From 89f89c901880e04ab9d07ab5dc984cf6b0cf86a8 Mon Sep 17 00:00:00 2001
From: Philipp Schmidt <philipp.schmidt@xfel.eu>
Date: Tue, 5 Apr 2022 10:12:31 +0200
Subject: [PATCH] Add slurm priority penalties to webservice configuration

---
 webservice/config/webservice.yaml | 6 ++++--
 webservice/webservice.py          | 5 ++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/webservice/config/webservice.yaml b/webservice/config/webservice.yaml
index 7a764b0fa..c91b4b923 100644
--- a/webservice/config/webservice.yaml
+++ b/webservice/config/webservice.yaml
@@ -31,7 +31,8 @@ kafka:
 correct:
     in-folder: /gpfs/exfel/exp/{instrument}/{cycle}/p{proposal}/raw
     out-folder: /gpfs/exfel/d/proc/{instrument}/{cycle}/p{proposal}/{run}
-    sched-prio: 80
+    commissioning-penalty: 1250
+    job-penalty: 2
     cmd : >-
         python -m xfel_calibrate.calibrate {detector} CORRECT
         --slurm-scheduling {sched_prio}
@@ -45,7 +46,8 @@ correct:
 dark:
     in-folder: /gpfs/exfel/exp/{instrument}/{cycle}/p{proposal}/raw
     out-folder: /gpfs/exfel/u/usr/{instrument}/{cycle}/p{proposal}/dark/runs_{runs}
-    sched-prio: 10
+    commissioning-penalty: 1250
+    job-penalty: 2
     cmd: >-
         python -m xfel_calibrate.calibrate {detector} DARK
         --concurrency-par karabo_da
diff --git a/webservice/webservice.py b/webservice/webservice.py
index 5fde4f4bb..983d33e58 100644
--- a/webservice/webservice.py
+++ b/webservice/webservice.py
@@ -1255,7 +1255,10 @@ class ActionsServer:
         ret = []
 
         partition = await get_slurm_partition(self.mdc, action, proposal)
-        nice = await get_slurm_nice(partition, instrument, cycle)
+        nice = await get_slurm_nice(
+            partition, instrument, cycle,
+            commissioning_penalty=self.config[action]['commissioning-penalty'],
+            job_penalty=self.config[action]['job-penalty'])
 
         # run xfel_calibrate
         for karabo_id, dconfig in detectors.items():
-- 
GitLab