Repository navigation
Report how many beliefs a job computed as well as how many it saved - #2822
Conversation
A saved count of 0 alone cannot tell a run that computed nothing from one that only repeated what is on record. save_generator_results now returns n_computed next to n_rows for each output, which reaches the result of reporting jobs and of plugin automation jobs, and make_schedule adds num-computed-beliefs next to num-beliefs, also on a dry run. The reporting job's log states both counts per output. Refs #2821 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
flexmeasures add report names the computed count where it saved fewer beliefs than it computed, or none, and flexmeasures add schedule says how many beliefs it saved, or that a rerun repeats what is on record, where it used to say "New schedule is stored." either way. A dry run of add schedule says how many beliefs it computed. Refs #2821 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
…t saved Extends the v1.1.0 entry for #2689 and #2571, as the meaning of these counts changes within that unreleased version, and adds lines to the API and CLI changelogs. Refs #2821 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
Documentation build overview
10 files changed ·
|
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
A repository convention issue remains in flexmeasures/data/services/scheduling_result.py where multi-line docstring bullet continuation lines lack ending punctuation, reducing consistency and reviewability.
1 open issue
What changed in this PR
This pull request improves observability for reporting, scheduling, and automation jobs by returning and displaying both how many beliefs were computed and how many were actually saved, so reruns that save nothing can be distinguished from runs that computed nothing. It propagates the new counts through job results, CLI output, API docs/OpenAPI spec, and test coverage (including NaN computed-but-not-saved behavior).
Changes:
- Extend generator result persistence to return
n_computedalongside existing saved counts (n_rows), and propagate this through reporting jobs and plugin automation jobs. - Add
num-computed-beliefsto scheduling job results (including dry runs) next tonum-beliefs, and update CLI messages to report computed vs saved where meaningful. - Update Jobs API documentation/OpenAPI spec plus changelogs, and expand tests to cover fresh runs, reruns, and NaN/misaligned-input scenarios.
Review notes (nits):
- Changelog wording should reflect that the prior behavior reported saved counts (not “computed”) to avoid confusion.
- One reporting log message may over-claim “every computed value was already on record” now that “computed” includes NaNs; consider narrowing that statement.
- Docstring bullet formatting in
scheduling_result.pyshould match repo conventions (line endings/punctuation).
| File | Summary |
|---|---|
flexmeasures/ui/static/openapi-specs.json |
Regenerated OpenAPI spec to include the new computed/saved fields and updated examples. |
flexmeasures/data/tests/test_plugin_automations_fresh_db.py |
Updates/extends automation job tests to assert computed vs saved counts. |
flexmeasures/data/tests/test_generator_results_fresh_db.py |
Adds coverage for computed-vs-saved semantics, including NaN counted as computed but not saved. |
flexmeasures/data/services/scheduling.py |
Aggregates computed belief counts for scheduling runs (including dry runs) and exposes them in results. |
flexmeasures/data/services/scheduling_result.py |
Extends scheduling result structure/serialization to include num-computed-beliefs. |
flexmeasures/data/services/reporting.py |
Propagates computed vs saved counts into reporting job results and logging. |
flexmeasures/data/services/generator_results.py |
save_generator_results now returns n_computed alongside n_rows per output while preserving saved-count semantics. |
flexmeasures/cli/tests/test_data_add_fresh_db.py |
Updates CLI add-flow tests for schedule/report messaging with computed vs saved and dry-run behavior. |
flexmeasures/cli/tests/test_automations.py |
Updates automation CLI tests to expect computed vs saved counts in outputs/results. |
flexmeasures/cli/data_add.py |
Improves add report / add schedule messages to report computed vs saved and avoid misleading “stored” messages on reruns. |
flexmeasures/api/v3_0/tests/test_report_trigger_api_fresh_db.py |
Adds/updates API test assertions for computed NaNs vs 0 saved rows on misaligned inputs. |
flexmeasures/api/v3_0/tests/test_jobs_api.py |
Validates num-computed-beliefs appears on finished scheduling job results. |
flexmeasures/api/v3_0/jobs.py |
Documents the expanded job result payloads (scheduling and reporting) in the Jobs endpoint docs. |
documentation/cli/change_log.rst |
Notes CLI output changes for showing computed vs saved counts. |
documentation/changelog.rst |
Updates unreleased v1.1.0 changelog entry to reflect the computed+saved reporting semantics. |
documentation/api/change_log.rst |
Adds API changelog entry documenting the new jobs-result fields (v3.0-34). |
Review effort: Balanced
…or its log The GET /api/v3_0/jobs/<uuid> docstring now breaks lines only after punctuation, and so do the SchedulingJobResult bullets. A report that saved nothing new no longer logs that every value it computed was already on record, as the computed values can include NaN values, which are not on record. Refs #2821 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
It used to print "New schedule is stored: saved 0 beliefs." in that case. Refs #2821 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟢 Approval recommended
The change is supported by updated implementations, regenerated API/spec and documentation, and expanded tests covering reruns, dry runs, and NaN edge cases, with only minor formatting/diagnostic nits noted and no unresolved issues indicated.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
… it was in v1.0 The deprecated num-beliefs counts the beliefs passed to the save again, as it did in v1.0, so that v1.1.0 does not change what it means: it equals num-computed-beliefs, except on a dry run, where nothing is passed to the save and it is 0. num-saved-beliefs now holds the count that num-beliefs briefly held since #2689: the beliefs actually saved. The changelogs no longer say that num-beliefs changed meaning, and the API changelog deprecates it. Refs #2821 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
A critical unresolved issue remains because the change repurposes the num-beliefs metric to count computed items rather than saved beliefs, contradicting the stated intent to preserve v1.1.0 semantics and risking downstream/client breakage unless the metric meaning or accompanying documentation is corrected.
1 open issue
Review effort: Balanced
…ling job results
A reporting job's result is now {"outputs": [...]},
with, per output sensor, the sensor ID and its num-computed-beliefs and num-saved-beliefs.
A plugin automation job's result, which comes from the same save, takes the same shape.
A scheduling job's result gains the same outputs list, counted per sensor in make_schedule,
with saved 0 on a dry run,
and drops the top-level num-computed-beliefs and num-saved-beliefs, which were never released.
Its num-beliefs is no longer called deprecated, and keeps its v1.0 meaning: the beliefs passed to the save.
save_generator_results keeps its internal snake_case return, which outputs_of_job_result turns into this shape.
Refs #2821
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf
Signed-off-by: F.N. Claessen <claessen@seita.nl>
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
Outstanding review findings indicate the API response semantics for belief counts are inconsistent with the documented/expected meaning (computed vs saved) and the related documentation omits an important exclusion behavior, so the change needs correction and clarification before approval.
1 open issue
1 resolved since last review
Review effort: Balanced
…messages The outputs of a reporting, scheduling or plugin automation job's result say num-recorded-beliefs, where they said num-saved-beliefs, which was never released. add schedule, add report and the reporting job's log say "recorded" where they report these counts, and so do the changelogs. Internal names, such as save_generator_results and its n_rows, stay as they are. Refs #2821 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
… on a dry run num-beliefs is now always the total of num-computed-beliefs across the outputs. On a real run, that is what v1.0 counted, as it handed every computed belief to the save; only a CLI dry run, which creates no job, used to count 0. Refs #2821 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
add schedule ends with "Scheduling done: computed N, recorded M", followed by ", as this was a dry run" or ", as the rest was already on record" where fewer were recorded than computed. The per-sensor print on a dry run says it is not recording the schedule, rather than not saving it. Refs #2821 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🔵 Needs a closer look
The changes still include unresolved issues, most notably a mismatch with the stated dry-run behavior where num-beliefs is set to the computed total (altering its meaning and obscuring saved totals), along with a remaining docstring formatting nit that violates the repository’s punctuation-per-line convention.
1 open issue
Review effort: Balanced


