From 6adc6b7ab7753bb6bdea4e8690f92f00f51fab59 Mon Sep 17 00:00:00 2001 From: Philipp Schmidt <philipp.schmidt@xfel.eu> Date: Thu, 21 Oct 2021 11:00:11 +0200 Subject: [PATCH] Add warning to xfel-calibrate if configuration may cause result to not be reproducible --- src/xfel_calibrate/calibrate.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/xfel_calibrate/calibrate.py b/src/xfel_calibrate/calibrate.py index 5b0198db6..a19663148 100755 --- a/src/xfel_calibrate/calibrate.py +++ b/src/xfel_calibrate/calibrate.py @@ -985,6 +985,34 @@ def run(): caltype = args["type"].upper() sequential = args["no_cluster_job"] + # Pick out any arguments that may prevent reproducibility from + # working, sorted alphabetically and converted back to their + # canonical representation. + not_reproducible_args = sorted( + ('--' + x.replace('_', '-') + for x in ['skip_report', 'skip_env_freeze'] + if args[x])) + + # If any of these arguments are set, present a warning. + if not_reproducible_args: + print('WARNING: One or more command line arguments ({}) may prevent ' + 'this specific correction result from being reproducible based ' + 'on its metadata. It may not be possible to restore identical ' + 'output data files when they have been deleted or lost. Please ' + 'ensure that the data retention policy of the chosen storage ' + 'location is sufficient for your ' + 'needs.'.format(', '.join(not_reproducible_args))) + + try: + input('Press ENTER to continue or CTRL+C to abort...') + except KeyboardInterrupt: + # Catch the interrupt and silently exit. + sys.exit(0) + + reproducible = False + else: + reproducible = True + try: nb_info = notebooks[detector][caltype] except KeyError: @@ -1100,6 +1128,7 @@ def run(): metadata["pycalibration-version"] = version metadata["report-path"] = f"{report_to}.pdf" if report_to \ else '# REPORT SKIPPED #' + metadata['reproducible'] = reproducible metadata["concurrency"] = { 'parameter': concurrency_par, 'default': concurrency_defval, -- GitLab