From db4399fc7ada7f08b5ed4e739888d9a314a83099 Mon Sep 17 00:00:00 2001 From: Cyril Danilevski <cyril.danilevski@xfel.eu> Date: Thu, 1 Sep 2022 10:27:23 +0200 Subject: [PATCH] Select partition based on beamtime dates --- webservice/webservice.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/webservice/webservice.py b/webservice/webservice.py index 9fa4119f4..7b4cbe6e3 100644 --- a/webservice/webservice.py +++ b/webservice/webservice.py @@ -518,7 +518,8 @@ async def get_slurm_partition( partition. The partition is either upex-high (for darks) or upex-middle (for - corrections) if the proposal is 'R'eady or 'A'ctive. + corrections) if the proposal is 'R'eady or 'A'ctive, and within the + beamtimes. In other cases, the jobs default to the exfel partition. :param mdc: an authenticated MyMDC client @@ -573,6 +574,19 @@ async def get_slurm_partition( if status_beamtime in ['R', 'A']: partition = 'upex-high' if action == 'dark' else 'upex-middle' + # A proposal can have several beamtimes during which data can be taken + # that are independent from the start and end dates. + beamtimes = response.json().get('beamtimes', []) + active_now = False + now = datetime.now().timestamp() + for beamtime in beamtimes: + begin = datetime.fromisoformat(beamtime['begin_at']).timestamp() + end = datetime.fromisoformat(beamtime['end_at']).timestamp() + if begin <= now <= end: + active_now = True + break + partition = partition if active_now else 'exfel' + # NOTE: non-zero at cycle index 4 (`str(cycle)[4]`) indicates commissioning if run_id and cycle and str(cycle)[4] != '0': response_run = await shield( -- GitLab