Skip to content

feat: Add Chap-compatible CSV export with global temporal continuity [CLIM-360]#6

Merged
karimbahgat merged 7 commits intomainfrom
CLIM-360
Jan 28, 2026
Merged

feat: Add Chap-compatible CSV export with global temporal continuity [CLIM-360]#6
karimbahgat merged 7 commits intomainfrom
CLIM-360

Conversation

@abyot
Copy link
Member

@abyot abyot commented Jan 21, 2026

This PR adds a Chap-compatible CSV export utility for producing training datasets that can be consumed directly by Chap.

What’s included

  • A CSV exporter that maps harmonized DataFrames to the Chap schema:

    • required and also reserved fields: time_period, location, disease_cases
    • optional reserved field: population
    • all other columns are treated as covariates
  • Enforcement of global temporal continuity across all locations:

    • all locations must cover the same start/end time window
    • the window is inferred from the data or can be provided explicitly
    • missing periods are never imputed
  • A diagnostic helper (find_temporal_gaps) that returns the complete list of missing periods per location to support upstream data repair or imputation

  • Time-period normalization and validation for monthly and weekly data

  • Configurable continuity handling at export time (error, warn, ignore)

Design notes

The exporter is intentionally strict and opinionated: its goal is to produce CSVs that are immediately usable by Chap without relying on implicit padding, masking, or downstream fixes.

Data completeness and imputation decisions are expected to happen upstream and are supported via explicit diagnostics rather than silent behavior.

Tests

Unit tests cover schema enforcement, time-period normalization, global continuity semantics, continuity policies, and successful CSV/file output.

@abyot abyot requested review from karimbahgat and turban January 21, 2026 09:30
Copy link
Collaborator

@karimbahgat karimbahgat left a comment

Choose a reason for hiding this comment

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

Looks great and seems very robust, with plenty of tests. Added some commits to simplify type hints and minor tweaks for code clarity. Ready for merge.

@karimbahgat karimbahgat merged commit 956b13a into main Jan 28, 2026
4 checks passed
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