Skip to content
Snippets Groups Projects
Commit db4399fc authored by Cyril Danilevski's avatar Cyril Danilevski :scooter: Committed by Karim Ahmed
Browse files

Select partition based on beamtime dates

parent 098b3924
No related branches found
No related tags found
1 merge request!725[webservice] Select partition based on beamtime dates
...@@ -518,7 +518,8 @@ async def get_slurm_partition( ...@@ -518,7 +518,8 @@ async def get_slurm_partition(
partition. partition.
The partition is either upex-high (for darks) or upex-middle (for 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. In other cases, the jobs default to the exfel partition.
:param mdc: an authenticated MyMDC client :param mdc: an authenticated MyMDC client
...@@ -573,6 +574,19 @@ async def get_slurm_partition( ...@@ -573,6 +574,19 @@ async def get_slurm_partition(
if status_beamtime in ['R', 'A']: if status_beamtime in ['R', 'A']:
partition = 'upex-high' if action == 'dark' else 'upex-middle' 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 # NOTE: non-zero at cycle index 4 (`str(cycle)[4]`) indicates commissioning
if run_id and cycle and str(cycle)[4] != '0': if run_id and cycle and str(cycle)[4] != '0':
response_run = await shield( response_run = await shield(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment