Skip to content

Support relative path in docker run #343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions automation/script/docker_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
import copy


def convert_to_abs_path(path):
if not os.path.isabs(path):
path = os.path.abspath(path)
return path


def process_mounts(mounts, env, docker_settings, f_run_cmd):
"""
Processes and updates the Docker mounts based on the provided inputs and environment variables.
Expand Down Expand Up @@ -63,7 +69,6 @@ def process_mounts(mounts, env, docker_settings, f_run_cmd):
else: # Skip mount if variable is missing
mounts[index] = None
break

# Skip further processing if the mount was invalid
if mounts[index] is None:
continue
Expand Down Expand Up @@ -241,7 +246,6 @@ def update_container_paths(path, mounts=None, force_target_path=''):
if mounts is not None:
if all(mount.lower() != mount_entry.lower() for mount in mounts):
mounts.append(mount_entry)

return host_path, container_path


Expand Down Expand Up @@ -387,9 +391,10 @@ def get_docker_default(key):


def get_host_path(value):
# convert relative path to absolute path
value = convert_to_abs_path(value)

path_split = value.split(os.sep)
if len(path_split) == 1:
return value

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


def get_container_path(value, username="mlcuser"):
# convert relative path to absolute path
value = convert_to_abs_path(value)

path_split = value.split(os.sep)
if len(path_split) == 1:
return value, value

new_value = ''
if "cache" in path_split and "local" in path_split:
Expand Down
Loading