-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
End of night shutdown improvements. (#407)
* End of night shutdown A number of fixes and changes to account for situation when on valid observations are found but we don't want to shut down the state machine. * If scheduler has a list of `observations` then it `has_valid_observations`. which is True when starting. Process: * `scheduling` state calls `observatory.get_observation()` * `get_observation` first checks if `has_valid_observations is False` if so it will reread the field list. * `get_observation` either returns an observation or, if none found, calls `clear_available_observations`, making `has_valid_observations = False`. * If no observation is returned to `scheduling` state, send to `parking` (then to `sleeping`). * In `sleeping`, if `has_valid_observations is False` then sleep for an hour then try again (or shut down if `run_once` is specified). If `has_valid_observations is True` and it is safe and dark, shut down because of unknown error. Other changes: * Remove `reread_fields_file` from dispatch scheduler as it is handled at the `observatory` level by `observatory.get_observation`. * Misc small fixes * If no messaging then show `say` commands in log * More shutdown cleanup Note: This changes some of the state behavior for how parking and retrying is handled. Housekeeping state will now only be called at the very end of an observing run (either in the morning when unsafe or when too many retry attempts). This moves some behavior from `sleeping` into `parked`. * Fix the `should_retry` so it does not modify values * Create a `reset_observing_run` method. Currenlty only resets number of retries * Other PR fixes * Better name for private variable * More updates * Adding back the ability to reread fields file from the `get_observation` call so that a user can do it manually rather than relying on an empty observations list. But do it cleaner. * Test the rereading of a fields with same entires only with a new higher priority target * Skip duplicate observation entries rather than stopping with assertion error. * Removing a whole test as it seems to be a duplication of the one below it for no reason and is also not testing what it says it should be testing. * Clear fields_file when clearing observations Explicitly clear observations for test of no targets * Feedback from PR * cleaning up code so parking logic is clearer
- Loading branch information
1 parent
e366ec5
commit e2dd720
Showing
9 changed files
with
90 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
def on_enter(event_data): | ||
""" """ | ||
pocs = event_data.model | ||
pocs.next_state = 'ready' | ||
|
||
# If it is dark and safe we shouldn't be in sleeping state | ||
if pocs.is_dark() and pocs.is_safe(): | ||
if pocs.should_retry is False: | ||
pocs.say("Weather is good and it is dark. Something must have gone wrong. Stopping loop") | ||
pocs.stop_states() | ||
else: | ||
pocs.say("Things look okay for now. I'm going to try again.") | ||
if pocs.should_retry is False: | ||
pocs.say("Weather is good and it is dark. Something must have gone wrong. " + | ||
"Stopping loop.") | ||
pocs.stop_states() | ||
else: | ||
pocs.say("Another successful night!") | ||
# Note: Unit will "sleep" before transition until it is safe | ||
# to observe again. | ||
pocs.next_state = 'ready' | ||
pocs.reset_observing_run() | ||
|
||
pocs.say("Another successful night!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters