From e363fc4835dc39f848d5622bda3b12d15f4ecb86 Mon Sep 17 00:00:00 2001
From: ahmedk <karim.ahmed@xfel.eu>
Date: Wed, 9 Aug 2023 11:40:53 +0200
Subject: [PATCH] Update webservice.yaml to have reports_folder for both
 actions and use it in webservice.py

---
 webservice/config/webservice.yaml | 25 +++++++++++++------------
 webservice/webservice.py          | 22 ++++++++++++----------
 2 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/webservice/config/webservice.yaml b/webservice/config/webservice.yaml
index 2ed4d41f9..21132b400 100644
--- a/webservice/config/webservice.yaml
+++ b/webservice/config/webservice.yaml
@@ -45,27 +45,28 @@ correct:
       "(JF|LPD) Darks",
     ]
   cmd: >-
-    python -m xfel_calibrate.calibrate {detector} CORRECT
-    --slurm-scheduling {sched_prio}
-    --slurm-partition {partition}
-    --request-time {request_time}
-    --slurm-name {action}_{instrument}_{detector}_{cycle}_p{proposal}_{runs}
-    --report-to /gpfs/exfel/exp/{instrument}/{cycle}/p{proposal}/usr/Reports/{runs}/{det_instance}_{action}_{proposal}_{runs}_{time_stamp}
+    python -m xfel_calibrate.calibrate {{detector}} CORRECT
+    --slurm-scheduling {{sched_prio}}
+    --slurm-partition {{partition}}
+    --request-time {{request_time}}
+    --slurm-name {{action}}_{{instrument}}_{{detector}}_{{cycle}}_p{{proposal}}_{{runs}}
+    --report-to {reports_folder}/{{det_instance}}_{{action}}_{{proposal}}_{{runs}}_{{time_stamp}}
     --cal-db-timeout 300000
     --cal-db-interface tcp://max-exfl-cal001:8015#8044
 
 dark:
   in-folder: /gpfs/exfel/exp/{instrument}/{cycle}/p{proposal}/raw
   out-folder: /gpfs/exfel/u/usr/{instrument}/{cycle}/p{proposal}/dark/runs_{runs}
+  reports-folder: /gpfs/exfel/d/cal/caldb_store/xfel/reports/{instrument}/{det_instance}/{action}
   commissioning-penalty: 1250
   job-penalty: 2
   cmd: >-
-    python -m xfel_calibrate.calibrate {detector} DARK
+    python -m xfel_calibrate.calibrate {{detector}} DARK
     --concurrency-par karabo_da
-    --slurm-scheduling {sched_prio}
-    --slurm-partition {partition}
-    --request-time {request_time}
-    --slurm-name {action}_{instrument}_{detector}_{cycle}_p{proposal}_{runs}
-    --report-to /gpfs/exfel/d/cal/caldb_store/xfel/reports/{instrument}/{det_instance}/{action}/{action}_{proposal}_{runs}_{time_stamp}
+    --slurm-scheduling {{sched_prio}}
+    --slurm-partition {{partition}}
+    --request-time {{request_time}}
+    --slurm-name {{action}}_{{instrument}}_{{detector}}_{{cycle}}_p{{proposal}}_{{runs}}
+    --report-to {reports_folder}/{{action}}_{{proposal}}_{{runs}}_{{time_stamp}}
     --cal-db-interface tcp://max-exfl-cal001:8015#8044
     --db-output
diff --git a/webservice/webservice.py b/webservice/webservice.py
index fe2ae575e..bcc5c05ef 100644
--- a/webservice/webservice.py
+++ b/webservice/webservice.py
@@ -1461,16 +1461,18 @@ class ActionsServer:
             detector = dconfig['detector-type']
             del dconfig['detector-type']
             cmd = self.config[action]['cmd'].format(
-                detector=detector,
-                sched_prio=nice,
-                partition=partition,
-                action=action, instrument=instrument,
-                cycle=cycle, proposal=proposal,
-                runs="_".join([f"r{int(r):04d}" for r in run_nrs]),
-                time_stamp=request_time.strftime('%y%m%d_%H%M%S_%f'),
-                det_instance=karabo_id,
-                request_time=request_time.isoformat(),
-            ).split()
+                reports_folder=self.config[action]['reports-folder']
+                ).format(
+                    detector=detector,
+                    sched_prio=nice,
+                    partition=partition,
+                    action=action, instrument=instrument,
+                    cycle=cycle, proposal=proposal,
+                    runs="_".join([f"r{int(r):04d}" for r in run_nrs]),
+                    time_stamp=request_time.strftime('%y%m%d_%H%M%S_%f'),
+                    det_instance=karabo_id,
+                    request_time=request_time.isoformat(),
+                ).split()
             cmd = parse_config(cmd, dconfig)
 
             with time_db_transaction(self.job_db, 'Insert execution'):
-- 
GitLab