From 7981f6d2383d28f1851cf67e48af04c1cfdaad54 Mon Sep 17 00:00:00 2001
From: Philipp Schmidt <philipp.schmidt@xfel.eu>
Date: Thu, 21 Oct 2021 11:00:40 +0200
Subject: [PATCH] Add --not-reproducible flag to xfel-calibrate to skip
 confirmation

---
 src/xfel_calibrate/calibrate.py | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/xfel_calibrate/calibrate.py b/src/xfel_calibrate/calibrate.py
index a19663148..6d53b8dae 100755
--- a/src/xfel_calibrate/calibrate.py
+++ b/src/xfel_calibrate/calibrate.py
@@ -83,6 +83,11 @@ def make_initial_parser(**kwargs):
                         help='Filename (and optionally path) for output'
                              ' report')
 
+    parser.add_argument('--not-reproducible', action='store_true',
+                        help='Disable checks or confirmations that may cause '
+                             'the processed result to not be reproducible at '
+                             'a later point in time.')
+
     parser.add_argument('--skip-report', action='store_true',
                         help='Skip report generation in finalize step.')
 
@@ -990,7 +995,7 @@ def run():
     # canonical representation.
     not_reproducible_args = sorted(
         ('--' + x.replace('_', '-')
-         for x in ['skip_report', 'skip_env_freeze']
+         for x in ['not_reproducible', 'skip_report', 'skip_env_freeze']
          if args[x]))
 
     # If any of these arguments are set, present a warning.
@@ -1003,11 +1008,14 @@ def run():
               '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)
+        if not args['not_reproducible']:
+            # If reproducibility has not been permitted to be broken
+            # explicitly, force the user to confirm this explicitly.
+            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:
-- 
GitLab