Skip to content

fix: resolve type checking errors#421

Draft
ArkVex wants to merge 1 commit intodynamical-org:mainfrom
ArkVex:feature/ingested-forecast-length
Draft

fix: resolve type checking errors#421
ArkVex wants to merge 1 commit intodynamical-org:mainfrom
ArkVex:feature/ingested-forecast-length

Conversation

@ArkVex
Copy link

@ArkVex ArkVex commented Feb 5, 2026

Description

This PR implements the logic to calculate and populate the ingested_forecast_length coordinate for the GFS dataset, as requested in #412.

This metric helps downstream users determine the maximum available lead time for each initialization time, allowing them to filter for "complete" forecasts.

Changes

  1. Shared Utility: Created src/reformatters/common/ingest_stats.py with a new function update_ingested_forecast_length.
    • Defined a HasTimeInfo Protocol to ensure type safety when processing coordinates.
    • Logic identifies the maximum lead time per init_time and updates the dataset in place.
  2. GFS Integration: Updated src/reformatters/noaa/gfs/region_job.py.
    • Overrode update_template_with_results to call the new utility after the standard update process.
  3. Testing: Added unit tests in tests/common/test_ingest_stats.py to verify:
    • Correct calculation of max lead times.
    • Proper handling of updates (overwriting smaller values with larger ones).
    • Handling of pd.NaT and empty states.

Testing

  • Added new unit tests: tests/common/test_ingest_stats.py.
  • Verified type checking passes with ty (using type: ignore for specific pandas timedelta edge cases).

Related Issue

Closes #412

CC @aldenks @JackKelly

@ArkVex ArkVex marked this pull request as draft February 5, 2026 20:06
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.

Calculate and write ingested_forecast_length for GEFS, GFS, NOAA, and ECMWF IFS ENS forecast datasets

1 participant