From 7842cc472e3484dd4c786d381c398b3e0dd67584 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 17 Jul 2025 00:14:16 +0000 Subject: [PATCH] Fix problem with completed observations blocking scheduling new ones --- adaptive_scheduler/observations.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/adaptive_scheduler/observations.py b/adaptive_scheduler/observations.py index 36ab484..291913d 100644 --- a/adaptive_scheduler/observations.py +++ b/adaptive_scheduler/observations.py @@ -339,8 +339,13 @@ def _get_running_observations(self, ends_after, starts_before, site, obs, tel): cutoff_dt = starts_before for observation in schedule: if observation['start'] < starts_before < observation['end']: - if observation['end'] > cutoff_dt and observation['state'] in ['PENDING', 'IN_PROGRESS']: - cutoff_dt = observation['end'] + if observation['end'] > cutoff_dt: + if observation['state'] in ['PENDING', 'IN_PROGRESS']: + cutoff_dt = observation['end'] + elif observation['state'] == 'COMPLETED': + # If the observation is already completed, set its end time so we don't block + # scheduling other observations using that end time as a reason + observation['end'] = starts_before running = [b for b in schedule if b['start'] < cutoff_dt]