Skip to content

Fail clearly on insufficient forecasting history by translating Darts fit errors#2192

Open
Copilot wants to merge 6 commits into
mainfrom
copilot/2191-fix-valueerror-regression-test
Open

Fail clearly on insufficient forecasting history by translating Darts fit errors#2192
Copilot wants to merge 6 commits into
mainfrom
copilot/2191-fix-valueerror-regression-test

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 20, 2026

Forecasting could fail with a low-level Darts ValueError when requested horizon exceeded usable training history.

  • Error translation at model-fit boundary

    • Wrap the specific Darts fit-time ValueError (no common times for which features can be created) as NotEnoughDataException.
    • Surface a domain-level message that clearly points to insufficient history vs requested horizon.
  • Regression coverage (integration-style)

    • Added an integration-style regression test through TrainPredictPipeline.compute(...) that reproduces the Darts fit failure path and asserts it is converted to NotEnoughDataException.
# train.py (fit boundary)
try:
    model.fit(...)
except ValueError as e:
    if "do not share any common times for which features can be created" in str(e):
        raise NotEnoughDataException(
            "Not enough training data for the requested forecast horizon. "
            "Upload more historical data or choose a shorter forecast duration."
        ) from e
    raise

Copilot AI and others added 3 commits May 20, 2026 20:15
Co-authored-by: BelhsanHmida <149331360+BelhsanHmida@users.noreply.github.com>
Co-authored-by: BelhsanHmida <149331360+BelhsanHmida@users.noreply.github.com>
Co-authored-by: BelhsanHmida <149331360+BelhsanHmida@users.noreply.github.com>
@BelhsanHmida
Copy link
Copy Markdown
Contributor

@copilot I don’t think the max-forecast-horizon / predict_period defaulting change belongs in this PR.

Issue #2191 is about translating the Darts “no common feature times” failure into a clear NotEnoughDataException when there is not enough training history. It does not require changing how max-forecast-horizon resolves the prediction window.

Please remove the schema/test changes around preserving the default 48h duration when only max-forecast-horizon is supplied, unless we intentionally want to make that as a separate API/CLI behavior change with its own issue, migration note, and tests.

For this PR, I think the scope should stay focused on:

  • catching or pre-detecting the insufficient-history Darts failure
  • raising NotEnoughDataException
  • adding an integration-style regression test through TrainPredictPipeline.compute(...)

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 21, 2026

@copilot I don’t think the max-forecast-horizon / predict_period defaulting change belongs in this PR.

Issue #2191 is about translating the Darts “no common feature times” failure into a...

Addressed in 9183269.

I removed the schema/defaulting behavior change and reverted the related schema test expectations, so this PR no longer changes max-forecast-horizon/predict-period semantics. I also replaced the unit-level wrapping test with an integration-style regression test that goes through TrainPredictPipeline.compute(...) and verifies the Darts ValueError is converted to NotEnoughDataException.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • publicsuffix.org
    • Triggering command: /home/REDACTED/work/flexmeasures/flexmeasures/.venv/bin/pytest pytest exec --process /tmp/runc-process775792770 --detach --pid-file /run/containerd/io.containerd.runtime.v2.task/moby/7e7b651f7c7b1f05c1ef82382934c0adfd6fef18d5796d04855f29c5fd9aaecd/ec319217d5b6a5c16c8e6f1ac2ff80c9ca511327d6a8bf20313263f8c5a10228.pid 7e7b651f7c7b1f05c1ef82382934c0adfd6fef18d5796d04855f29c5fd9aaecd (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Fail clearly on insufficient forecasting history without auto-shortening requested duration Fail clearly on insufficient forecasting history by translating Darts fit errors May 21, 2026
Copilot AI requested a review from BelhsanHmida May 21, 2026 17:11
@BelhsanHmida
Copy link
Copy Markdown
Contributor

@copilot 1. The new test goes through TrainPredictPipeline.compute(...), which is good, but it still monkeypatches CustomLGBM.fit to raise the error. So it proves the wrapping path, but not the real #2191 short-history / long-horizon failure. Can we make this reproduce the actual Darts failure without monkeypatching fit?

@BelhsanHmida BelhsanHmida marked this pull request as ready for review May 21, 2026 17:33
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 21, 2026

@copilot 1. The new test goes through TrainPredictPipeline.compute(...), which is good, but it still monkeypatches CustomLGBM.fit to raise the error. So it proves the wrapping path, but not the re...

Implemented in 18f55c8.

The regression test no longer monkeypatches CustomLGBM.fit. It now creates a real 15-minute sensor with only 3 days of history and requests a 4-day (PT96H) horizon through TrainPredictPipeline.compute(...), which reproduces the real short-history/long-horizon Darts failure path and asserts it is surfaced as NotEnoughDataException.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Copy link
Copy Markdown
Contributor

@BelhsanHmida BelhsanHmida left a comment

Choose a reason for hiding this comment

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

approved!

@nhoening
Copy link
Copy Markdown
Contributor

Now what? There should be a second human in the loop right?

@BelhsanHmida
Copy link
Copy Markdown
Contributor

Now what? There should be a second human in the loop right?

Yes i was thinking to ask second review from yourself or felix.

@BelhsanHmida BelhsanHmida requested a review from nhoening May 21, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants