Refactor archive methods for robustness and consistency#5
Merged
RussTreadon-NOAA merged 2 commits intofeature/arch_cycfrom Feb 18, 2026
Merged
Refactor archive methods for robustness and consistency#5RussTreadon-NOAA merged 2 commits intofeature/arch_cycfrom
RussTreadon-NOAA merged 2 commits intofeature/arch_cycfrom
Conversation
- Added Union and Tuple to typing imports - Added _normalize_arch_cyc helper method for DRY ARCH_CYC normalization - Refactored _arch_warm_start_increments with better validation and docstrings - Refactored _arch_warm_restart_ics with improved error handling and case-insensitive RUN matching - Replaced magic number 24 with HOURS_PER_DAY constant - Enhanced docstrings with complete parameter and return documentation - Improved variable names for clarity (cycle_hours, adjusted_cycle_hours) - Added comprehensive error handling with descriptive messages - Used .startswith() for more robust GDAS detection - All changes validated with tests Co-authored-by: RussTreadon-NOAA <26926959+RussTreadon-NOAA@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor methods for arch warm start and restart
Refactor archive methods for robustness and consistency
Feb 18, 2026
RussTreadon-NOAA
approved these changes
Feb 18, 2026
Owner
RussTreadon-NOAA
left a comment
There was a problem hiding this comment.
Looks good to me.
Approve.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Refactors
_arch_warm_start_incrementsand_arch_warm_restart_icsinush/python/pygfs/task/archive.pyto eliminate code duplication, add input validation, and fix fragile string matching that could cause incorrect archiving behavior.Changes
New helper method
_normalize_arch_cyc:Improved
_arch_warm_start_increments:ARCH_FCSTICFREQwith explicit error handlingImproved
_arch_warm_restart_ics:HOURS_PER_DAYconstantRUN.lower()) prevents case-sensitivity bugs.startswith("gdas")instead of"gdas" in RUNto avoid false substring matches (e.g., "mygdas_test")ARCH_WARMICFREQwith explicit error handlingExample of improved string matching:
All changes maintain backward compatibility with existing configurations.
Type of change
Change characteristics
How has this been tested?
Unit tests created covering:
Code passes pycodestyle validation.
Checklist
Original prompt
Problem Statement
Refactor the
_arch_warm_start_incrementsand_arch_warm_restart_icsmethods inush/python/pygfs/task/archive.pyto improve code quality, consistency, and robustness.Current Issues
ARCH_CYChandling:_arch_warm_start_incrementsonly handles integers, while both methods should support integers or lists of integers_arch_warm_restart_ics, using"gdas" in RUNis case-sensitive and could match unintended substringsarch_cyc_valandarch_cyccould be clearerARCH_CYCRequired Changes
1. Add Helper Method
_normalize_arch_cycAdd a new private method after line 751 (before
_arch_warm_start_increments) to handle normalization ofARCH_CYCto a list of integers:Note: Add the required import at the top of the file:
UnionandTupleto the imports fromtypingon line 82. Refactor
_arch_warm_start_increments(lines 752-778)Replace the existing method with:
3. Refactor
_arch_warm_restart_ics(lines 780-811)Replace the existing method with: