diff --git a/webservice/webservice.py b/webservice/webservice.py index 9fa4119f43adba5b964d0dc91ecd63d73c0fcf7f..7b4cbe6e3f76cb1163a1cee902f17b64a5fcfb1b 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(