Skip to content

Generalize ARCH_CYC to support multiple cycle hours#6

Merged
RussTreadon-NOAA merged 2 commits intofeature/arch_cycfrom
copilot/generalize-arch-cyc-usage
Feb 23, 2026
Merged

Generalize ARCH_CYC to support multiple cycle hours#6
RussTreadon-NOAA merged 2 commits intofeature/arch_cycfrom
copilot/generalize-arch-cyc-usage

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 23, 2026

Description

ARCH_CYC in archive_tar_vars.py only accepted a single integer, preventing archiving at multiple cycle hours without workarounds. This change generalizes parsing so ARCH_CYC can be specified as an int, a whitespace-separated str, or a list/tuple, and updates downstream boolean logic accordingly.

Changes in ush/python/pygfs/utils/archive_tar_vars.py

  • Replace scalar arch_cyc with arch_cyc_list built from a type-dispatch parser:
    arch_cyc_raw = config_dict.get('ARCH_CYC', 0)
    if isinstance(arch_cyc_raw, int):
        arch_cyc_list = [arch_cyc_raw]
    elif isinstance(arch_cyc_raw, str):
        arch_cyc_list = [int(val) for val in arch_cyc_raw.strip().split()]
    elif isinstance(arch_cyc_raw, (list, tuple)):
        arch_cyc_list = [int(val) for val in arch_cyc_raw]
    else:
        arch_cyc_list = [0]
  • archive_increments: arch_cyc == cycle_hourcycle_hour in arch_cyc_list
  • archive_ics: (arch_cyc - assim_freq) % 24 == cycle_hourany((val - assim_freq) % 24 == cycle_hour for val in arch_cyc_list)
  • Extract cycle_hour as a local variable to avoid repeated strftime calls

Fully backward-compatible: a single integer ARCH_CYC=12 behaves identically to before.

Type of change

  • Bug fix (fixes something broken)
  • New feature (adds functionality)
  • Maintenance (code refactor, clean-up, new CI test, etc.)

Change characteristics

  • Is this change expected to change outputs (e.g. value changes to existing outputs, new files stored in COM, files removed from COM, filename changes, additions/subtractions to archives)? NO
    • GFS
    • GEFS
    • SFS
    • GCAFS
  • Is this a breaking change (a change in existing functionality)? NO
  • Does this change require a documentation update? NO
  • Does this change require an update to any of the following submodules? NO
    • EMC verif-global
    • GDAS
    • GFS-utils
    • GSI
    • GSI-monitor
    • GSI-utils
    • UFS-utils
    • UFS-weather-model
    • wxflow

How has this been tested?

  • Syntax validated via python -m py_compile
  • Logic manually reviewed for backward compatibility with single-integer ARCH_CYC

Checklist

  • Any dependent changes have been merged and published
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have documented my code, including function, input, and output descriptions
  • My changes generate no new warnings
  • New and existing tests pass with my changes
  • This change is covered by an existing CI test or a new one has been added
  • Any new scripts have been added to the .github/CODEOWNERS file with owners
  • I have made corresponding changes to the system documentation if necessary
Original prompt

Generalize ARCH_CYC usage to support both single integer and multiple cycle hours in ush/python/pygfs/utils/archive_tar_vars.py (lines 418-439).

Replace:
arch_cyc = config_dict.get('ARCH_CYC', 0)

With:
arch_cyc_raw = config_dict.get('ARCH_CYC', 0)
if isinstance(arch_cyc_raw, int):
arch_cyc_list = [arch_cyc_raw]
elif isinstance(arch_cyc_raw, str):
arch_cyc_list = [int(val) for val in arch_cyc_raw.strip().split()]
elif isinstance(arch_cyc_raw, (list, tuple)):
arch_cyc_list = [int(val) for val in arch_cyc_raw]
else:
arch_cyc_list = [0]

Update all downstream usage (lines 418-439): Replace comparisons like 'if cycle_hour == arch_cyc:' with 'if cycle_hour in arch_cyc_list:'

These changes enable ARCH_CYC to be specified as a single integer (e.g., 12), a whitespace-separated string (e.g., "0 6 12 18"), or a list/tuple ([0, 6, 12, 18]) in config_dict, maintaining backward compatibility and correct archiving logic.

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…_vars.py

Co-authored-by: RussTreadon-NOAA <26926959+RussTreadon-NOAA@users.noreply.github.com>
Copilot AI changed the title [WIP] Generalize ARCH_CYC to support single and multiple cycle hours Generalize ARCH_CYC to support multiple cycle hours Feb 23, 2026
Copy link
Copy Markdown
Owner

@RussTreadon-NOAA RussTreadon-NOAA left a comment

Choose a reason for hiding this comment

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

Changes look good. Tested on WCOSS2. Changes work as intended.

@RussTreadon-NOAA RussTreadon-NOAA marked this pull request as ready for review February 23, 2026 21:17
@RussTreadon-NOAA RussTreadon-NOAA changed the base branch from develop to feature/arch_cyc February 23, 2026 21:19
@RussTreadon-NOAA RussTreadon-NOAA merged commit 25a2f06 into feature/arch_cyc Feb 23, 2026
6 checks passed
@RussTreadon-NOAA RussTreadon-NOAA deleted the copilot/generalize-arch-cyc-usage branch February 23, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants