Aufgrund einer Störung des s3 Storage, könnten in nächster Zeit folgende GitLab Funktionen nicht zur Verfügung stehen: LFS, Container Registry, Job Artifacs, Uploads (Wiki, Bilder, Projekt-Exporte). Wir bitten um Verständnis. Es wird mit Hochdruck an der Behebung des Problems gearbeitet. Weitere Informationen zur Störung des Object Storage finden Sie hier: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/59-object-storage-pilot

Commit 1cf9afcf authored by laochailan's avatar laochailan
Browse files

loadl merge: properly handle attempted overwrites

parent d72d756d
......@@ -68,13 +68,7 @@ def run():
print('Error: {}'.format(e))
sys.exit(1)
except jobfile.JobFileOverwriteError as e:
diff_summary = ''
for taskname, taskdiff in e.difference.items():
diff_summary += '{}:\n'.format(taskname)
for param, diff in taskdiff.items():
diff_summary += ' {}: {} -> {}\n'.format(param, diff[1], diff[0])
print('Error: You changed the job parameters of an existing simulation.\nSummary of changes:\n{}\nThis can be no problem or data-breaking depending on the situation. Use \'--force\' to force overwriting the parameters or \'--restart\' to start a blank run.'.format(diff_summary))
print('Error: You changed the job parameters of an existing simulation.\nSummary of changes:\n{}\nThis can be no problem or data-breaking depending on the situation. Use \'--force\' to force overwriting the parameters or \'--restart\' to start a blank run.'.format(e.diff_summary()))
sys.exit(1)
if args_run.single:
cmd = '{} single "{}"'.format(job.jobconfig['mc_binary'], job_input_filename)
......@@ -96,7 +90,11 @@ def delete():
os.unlink(results_file)
def merge():
job_input_filename = job.write_job_input_file(force_overwrite=args_run.force)
try:
job_input_filename = job.write_job_input_file(force_overwrite=False)
except (jobfile.JobFileGenError, jobfile.JobFileOverwriteError) as e:
print('Error: {}'.format(e))
sys.exit(1)
cmd = '{} merge "{}"'.format(job.jobconfig['mc_binary'], job_input_filename)
print('$ '+cmd)
subprocess.run(cmd, shell=True)
......
......@@ -13,6 +13,15 @@ class JobFileGenError(Exception):
class JobFileOverwriteError(Exception):
def __init__(self, difference):
self.difference = difference
def diff_summary(self):
summary = []
for taskname, taskdiff in self.difference.items():
summary.append('{}:'.format(taskname))
for param, diff in taskdiff.items():
summary.append(' {}: {} -> {}'.format(param, diff[1], diff[0]))
return '\n'.join(summary)
def __str__(self):
return 'Tried to overwrite existing job data with different parameters.\n{}'.format(self.diff_summary())
class JobFile:
def __init__(self, filename):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment