From c58fdc9830c6937b2cff411a37af339be0f32779 Mon Sep 17 00:00:00 2001 From: Golan Shatz Date: Tue, 3 Sep 2019 11:41:27 +0300 Subject: [PATCH 1/2] 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','') From 13ac31acb49efd0514392716a2cfe22a0562db68 Mon Sep 17 00:00:00 2001 From: Golan Shatz Date: Thu, 5 Sep 2019 17:52:07 +0300 Subject: [PATCH 2/2] IG-13196: Set working directory to /User (#8) * Set working directory to /User * bump version to 0.0.8 * fix yams * add "working_dir" function --- v3io_gputils/__init__.py | 2 +- v3io_gputils/mpijob.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/v3io_gputils/__init__.py b/v3io_gputils/__init__.py index 2792152..9123cf0 100644 --- a/v3io_gputils/__init__.py +++ b/v3io_gputils/__init__.py @@ -1 +1 @@ -__version__ = '0.0.7' +__version__ = '0.0.8' diff --git a/v3io_gputils/mpijob.py b/v3io_gputils/mpijob.py index 20f839e..f74959f 100644 --- a/v3io_gputils/mpijob.py +++ b/v3io_gputils/mpijob.py @@ -21,6 +21,7 @@ 'name': '', 'command': [], 'volumeMounts': [{'name': 'v3io', 'mountPath': '/User'}], + 'workingDir': '/User', 'securityContext': { 'capabilities': {'add': ['IPC_LOCK']}}, 'resources': { @@ -111,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