From cfa9e8ab70ec2b57523c41591335a39aae00ad32 Mon Sep 17 00:00:00 2001
From: Thomas Kluyver <thomas@kluyver.me.uk>
Date: Fri, 20 Aug 2021 14:30:18 +0100
Subject: [PATCH] Add --prepare-only option for xfel-calibrate

---
 src/xfel_calibrate/calibrate.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/xfel_calibrate/calibrate.py b/src/xfel_calibrate/calibrate.py
index 1dd810b12..735730fe5 100755
--- a/src/xfel_calibrate/calibrate.py
+++ b/src/xfel_calibrate/calibrate.py
@@ -74,6 +74,9 @@ def make_initial_parser(**kwargs):
                         default=False,
                         help="Do not run as a cluster job")
 
+    parser.add_argument('--prepare-only', action="store_true",
+                        help="Prepare notebooks but don't run them")
+
     parser.add_argument('--report-to', type=str,
                         help='Filename (and optionally path) for output'
                              ' report')
@@ -1166,6 +1169,15 @@ def run():
     # Save information about jobs for reproducibility
     job_group.save()
 
+    if args['prepare_only']:
+        print("Files prepared, not executing now (--prepare-only option).")
+        print("To execute the notebooks, run:")
+        rpt_opts = ''
+        if user_venv is not None:
+            rpt_opts = f'--python {python_exe}'
+        print(f"  python -m xfel_calibrate.repeat {run_tmp_path} {rpt_opts}")
+        return
+
     submission_time = datetime.now().strftime('%Y-%m-%dT%H:%M:%S')
 
     # Launch the calibration work
-- 
GitLab