Skip to content

Commit cbcaffa

Browse files
authored
Support continue_on_error for script deps (mlcommons#734)
1 parent 9d8fa9f commit cbcaffa

File tree

1 file changed

+48
-42
lines changed

1 file changed

+48
-42
lines changed

automation/script/module.py

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3621,13 +3621,17 @@ def _run_deps(self, deps, clean_env_keys_deps, env, state, const, const_state, a
36213621
if d.get(key):
36223622
d[key] = {}
36233623

3624-
# print(f"ii = {ii}, d = {d}")
36253624
utils.merge_dicts(
36263625
{'dict1': ii, 'dict2': d, 'append_lists': True, 'append_unique': True})
36273626

36283627
r = self.action_object.access(ii)
36293628
if r['return'] > 0:
3630-
return r
3629+
if is_true(d.get('continue_on_error')):
3630+
# Warning printed by mlcflow
3631+
# logger.warning(f"Dependency with tags: {d['tags']} failed. Ignoring the failure as 'continue_on_error' is set for the dependency call")
3632+
pass
3633+
else:
3634+
return r
36313635

36323636
run_state['version_info'] = run_state_copy.get(
36333637
'version_info')
@@ -5466,53 +5470,55 @@ def prepare_and_run_script_with_postprocessing(i, postprocess="postprocess"):
54665470

54675471
rc = os.system(cmd)
54685472

5469-
if rc > 0 and not i.get('ignore_script_error', False):
5470-
# Check if print files when error
5471-
print_files = meta.get('print_files_if_script_error', [])
5472-
if len(print_files) > 0:
5473-
for pr in print_files:
5474-
if os.path.isfile(pr):
5475-
r = utils.load_txt(file_name=pr)
5476-
if r['return'] == 0:
5477-
logger.info(
5478-
"========================================================")
5479-
logger.info("Print file {}:".format(pr))
5480-
logger.info("")
5481-
logger.info(r['string'])
5482-
logger.info("")
5483-
5484-
# Check where to report errors and failures
5485-
repo_to_report = run_state.get(
5486-
'script_entry_repo_to_report_errors', '')
5487-
5488-
if repo_to_report == '':
5489-
script_repo_alias = run_state.get('script_repo_alias', '')
5490-
script_repo_git = run_state.get('script_repo_git', False)
5491-
5492-
if script_repo_git and script_repo_alias != '':
5493-
repo_to_report = 'https://github.com/' + \
5494-
script_repo_alias.replace('@', '/') + '/issues'
5495-
5496-
if repo_to_report == '':
5497-
repo_to_report = 'https://github.com/mlcommons/mlperf-automations/issues'
5498-
5499-
note = '''
5473+
if rc > 0:
5474+
if not is_true(i.get('ignore_script_error', False)):
5475+
# Check if print files when error
5476+
print_files = meta.get('print_files_if_script_error', [])
5477+
if len(print_files) > 0:
5478+
for pr in print_files:
5479+
if os.path.isfile(pr):
5480+
r = utils.load_txt(file_name=pr)
5481+
if r['return'] == 0:
5482+
logger.info(
5483+
"========================================================")
5484+
logger.info("Print file {}:".format(pr))
5485+
logger.info("")
5486+
logger.info(r['string'])
5487+
logger.info("")
5488+
5489+
# Check where to report errors and failures
5490+
repo_to_report = run_state.get(
5491+
'script_entry_repo_to_report_errors', '')
5492+
5493+
if repo_to_report == '':
5494+
script_repo_alias = run_state.get('script_repo_alias', '')
5495+
script_repo_git = run_state.get('script_repo_git', False)
5496+
5497+
if script_repo_git and script_repo_alias != '':
5498+
repo_to_report = 'https://github.com/' + \
5499+
script_repo_alias.replace('@', '/') + '/issues'
5500+
5501+
if repo_to_report == '':
5502+
repo_to_report = 'https://github.com/mlcommons/mlperf-automations/issues'
5503+
5504+
note = '''
55005505
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
55015506
Please file an issue at {} along with the full MLC command being run and the relevant
55025507
or full console log.
55035508
'''.format(repo_to_report)
55045509

5505-
rr = {
5506-
'return': 2,
5507-
'error': 'MLC script failed (name = {}, return code = {})\n\n{}'.format(
5508-
meta['alias'],
5509-
rc,
5510-
note)}
5510+
rr = {
5511+
'return': 2,
5512+
'error': f"""Native run script failed inside MLC script (name = {meta['alias']}, return code = {rc})\n\n{note}"""
5513+
}
55115514

5512-
if repro_prefix != '':
5513-
dump_repro(repro_prefix, rr, run_state)
5515+
if repro_prefix != '':
5516+
dump_repro(repro_prefix, rr, run_state)
55145517

5515-
return rr
5518+
return rr
5519+
else:
5520+
logger.warn(
5521+
f"""Native run script failed inside MLC script (name = {meta['alias']}, return code = {rc}. Ignoring as ignore_script_error is set.)\n""")
55165522

55175523
# Load updated state if exists
55185524
if tmp_file_run_state != '' and os.path.isfile(tmp_file_run_state):

0 commit comments

Comments
 (0)