diff --git a/webservice/webservice.py b/webservice/webservice.py index d8a5e532648dfedaefeb43728c553951844a0425..394db06c3a722279fd30a5f153f0bfc15ca39764 100644 --- a/webservice/webservice.py +++ b/webservice/webservice.py @@ -568,24 +568,24 @@ async def get_slurm_partition( logging.error(Errors.MDC_RESPONSE.format(response)) partition = 'exfel' + active_now = False status_beamtime = response.json().get('flg_beamtime_status', 'whoopsie') 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' + # 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', []) + 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':