From a7d5d474749a76ed3d3e2d200b7bcea3f062fc34 Mon Sep 17 00:00:00 2001
From: Thomas Kluyver <thomas@kluyver.me.uk>
Date: Thu, 17 Nov 2022 12:35:45 +0000
Subject: [PATCH] Launch and stop CalParrot when running correction notebooks

---
 bin/slurm_calibrate.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/bin/slurm_calibrate.sh b/bin/slurm_calibrate.sh
index 2d8dfccbf..14e6d96d6 100755
--- a/bin/slurm_calibrate.sh
+++ b/bin/slurm_calibrate.sh
@@ -43,10 +43,26 @@ then
     sleep 15
 fi
 
+# Launch CalParrot to repeat calibration constant queries
+if [ "$caltype" == "CORRECT" ]
+then
+  port_file=$(mktemp)
+  ${python_path} -m calparrot --port-file $port_file
+  calparrot_port=$(cat $port_file)
+  rm $port_file
+  export CAL_CAL_TOOLS_CALCAT__base-api-url="http://127.0.0.1:${calparrot_port}"
+  export CAL_CAL_TOOLS_CALCAT__use-oauth2=false
+fi
 
 echo "Running notebook"
 ${python_path} -m princess ${nb_path} --save
 
+# Stop CalParrot
+if [ "$caltype" == "CORRECT" ]
+then
+  ${python_path} -m calparrot.stop $calparrot_port
+fi
+
 # stop the cluster if requested
 if [ "${ipcluster_profile}" != "NO_CLUSTER" ]
 then
-- 
GitLab