diff --git a/v3io_gputils/__init__.py b/v3io_gputils/__init__.py index fa9c4ec..9123cf0 100644 --- a/v3io_gputils/__init__.py +++ b/v3io_gputils/__init__.py @@ -1 +1 @@ -__version__ = '0.0.6' +__version__ = '0.0.8' diff --git a/v3io_gputils/mpijob.py b/v3io_gputils/mpijob.py index fa076e5..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': { @@ -31,7 +32,7 @@ 'driver': 'v3io/fuse', 'options': { 'container': 'users', - 'subPath': '/iguazio', + 'subPath': '', 'accessKey': '', } }}] @@ -70,6 +71,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 +79,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','') @@ -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