Skip to content

Commit 9af8083

Browse files
committed
support mounting file paths in docker
1 parent 48f74d5 commit 9af8083

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

automation/script/docker_utils.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,16 @@ def process_mounts(mounts, env, docker_settings, f_run_cmd):
7878

7979
# Update container environment string and mappings
8080
if host_env_key:
81-
container_env_string += f" --env.{host_env_key}={container_env_key} "
81+
# We are modifying the input mapping variables wrt to the new container env variable. Is explicit passing of env variable necessary?
82+
# container_env_string += f" --env.{host_env_key}={container_env_key} "
8283
for key, value in docker_input_mapping.items():
8384
if value == host_env_key:
84-
f_run_cmd[key] = container_env_key
85+
# If we want to pass/mount a filepath, now its mounting its parent folder
86+
# and in the input, along with the parent folder, filename is also passed to access
87+
if os.path.basename(env[host_env_key]) != "":
88+
f_run_cmd[key] = os.path.join(container_env_key, os.path.basename(env[host_env_key]))
89+
else:
90+
f_run_cmd[key] = container_env_key
8591

8692
# Remove invalid mounts and construct mount string
8793
mounts = [item for item in mounts if item is not None]
@@ -392,7 +398,7 @@ def get_docker_default(key):
392398

393399
def get_host_path(value):
394400
# convert relative path to absolute path
395-
value = convert_to_abs_path(value)
401+
value = os.path.dirname(convert_to_abs_path(value))
396402

397403
path_split = value.split(os.sep)
398404

@@ -419,7 +425,8 @@ def get_container_path_script(i):
419425

420426
def get_container_path(value, username="mlcuser"):
421427
# convert relative path to absolute path
422-
value = convert_to_abs_path(value)
428+
# if we are trying to mount a file, mount the parent folder.
429+
value = os.path.dirname(convert_to_abs_path(value))
423430

424431
path_split = value.split(os.sep)
425432

script/run-mlperf-inference-submission-checker/meta.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,34 @@ deps:
4040
MLC_TMP_MLPERF_INFERENCE_PREPROCESS_SUBMISSION:
4141
- 'on'
4242
tags: preprocess,mlperf,inference,submission
43+
docker:
44+
mlc_repo: mlcommons@mlperf-automations
45+
mlc_repo_branch: dev
46+
extra_run_args: ' --cap-add SYS_ADMIN'
47+
os: ubuntu
48+
os_version: '22.04'
49+
pre_run_cmds:
50+
- mlc pull repo
51+
real_run: false
52+
use_host_group_id: true
53+
use_host_user_id: true
54+
deps:
55+
- names:
56+
- get-mlperf-submission-dir
57+
skip_if_env:
58+
MLC_MLPERF_INFERENCE_SUBMISSION_DIR:
59+
- 'on'
60+
tags: get,mlperf,submission,dir
61+
- enable_if_env:
62+
MLC_TMP_MLPERF_INFERENCE_PREPROCESS_SUBMISSION:
63+
- 'on'
64+
tags: preprocess,mlperf,inference,submission
65+
input_mapping:
66+
submission_dir: MLC_MLPERF_INFERENCE_SUBMISSION_DIR
67+
submission_tar_file: MLPERF_INFERENCE_SUBMISSION_TAR_FILE
68+
mounts:
69+
- ${{ MLC_MLPERF_INFERENCE_SUBMISSION_DIR }}:${{ MLC_MLPERF_INFERENCE_SUBMISSION_DIR }}
70+
- ${{ MLPERF_INFERENCE_SUBMISSION_TAR_FILE }}:${{ MLPERF_INFERENCE_SUBMISSION_TAR_FILE }}
4371
input_mapping:
4472
extra_args: MLC_MLPERF_SUBMISSION_CHECKER_EXTRA_ARGS
4573
extra_checker_args: MLC_MLPERF_SUBMISSION_CHECKER_EXTRA_ARGS
@@ -60,6 +88,7 @@ input_mapping:
6088
submission_dir: MLC_MLPERF_INFERENCE_SUBMISSION_DIR
6189
submitter: MLC_MLPERF_SUBMITTER
6290
submitter_id: MLC_MLPERF_SUBMITTER_ID
91+
submission_tar_file: MLPERF_INFERENCE_SUBMISSION_TAR_FILE
6392
tar: MLC_TAR_SUBMISSION_DIR
6493
post_deps:
6594
- enable_if_env:

0 commit comments

Comments
 (0)