Skip to content

Commit

Permalink
Merge pull request #9 from v3io/development
Browse files Browse the repository at this point in the history
Development --> Master (0.0.8)
  • Loading branch information
gshatz authored Sep 5, 2019
2 parents b1db4e0 + 13ac31a commit 8d18c6b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion v3io_gputils/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.6'
__version__ = '0.0.8'
15 changes: 12 additions & 3 deletions v3io_gputils/mpijob.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
'name': '',
'command': [],
'volumeMounts': [{'name': 'v3io', 'mountPath': '/User'}],
'workingDir': '/User',
'securityContext': {
'capabilities': {'add': ['IPC_LOCK']}},
'resources': {
Expand All @@ -31,7 +32,7 @@
'driver': 'v3io/fuse',
'options': {
'container': 'users',
'subPath': '/iguazio',
'subPath': '',
'accessKey': '',
}
}}]
Expand Down Expand Up @@ -70,19 +71,23 @@ def __init__(self, name, image=None, command=None,
if replicas:
self._struct['spec']['replicas'] = replicas
self._update_access_token(environ.get('V3IO_ACCESS_KEY',''))
self._update_running_user(environ.get('V3IO_USERNAME',''))

def _update_container(self, key, value):
self._struct['spec']['template']['spec']['containers'][0][key] = value

def _update_access_token(self, token):
self._struct['spec']['template']['spec']['volumes'][0]['flexVolume']['options']['accessKey'] = token

def _update_running_user(self, username):
self._struct['spec']['template']['spec']['volumes'][0]['flexVolume']['options']['subPath'] = '/' + username

def volume(self, mount='/User', volpath='~/', access_key=''):
self._update_container('volumeMounts', [{'name': 'v3io', 'mountPath': mount}])

if volpath.startswith('~/'):
user = environ.get('V3IO_USERNAME', '')
volpath = 'users/' + user + volpath[1:]
v3io_home = environ.get('V3IO_HOME', '')
volpath = v3io_home + volpath[1:]

container, subpath = split_path(volpath)
access_key = access_key or environ.get('V3IO_ACCESS_KEY','')
Expand All @@ -107,6 +112,10 @@ def replicas(self, replicas_num):
self._struct['spec']['replicas'] = replicas_num
return self

def working_dir(self, working_dir):
self._update_container('workingDir', working_dir)
return self

def to_dict(self):
return self._struct

Expand Down

0 comments on commit 8d18c6b

Please sign in to comment.