Skip to content

Commit 610fe10

Browse files
authored
Merge pull request #706 from amd/dev
Merge from AMD
2 parents 03d4f03 + c18c100 commit 610fe10

File tree

6 files changed

+56
-39
lines changed

6 files changed

+56
-39
lines changed

automation/script/docker.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ 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')
177+
).lower() in ['true', 'yes', '1']:
177178
env['MLC_DOCKER_PUSH_IMAGE'] = 'yes'
178179

179180
dockerfile_env = docker_inputs.get('env', {})
@@ -191,6 +192,9 @@ def dockerfile(self_module, input_params):
191192
'quiet': True, 'real_run': True
192193
}
193194

195+
if docker_inputs.get('mlc_repo_path', '') != '':
196+
mlc_docker_input['mlc_repo_path'] = docker_inputs['mlc_repo_path']
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
]

automation/script/help.py

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ def display_help(self_module, input_params):
2626
generic_inputs = self_module.input_flags_converted_to_env
2727

2828
# Step 2: Search for scripts
29-
search_result = self_module.search(input_params.copy())
30-
if search_result['return'] > 0:
31-
return search_result
3229

33-
scripts_list = search_result['list']
34-
if not scripts_list:
30+
r = self_module._select_script(input_params)
31+
if r['return'] > 0:
32+
return r
33+
34+
script = r['script']
35+
36+
if not script:
3537

3638
print("")
3739
print("Please use script tags or alias/uid to get help for a specific script")
@@ -41,17 +43,14 @@ def display_help(self_module, input_params):
4143
print_input_descriptions(generic_inputs)
4244

4345
else:
44-
# Step 4: Iterate over scripts and generate help output
45-
for script in sorted(
46-
scripts_list, key=lambda x: x.meta.get('alias', '')):
47-
metadata = script.meta
48-
script_path = script.path
49-
print_script_help(
50-
metadata,
51-
script_path,
52-
generic_inputs,
53-
env,
54-
self_module)
46+
metadata = script.meta
47+
script_path = script.path
48+
print_script_help(
49+
metadata,
50+
script_path,
51+
generic_inputs,
52+
env,
53+
self_module)
5554

5655
return {'return': 0}
5756

@@ -146,22 +145,28 @@ def print_input_descriptions(input_descriptions):
146145
if not input_descriptions:
147146
print("\tNo inputs")
148147

149-
for key in input_descriptions:
148+
for key in sorted(input_descriptions):
150149
field = input_descriptions[key]
151150
env_key = field.get('env_key', f"""MLC_TMP_{key.upper()}""")
152151
desc = field.get('desc')
153-
default = field.get('default', 'None')
152+
default = field.get('default', None)
154153
choices = field.get("choices", "")
155154
dtype = infer_type(field)
155+
156+
line = []
157+
156158
# Use .ljust(15) to ensure the key occupies 15 characters minimum
157-
print(f"\t--{key.ljust(26)}: maps to --env.{env_key}")
158-
if desc:
159-
print(f"\t{' '.ljust(30)}Desc: {desc}")
160-
print(f"\t{' '.ljust(30)}Default: {default}")
159+
line.append(f"--{key.ljust(26)}: maps to --env.{env_key}")
160+
if default:
161+
line.append(f"{' '.ljust(30)}Default: {default}")
162+
# if dtype:
163+
# line.append(f"{' '.ljust(30)}Type: {dtype}")
161164
if choices:
162-
print(f"\t{' '.ljust(30)}Choices: {choices}")
163-
if dtype:
164-
print(f"\t{' '.ljust(30)}Type: {dtype}")
165+
line.append(f"{' '.ljust(30)}Choices: {choices}")
166+
if desc:
167+
line.append(f"{' '.ljust(30)}Desc: {desc}")
168+
169+
print("\t" + "\t\n\t".join(line))
165170
print("")
166171

167172

automation/script/module.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ def _run(self, i):
251251
import time
252252
import shutil
253253

254+
# Check if has --help
255+
if i.get('help', False):
256+
return self.help(i)
257+
254258
# Check if save input/output to file
255259
repro = i.get('repro', False)
256260
repro_prefix = ''
@@ -788,10 +792,6 @@ def _run(self, i):
788792
env['MLC_TMP_CURRENT_SCRIPT_REPO_PATH'] = script_repo_path
789793
env['MLC_TMP_CURRENT_SCRIPT_REPO_PATH_WITH_PREFIX'] = script_repo_path_with_prefix
790794

791-
# Check if has --help
792-
if i.get('help', False):
793-
return self.help(i)
794-
795795
run_state['script_id'] = meta['alias'] + "," + meta['uid']
796796
run_state['script_tags'] = script_tags
797797
run_state['script_variation_tags'] = variation_tags

script/build-dockerfile/customize.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ 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(
93+
build_context_dir, "mlc_repo", repo_name)
9294

9395
# Remove existing directory if it exists
9496
if os.path.exists(repo_build_context_path):
@@ -309,8 +311,8 @@ def preprocess(i):
309311

310312
docker_use_virtual_python = env.get('MLC_DOCKER_USE_VIRTUAL_PYTHON', "yes")
311313
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)
314+
f.write('RUN {} -m venv $HOME/venv/mlcflow'.format(python) + " " + EOL)
315+
f.write('ENV PATH="$HOME/venv/mlcflow/bin:$PATH"' + EOL)
314316
# f.write('RUN . /opt/venv/mlc/bin/activate' + EOL)
315317

316318
f.write('ENV PATH="$PATH:$HOME/.local/bin"' + EOL)
@@ -328,22 +330,27 @@ def preprocess(i):
328330
EOL)
329331

330332
f.write(EOL + '# Download MLC repo for scripts' + EOL)
331-
pat = env.get('MLC_GH_TOKEN')
332-
if pat:
333+
pat = env.get('MLC_GH_TOKEN', '')
334+
335+
if pat != '':
333336
token_string = f" --pat={pat}"
334337
else:
335338
token_string = ""
336339

337340
if use_copy_repo:
338-
docker_repo_dest = "$HOME/MLC/repos/mlcommons@mlperf-automations"
341+
repo_name = os.path.basename(relative_repo_path)
342+
docker_repo_dest = f"$HOME/MLC/repos/{repo_name}"
339343
f.write(
340-
f'COPY --chown=mlcuser:mlc {relative_repo_path} {docker_repo_dest}' +
344+
f'COPY --chown={docker_user}:{docker_group} {relative_repo_path} {docker_repo_dest}' +
341345
EOL)
342346

343347
f.write(EOL + '# Register MLC repository' + EOL)
344348
f.write(
345-
'RUN mlc pull repo --url={} {token_string} --quiet'.format(docker_repo_dest) +
349+
'RUN mlc add repo {} --quiet'.format(docker_repo_dest) +
346350
EOL)
351+
# f.write(
352+
# 'RUN mlc pull repo --url={} {} --quiet'.format(docker_repo_dest, token_string) +
353+
# EOL)
347354
f.write(EOL)
348355

349356
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)