Repository navigation
Decompose set_increment_times() into one method per phase #472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
adrianseco
wants to merge
5
commits into
NASA-PDS:main
Choose a base branch
from
adrianseco:464-decompose-set-increment-times
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c5deb95
Move the increment time normalisation into its own method
adrianseco 55b5d2f
Move the previous bundle correction into its own method
adrianseco 80e6acd
Move the initial increment times into their own method
adrianseco a2d09c3
Add direct tests for the increment time phases
adrianseco a125b1b
Document the increment time phases and check their full log text
adrianseco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -221,6 +221,25 @@ def set_increment_times(self) -> None: | |
| execution. The determined times are stored in ``increment_start`` and | ||
| ``increment_finish``. | ||
| """ | ||
| (increment_start, increment_finish) = self._initial_increment_times() | ||
|
|
||
| (increment_start, increment_finish) = self._correct_from_previous_bundle( | ||
| increment_start, increment_finish) | ||
|
|
||
| (increment_start, increment_finish) = self._normalise_increment_times( | ||
| increment_start, increment_finish) | ||
|
|
||
| self.increment_finish = increment_finish | ||
| self.increment_start = increment_start | ||
|
|
||
| def _initial_increment_times(self) -> tuple[str, str]: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method, and the other two added in this PR, do not have :return: lines (or :param:, where applicable). Please add the input and output documentation to the docstrings. |
||
| """Pick the first increment start and finish times. | ||
|
|
||
| They come from the meta-kernels that set the coverage, then from the | ||
| configuration, and finally from the mission start and finish times. | ||
| If the meta-kernels fail halfway, a start already taken from them is | ||
| kept while the finish falls back. | ||
| """ | ||
| increment_start = "" | ||
| increment_finish = "" | ||
| # | ||
|
|
@@ -295,6 +314,17 @@ def set_increment_times(self) -> None: | |
| 'Mission stop time will be used:') | ||
| logging.warning(' %s', increment_finish) | ||
|
|
||
| return increment_start, increment_finish | ||
|
|
||
| def _correct_from_previous_bundle( | ||
| self, increment_start: str, increment_finish: str | ||
| ) -> tuple[str, str]: | ||
| """Widen the increment times with the previous bundle's interval. | ||
|
|
||
| When the previous label is missing, unreadable or lacks a start or | ||
| stop tag, a warning is logged and the times are returned as they | ||
| are at that point, so a start corrected before the failure is kept. | ||
| """ | ||
| # | ||
| # We check the coverage with the previous increment. | ||
| # | ||
|
|
@@ -353,6 +383,16 @@ def set_increment_times(self) -> None: | |
| except (IndexError, TypeError, *FILE_READ_ERRORS): | ||
| logging.warning("-- Previous bundle not found.") | ||
|
|
||
| return increment_start, increment_finish | ||
|
|
||
| def _normalise_increment_times( | ||
| self, increment_start: str, increment_finish: str | ||
| ) -> tuple[str, str]: | ||
| """Convert the increment times to the configured date format. | ||
|
|
||
| Without a loaded LSK the times are returned as they came in. The | ||
| resulting interval is logged either way. | ||
| """ | ||
| # | ||
| # Check the format of the previous bundle and correct it. The 'Z' is | ||
| # removed from the UTC string since it is not supported until the | ||
|
|
@@ -376,8 +416,7 @@ def set_increment_times(self) -> None: | |
| logging.info(' %s - %s', increment_start, increment_finish) | ||
| logging.info('') | ||
|
|
||
| self.increment_finish = increment_finish | ||
| self.increment_start = increment_start | ||
| return increment_start, increment_finish | ||
|
|
||
| def validate(self) -> None: | ||
| """Validate the SPICE Kernels collection. | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that this method only calls the three phases, the docstring could describe them instead of "the coverage of a given SPK or CK kernel". For example: the initial times come from the meta-kernels, then the configuration, then the mission times; they are widened with the previous bundle's interval; and they are converted to the configured date format.