From c58fdc9830c6937b2cff411a37af339be0f32779 Mon Sep 17 00:00:00 2001 From: Golan Shatz Date: Tue, 3 Sep 2019 11:41:27 +0300 Subject: [PATCH] Update the running user as the horovod job user (#7) * 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 --- v3io_gputils/__init__.py | 2 +- v3io_gputils/mpijob.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/v3io_gputils/__init__.py b/v3io_gputils/__init__.py index fa9c4ec..2792152 100644 --- a/v3io_gputils/__init__.py +++ b/v3io_gputils/__init__.py @@ -1 +1 @@ -__version__ = '0.0.6' +__version__ = '0.0.7' diff --git a/v3io_gputils/mpijob.py b/v3io_gputils/mpijob.py index fa076e5..20f839e 100644 --- a/v3io_gputils/mpijob.py +++ b/v3io_gputils/mpijob.py @@ -31,7 +31,7 @@ 'driver': 'v3io/fuse', 'options': { 'container': 'users', - 'subPath': '/iguazio', + 'subPath': '', 'accessKey': '', } }}] @@ -70,6 +70,7 @@ 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 @@ -77,12 +78,15 @@ def _update_container(self, 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','')