Die Migration der Bereiche "Docker Registry" und "Artifiacts" ist fast abgeschlossen. Die letzten Daten werden im Laufe des heutigen Abend (05.08.2021) noch vollständig hochgeladen. Das Anlegen neuer Images und Artifacts funktioniert bereits wieder.

Commit 738dd515 authored by laochailan's avatar laochailan
Browse files

add warning for overwriting existing parameters.

parent 0fd798b9
......@@ -62,7 +62,20 @@ def run():
except StopIteration:
job_input_filename = job.write_job_input_file()
job_input_filename = job.write_job_input_file(force_overwrite=args_run.force)
except jobfile.JobFileGenError as e:
print('Error: {}'.format(e))
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))
if args_run.single:
cmd = '{} single "{}"'.format(job.jobconfig['mc_binary'], job_input_filename)
print('$ '+cmd)
......@@ -2,6 +2,7 @@ import json
import os
import subprocess
import errno
from collections import defaultdict
'''Helpers for handling loadleveller jobfiles/scripts. For lack of a better idea, the job description files of loadleveller are actually executables that output a more verbose json parameter file to stdout. Use the taskmaker module to write the input scripts.'''
......@@ -9,6 +10,10 @@ import errno
class JobFileGenError(Exception):
class JobFileOverwriteError(Exception):
def __init__(self, difference):
self.difference = difference
class JobFile:
def __init__(self, filename):
env = dict(os.environ)
......@@ -25,18 +30,38 @@ class JobFile:
except Exception as e:
raise JobFileGenError('Could not parse job generation script output: {}'.format(e))
def write_job_input_file(self):
def _compare_to_old(self, old_data):
diff = defaultdict(dict)
for taskname, task in self.tasks.items():
if taskname in old_data['tasks']:
old_task = old_data['tasks'][taskname]
for param, value in task.items():
if param not in old_task:
diff[taskname][param] = (value, None)
elif value != old_task[param]:
diff[taskname][param] = (value, old_task[param])
return diff
def write_job_input_file(self, force_overwrite):
datadir = self.jobname + '.data'
except OSError as e:
if e.errno != errno.EEXIST:
job_input_filename = os.path.join(datadir, 'parameters.json')
if os.path.isfile(job_input_filename):
with open(job_input_filename, 'r') as f:
old_data = json.load(f)
diff = self._compare_to_old(old_data)
if not force_overwrite and len(diff) > 0:
raise JobFileOverwriteError(difference=diff)
datadir = self.jobname + '.data'
except OSError as e:
if e.errno != errno.EEXIST:
job_input_filename = os.path.join(datadir, 'parameters.json')
with open(job_input_filename, 'w') as f:
except Exception as e:
except JobFileGenError as e:
raise JobFileGenError('Could not write parameters.json: {}'.format(e))
return job_input_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