From 7cfe3c34820f1e5ae719721ce0def138ac96a44b Mon Sep 17 00:00:00 2001
From: Thomas Kluyver <thomas@kluyver.me.uk>
Date: Fri, 8 Oct 2021 11:29:23 +0100
Subject: [PATCH] Improve warnings/errors around concurrency parameter

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

diff --git a/src/xfel_calibrate/calibrate.py b/src/xfel_calibrate/calibrate.py
index 961d39a7e..acb46ebea 100755
--- a/src/xfel_calibrate/calibrate.py
+++ b/src/xfel_calibrate/calibrate.py
@@ -609,7 +609,9 @@ def run(argv=None):
     run_uuid = f"t{datetime.now().strftime('%y%m%d_%H%M%S')}"
 
     # check if concurrency parameter is given and we run concurrently
-    if not any(p.name == "parameter" for p in nb_details.default_params) and concurrency_par is not None:
+    if concurrency_par is not None and not any(
+            p.name == concurrency_par for p in nb_details.default_params
+    ):
         msg = f"Notebook cannot be run concurrently: no {concurrency_par} parameter"
         warnings.warn(msg, RuntimeWarning)
 
@@ -764,6 +766,11 @@ def run(argv=None):
                 cvals = f(*callargs)
                 print(f"Split concurrency into {cvals}")
 
+        if cvals is None:
+            raise ValueError(
+                f"No values found for {concurrency_par} (concurrency parameter)"
+            )
+
         # get expected type
         cvtype = get_par_attr(parms, concurrency_par, 'type', list)
         cvals = remove_duplications(cvals)
-- 
GitLab