Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions adaptive_scheduler/observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify, starts_before is always in the future when this is being run, correct?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, starts_before is the estimated scheduling run completion time, always in the future usually ~1-5 min or so (based on how long a run takes). ends_after is when this current scheduling run began, probably 0-1 min in the past.


running = [b for b in schedule if b['start'] < cutoff_dt]

Expand Down