Skip to content

Commit 2c45516

Browse files
authored
Support relative path in docker run (#343)
* support relative path in docker run * remove unused library
1 parent 3b93437 commit 2c45516

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

automation/script/docker_utils.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
import copy
77

88

9+
def convert_to_abs_path(path):
10+
if not os.path.isabs(path):
11+
path = os.path.abspath(path)
12+
return path
13+
14+
915
def process_mounts(mounts, env, docker_settings, f_run_cmd):
1016
"""
1117
Processes and updates the Docker mounts based on the provided inputs and environment variables.
@@ -63,7 +69,6 @@ def process_mounts(mounts, env, docker_settings, f_run_cmd):
6369
else: # Skip mount if variable is missing
6470
mounts[index] = None
6571
break
66-
6772
# Skip further processing if the mount was invalid
6873
if mounts[index] is None:
6974
continue
@@ -241,7 +246,6 @@ def update_container_paths(path, mounts=None, force_target_path=''):
241246
if mounts is not None:
242247
if all(mount.lower() != mount_entry.lower() for mount in mounts):
243248
mounts.append(mount_entry)
244-
245249
return host_path, container_path
246250

247251

@@ -387,9 +391,10 @@ def get_docker_default(key):
387391

388392

389393
def get_host_path(value):
394+
# convert relative path to absolute path
395+
value = convert_to_abs_path(value)
396+
390397
path_split = value.split(os.sep)
391-
if len(path_split) == 1:
392-
return value
393398

394399
new_value = ''
395400
if "cache" in path_split and "local":
@@ -413,9 +418,10 @@ def get_container_path_script(i):
413418

414419

415420
def get_container_path(value, username="mlcuser"):
421+
# convert relative path to absolute path
422+
value = convert_to_abs_path(value)
423+
416424
path_split = value.split(os.sep)
417-
if len(path_split) == 1:
418-
return value, value
419425

420426
new_value = ''
421427
if "cache" in path_split and "local" in path_split:

0 commit comments

Comments
 (0)