Skip to content
Open
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
11 changes: 10 additions & 1 deletion tom_observations/cadences/resume_cadence_after_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def run(self):
# Boilerplate to get necessary properties for future calls
start_keyword, end_keyword = facility.get_start_end_keywords()
observation_payload = last_obs.parameters
observation_payload['last_obs_end'] = last_obs.scheduled_end
observation_payload['last_obs_start'] = last_obs.scheduled_start

# Cadence logic
# If the observation hasn't finished, do nothing
Expand Down Expand Up @@ -105,7 +107,14 @@ def advance_window(self, observation_payload, start_keyword='start', end_keyword
advance_window_hours = cadence_frequency
window_length = parse(observation_payload[end_keyword]) - parse(observation_payload[start_keyword])

new_start = parse(observation_payload[start_keyword]) + timedelta(hours=advance_window_hours)
# If the last observation has an end or start time recorded use that for the beginning of the new cadence
# Otherwise use the start time of the current cadence.
if observation_payload['last_obs_end']:
new_start = observation_payload['last_obs_end'] + timedelta(hours=advance_window_hours)
elif observation_payload['last_obs_start']:
new_start = observation_payload['last_obs_start'] + timedelta(hours=advance_window_hours)
else:
new_start = parse(observation_payload[start_keyword]) + timedelta(hours=advance_window_hours)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I worry about the window length being limited to the length of the observation because if it is a short exposure that isn't constantly visible, it will clutter up the runcadencestrategies log with visibility errors as it keeps attempting to schedule it. This also might be tricky with many observations because it's more observations being scheduled for the same window instead of giving the scheduler room to avoid failures. Maybe a combination of this more robust check for scheduled start/end method and a user defined from the settings file for the minimum window

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is definitely the right direction though, and cluttering runcadencestrategies log is not the worst thing in the world. Maybe a future improvement would be to combine with the method in #1492 to allow the observing window to be increased or defined elsewhere

if new_start < datetime.now(): # Ensure that the new window isn't in the past
new_start = datetime.now()
new_end = new_start + window_length
Expand Down
Loading