Skip to content

fix: close load_data_source validation gaps (#533) - #544

Open
Shashankss1205 wants to merge 1 commit into
mainfrom
fix/533-load-validation
Open

fix: close load_data_source validation gaps (#533)#544
Shashankss1205 wants to merge 1 commit into
mainfrom
fix/533-load-validation

Conversation

@Shashankss1205

Copy link
Copy Markdown
Collaborator

Fixes #533.

Three related load_data_source validation gaps, all verified in the sweeps:

NB-07 — non-numeric target passed validation silently

An object-dtype target (value: ["1","2","3"]) returned valid: true and failed much later inside fit. validate() now warns when the target column is non-numeric, naming the column and dtype. The check is forwarded to file sources too — file_adapter.validate now passes the target/exog config into the reused PandasAdapter validation (previously it constructed one with {"data": data} only, so the target was unknown).

NB-06 — 1–2 row series could not load

pd.infer_freq requires ≥3 points and raises "Need at least 3 dates to infer frequency"; three call sites hit it unguarded. Added a _safe_infer_freq helper that returns None for short series, so a tiny (but valid) series loads with no frequency instead of crashing.

NB-11 — file loader leaked pandas parse_dates internals

A bad time_column produced "Missing column provided to 'parse_dates': 'index'". Now the time column's existence is checked up front with a clean "Time column 'x' not found in data. Available columns: [...]" message, and parse_dates=[col] is no longer wired into read_csv — the column is parsed to datetime in load() after the existence check (matching the pandas-source path).

Testing

  • New tests/test_load_validation.py (6 tests): object-dtype target warns / numeric doesn't; 1- and 2-row series load; bad file time_column gives a clean not-found without parse_dates in the message and lists available columns; bad target_column lists available.
  • Full suite: 260 passed.

🤖 Generated with Claude Code

Three related load defects:

- NB-07: a non-numeric (object-dtype) target passed validation with
  valid=true and failed much later inside fit. validate() now warns when the
  target column is non-numeric, naming the column and dtype. The check is
  forwarded to file sources too (file_adapter passes target/exog config into
  the reused PandasAdapter validation).
- NB-06: a 1-2 row series could not load at all — pd.infer_freq raises
  "Need at least 3 dates to infer frequency". Guarded all three infer_freq
  call sites behind a _safe_infer_freq helper that returns None for short
  series, so tiny series load with no frequency instead of crashing.
- NB-11: a bad file time_column leaked a raw pandas
  "Missing column provided to 'parse_dates'" error. Check the time column
  exists up front (clean "not found, available: [...]" message) and stop
  wiring parse_dates=[col] into read_csv; the column is parsed to datetime in
  load() after the existence check.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

[BUG] load_data_source validation gaps: non-numeric target passes, 1–2 row load blocked, file loader leaks internals

1 participant