Description
Since #2689 (with #2571), the result of a reporting or scheduling job counts the beliefs it saved, and no longer says how many it computed. So "0 saved" cannot tell a run that computed nothing from one that only repeated what is on record. This PR returns both, additively: the saved counts keep their v1.1.0 meaning and names.
save_generator_resultsreturnsn_computednext ton_rows(saved) for each output. This reaches the result of reporting jobs (run_report_job), plugin automation jobs (execute_automation_job) andcompute_and_save_report.make_schedule(andSchedulingJobResult) addsnum-computed-beliefsnext tonum-beliefs, kebab-case like its neighbours. It is counted on a dry run too, wherenum-beliefsstays 0.flexmeasures add reportandflexmeasures add schedulesay both counts where they differ.add scheduleno longer says "New schedule is stored." when a rerun saved nothing.GET /api/v3_0/jobs/<uuid>docs (and the regenerated OpenAPI spec) describe the new fields, including the reporting job's result, which was undocumented before.documentation/changelog.rst, since these counts change meaning within the unreleased v1.1.0. Also added lines to the API changelog (v3.0-34) and the CLI changelog.Look & Feel
Scheduling job result (
GET /api/v3_0/jobs/<uuid>), rerun of a schedule already on record:Reporting job result, rerun:
Reporting job log:
CLI:
How to test
Extended tests assert both counts, for a fresh run (computed == saved) and for a rerun that repeats what is on record (computed > 0, saved 0):
flexmeasures/data/tests/test_generator_results_fresh_db.py, which also has a new test: a NaN value counts as computed, but not as saved.flexmeasures/data/tests/test_plugin_automations_fresh_db.py::test_plugin_job_reports_rows_savedflexmeasures/cli/tests/test_automations.py, includingtest_a_rerun_report_job_counts_what_it_saved_and_says_why_it_saved_nothing.flexmeasures/api/v3_0/tests/test_report_trigger_api_fresh_db.py: misaligned inputs give 20 computed NaN rows, 0 saved.flexmeasures/api/v3_0/tests/test_jobs_api.py:num-computed-beliefson a finished scheduling job.flexmeasures/cli/tests/test_data_add_fresh_db.py: theadd reportrerun message, andadd scheduleas a dry run, then a first run, then a rerun.I checked that each test can fail. For each changed source file in turn (
generator_results.py;scheduling.pywithscheduling_result.py;data_add.py), I copied it aside, restored the version on main, ran the tests (16, 16 and 2 failures respectively), and put the copy back.Test runs on a sandboxed Postgres:
flexmeasures/cli(285 passed, 1 xfailed),flexmeasures/data/tests(689 passed), the API job, automation, report and schedule tests (183 passed), andflexmeasures/data/models/planningplusflexmeasures/data/models/reporting(463 passed, 3 xfailed).Further Improvements
add forecastsmessage andsave_forecast's log say how many beliefs were computed and saved. A forecasting job's result is its runtime, not a count, so it is unchanged here.Related Items
Closes #2821. Raised in the review of #2818 (discussion).
Sign-off
🤖 Generated with Claude Code
https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf