Skip to content

Feat/clean up old rolling forecasting code#2082

Open
BelhsanHmida wants to merge 16 commits intomainfrom
feat/clean-up-old-rolling-forecasting-code
Open

Feat/clean up old rolling forecasting code#2082
BelhsanHmida wants to merge 16 commits intomainfrom
feat/clean-up-old-rolling-forecasting-code

Conversation

@BelhsanHmida
Copy link
Copy Markdown
Contributor

@BelhsanHmida BelhsanHmida commented Apr 2, 2026

Description

  • Remove leftover rolling forecasting job helpers after the fixed-point migration
  • Stop failed forecasting jobs from enqueuing unsupported fallback jobs
  • Remove unused rolling horizon utilities
  • Update tests and developer tooling to use TrainPredictPipeline
  • Refresh generated OpenAPI specs
  • Add a changelog entry

How to test

  • pytest -q flexmeasures/data/tests/test_forecasting_jobs.py flexmeasures/data/tests/test_forecasting_jobs_fresh_db.py flexmeasures/data/tests/test_job_cache.py flexmeasures/api/common/schemas/tests/test_sensor_data_schema.py
  • pytest -q flexmeasures/data/tests/test_forecasting_pipeline.py flexmeasures/api/v3_0/tests/test_forecasting_api.py
  • pre-commit run --all-files

Related Items


Sign-off

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on code under GPL or other license that is incompatible with FlexMeasures

Context:
- Fixed-viewpoint forecasting is the supported execution path
- Rolling job helpers and horizon tables were left behind in shared utilities

Change:
- Remove legacy rolling forecasting service entry points
- Keep worker exception handling but stop re-enqueueing unsupported fallback jobs
- Delete unused rolling horizon utility helpers
Context:
- Some tests still created forecasting jobs through the removed rolling job helper
- These tests only need queue metadata, not rolling-forecast behavior

Change:
- Build forecasting jobs with TrainPredictPipeline in cache/schema tests
- Update assertions to match the supported forecasting queue shape
Context:
- The old forecasting job test modules were centered on removed rolling behavior and fallback chaining
- We still need coverage for queue metadata, failure handling, and successful fixed-viewpoint execution

Change:
- Rewrite forecasting job tests around TrainPredictPipeline jobs
- Verify failed jobs stay failed without spawning fallback jobs
- Keep fresh-db coverage for queued fixed-viewpoint forecasting
Context:
- The developer forecasting helper still queued work through the removed rolling entry point
- Pre-commit also refreshed the generated OpenAPI spec in this branch

Change:
- Switch the manual testing helper to TrainPredictPipeline jobs
- Keep the generated OpenAPI spec in sync
@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community bot commented Apr 2, 2026

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR completes the fixed-point forecasting migration by removing legacy rolling-forecasting infrastructure (including the timetomodel integration) and updating tests/tooling to queue forecasting work via TrainPredictPipeline, while also refreshing the generated OpenAPI specs.

Changes:

  • Remove the old rolling forecasting job creation + helper utilities and the timetomodel dependency.
  • Update forecasting-related tests and developer CLI tooling to use TrainPredictPipeline.
  • Adjust forecasting exception handling to stop enqueueing legacy fallback jobs; refresh OpenAPI specs.

Reviewed changes

Copilot reviewed 16 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
uv.lock Drops timetomodel from the resolved dependency set.
pyproject.toml Removes the direct timetomodel dependency.
flexmeasures/utils/time_utils.py Removes unused rolling-horizon helper functions.
flexmeasures/ui/static/openapi-specs.json Updates generated OpenAPI version metadata.
flexmeasures/data/tests/test_job_cache.py Switches forecasting job cache test to TrainPredictPipeline-queued jobs.
flexmeasures/data/tests/test_forecasting_jobs.py Replaces rolling-forecasting job tests with pipeline-based job queuing/failure assertions.
flexmeasures/data/tests/test_forecasting_jobs_fresh_db.py Updates fresh-DB job execution test to use pipeline jobs.
flexmeasures/data/tests/conftest.py Removes legacy model-spec fixtures tied to the old forecasting stack.
flexmeasures/data/services/forecasting.py Removes legacy forecasting job creation/execution code; keeps exception handler and disables fallback enqueueing.
flexmeasures/data/scripts/data_gen.py Removes legacy forecast population code built on the old forecasting stack.
flexmeasures/data/models/forecasting/utils.py Removes old rolling-forecasting utility functions, keeping only shared helpers still in use.
flexmeasures/data/models/forecasting/model_specs/naive.py Deletes legacy naive model spec implementation.
flexmeasures/data/models/forecasting/model_specs/linear_regression.py Deletes legacy linear regression model spec implementation.
flexmeasures/data/models/forecasting/model_spec_factory.py Deletes the timetomodel-based model spec factory.
flexmeasures/data/models/forecasting/__init__.py Removes legacy model-map lookup API tied to deleted model specs/factory.
flexmeasures/cli/testing.py Updates developer manual forecasting job test to enqueue pipeline jobs.
flexmeasures/api/common/schemas/tests/test_sensor_data_schema.py Updates jobs-metadata test setup to enqueue forecasting jobs via the pipeline.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Context:
- Copilot review pointed out that raw exception instances in rq job meta are not JSON-serializable.
- rq-dashboard and job meta consumers rely on this metadata being safe to serialize.

Change:
- Store forecasting exception metadata as a JSON-safe dict with type and message.
- Keep start and end timestamps normalized before saving job meta.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@BelhsanHmida BelhsanHmida requested a review from Flix6x April 13, 2026 08:28
Signed-off-by: Mohamed Belhsan Hmida <149331360+BelhsanHmida@users.noreply.github.com>
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.

Clean up old rolling forecasting code after fixed-point migration

2 participants