Skip to content

Commit

Permalink
Update the running user as the horovod job user (#7)
Browse files Browse the repository at this point in the history
* 1. initialize mpijob with the home directory of the jury running user
2. enable 'volume' function to work on all containers (not only 'users')

* Bump version to 0.0.7
  • Loading branch information
gshatz authored Sep 3, 2019
1 parent 887b661 commit c58fdc9
Show file tree
Hide file tree
Showing 2 changed files with 8 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.7'
10 changes: 7 additions & 3 deletions v3io_gputils/mpijob.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
'driver': 'v3io/fuse',
'options': {
'container': 'users',
'subPath': '/iguazio',
'subPath': '',
'accessKey': '',
}
}}]
Expand Down Expand Up @@ -70,19 +70,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 Down

0 comments on commit c58fdc9

Please sign in to comment.