Skip to content

Commit 5b12e32

Browse files
committed
Support --docker_mlc_repo_path
1 parent a5d9868 commit 5b12e32

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

automation/script/docker.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def dockerfile(self_module, input_params):
173173
comments = []
174174

175175
# Push Docker image if specified
176-
if input_params.get('docker_push_image') in [True, 'True', 'yes']:
176+
if str(input_params.get('docker_push_image')).lower() in [ 'true', 'yes', '1']:
177177
env['MLC_DOCKER_PUSH_IMAGE'] = 'yes'
178178

179179
dockerfile_env = docker_inputs.get('env', {})
@@ -191,6 +191,10 @@ def dockerfile(self_module, input_params):
191191
'quiet': True, 'real_run': True
192192
}
193193

194+
if docker_inputs.get('mlc_repo_path', '') != '':
195+
mlc_docker_input['mlc_repo_path'] = docker_inputs['mlc_repo_path']
196+
197+
194198
docker_v = False
195199
docker_s = False
196200
if is_true(input_params.get(

automation/script/docker_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def prepare_docker_inputs(input_params, docker_settings,
136136
"""
137137

138138
keys = [
139-
"mlc_repo", "mlc_repo_branch", "base_image", "os", "os_version",
139+
"mlc_repo", "mlc_repo_branch", "base_image", "os", "os_version", "mlc_repo_path",
140140
"mlc_repos", "skip_mlc_sys_upgrade", "extra_sys_deps", "image_name",
141141
"gh_token", "fake_run_deps", "run_final_cmds", "real_run", "copy_files", "path", "user", "env", "build_env"
142142
]

script/build-dockerfile/customize.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ def preprocess(i):
8787
"Dockerfile")))
8888
os.makedirs(build_context_dir, exist_ok=True)
8989

90+
repo_name = os.path.basename(mlc_repo_path)
9091
# Create mlc_repo directory relative to the build context
91-
repo_build_context_path = os.path.join(build_context_dir, "mlc_repo")
92+
repo_build_context_path = os.path.join(build_context_dir, "mlc_repo", repo_name)
9293

9394
# Remove existing directory if it exists
9495
if os.path.exists(repo_build_context_path):
@@ -309,8 +310,8 @@ def preprocess(i):
309310

310311
docker_use_virtual_python = env.get('MLC_DOCKER_USE_VIRTUAL_PYTHON', "yes")
311312
if not is_false(docker_use_virtual_python):
312-
f.write('RUN {} -m venv $HOME/venv/mlc'.format(python) + " " + EOL)
313-
f.write('ENV PATH="$HOME/venv/mlc/bin:$PATH"' + EOL)
313+
f.write('RUN {} -m venv $HOME/venv/mlcflow'.format(python) + " " + EOL)
314+
f.write('ENV PATH="$HOME/venv/mlcflow/bin:$PATH"' + EOL)
314315
# f.write('RUN . /opt/venv/mlc/bin/activate' + EOL)
315316

316317
f.write('ENV PATH="$PATH:$HOME/.local/bin"' + EOL)
@@ -328,22 +329,27 @@ def preprocess(i):
328329
EOL)
329330

330331
f.write(EOL + '# Download MLC repo for scripts' + EOL)
331-
pat = env.get('MLC_GH_TOKEN')
332-
if pat:
332+
pat = env.get('MLC_GH_TOKEN', '')
333+
334+
if pat != '':
333335
token_string = f" --pat={pat}"
334336
else:
335337
token_string = ""
336338

337339
if use_copy_repo:
338-
docker_repo_dest = "$HOME/MLC/repos/mlcommons@mlperf-automations"
340+
repo_name = os.path.basename(relative_repo_path)
341+
docker_repo_dest = f"$HOME/MLC/repos/{repo_name}"
339342
f.write(
340-
f'COPY --chown=mlcuser:mlc {relative_repo_path} {docker_repo_dest}' +
343+
f'COPY --chown={docker_user}:{docker_group} {relative_repo_path} {docker_repo_dest}' +
341344
EOL)
342345

343346
f.write(EOL + '# Register MLC repository' + EOL)
344347
f.write(
345-
'RUN mlc pull repo --url={} {token_string} --quiet'.format(docker_repo_dest) +
348+
'RUN mlc add repo {} --quiet'.format(docker_repo_dest) +
346349
EOL)
350+
#f.write(
351+
# 'RUN mlc pull repo --url={} {} --quiet'.format(docker_repo_dest, token_string) +
352+
# EOL)
347353
f.write(EOL)
348354

349355
else:

script/build-dockerfile/meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ input_mapping:
4545
gh_token: MLC_GH_TOKEN
4646
image_repo: MLC_DOCKER_IMAGE_REPO
4747
image_tag: MLC_DOCKER_IMAGE_TAG
48+
mlc_repo_path: MLC_REPO_PATH
4849
package_manager_update_cmd: MLC_PACKAGE_MANAGER_UPDATE_CMD
4950
pip_extra_flags: MLC_DOCKER_PIP_INSTALL_EXTRA_FLAGS
5051
post_file: DOCKER_IMAGE_POST_FILE

0 commit comments

Comments
 (0)