Repository navigation
Decompose set_increment_times() into one method per phase - #472
adrianseco wants to merge 5 commits into
Conversation
The date conversion at the end of set_increment_times() was moved into _normalise_increment_times(). It takes the two times and returns them converted, or unchanged with a warning when no leap seconds kernel is loaded. The times and the log output are the same as before.
The step of widening the increment times with the previous bundle's interval was moved into _correct_from_previous_bundle(). It takes the two times and returns them, keeping a corrected start even when the stop time can't be read from the previous label. The times and the log output are the same as before.
The choice of the first increment start and finish times was moved into _initial_increment_times(). It tries the meta-kernels first, then the configuration, and finally the mission times, and set_increment_times() now only calls the three steps in order and stores the result. The times and the log output are the same as before.
The three methods that set_increment_times() now delegates to, and the order in which it calls them, are tested on their own. The cases cover the meta-kernel, configuration and mission times, every outcome of reading the previous bundle label (including a label with only a start time), and the conversion with and without a leap seconds kernel.
| self.increment_finish = increment_finish | ||
| self.increment_start = increment_start | ||
|
|
||
| def _initial_increment_times(self) -> tuple[str, str]: |
There was a problem hiding this comment.
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.
| @@ -221,6 +221,25 @@ def set_increment_times(self) -> None: | |||
| execution. The determined times are stored in ``increment_start`` and | |||
| ``increment_finish``. | |||
There was a problem hiding this comment.
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.
| _Setup(**attrs), make_bundle(), make_kernels()) | ||
|
|
||
|
|
||
| def _assert_logged( |
There was a problem hiding this comment.
_assert_logged() checks the levels in full, but each message only for a fragment it contains. The two log-text defects #464 asks to keep are therefore not pinned. Fixing "corrected form previous bundle" to "from", or "Increment stop time set to" to "start" for the start time, still passes every test. ("INFO", "") also matches any INFO message.
Please compare the full messages (level and text, in order), as the other log tests in this file do with messages == [...]. The cases then need the complete texts, including:
" Increment stop time set to: <time> as provided from configuration file"for the configured start time;"-- Increment finish corrected form previous bundle.".
The three phase methods and set_increment_times() now describe what they take and return, and the main docstring walks through the phases. The tests now compare the whole log, level and text, so a change to any message wording is caught.
|



🗒️ Summary
SpiceKernelsCollection.set_increment_times()was split into one private method per phase, and it now only calls them in order and stores the result:_initial_increment_times()picks the first times (from the meta-kernels, then the configuration, then the mission times),_correct_from_previous_bundle()widens them with the latest previous bundle label, and_normalise_increment_times()converts them to the configured date format. The code was moved as it was, so the times, the log messages, their levels and their order are the same as on main, including the partial update when a previous label has a start tag but no stop tag.The known defects were kept on purpose so that each later fix stays local to one small method: the string comparison of the times before normalisation, the
[:-1]that assumes a trailing 'Z', the lexical sort of the previous labels, the 'corrected form previous bundle' typo, and the 'Increment stop time set to' wording used for the start time.Direct tests were added for each new method and for the order of the calls. The existing
set_increment_times()tests were not modified.⚙️ Test Data and/or Report
Regression tests included:
tests/npb/test_classes_collection_kernels.py_initial_increment_times_correct_from_previous_bundle_normalise_increment_timesset_increment_times♻️ Related Issues
Fixes #464