Skip to content

Feat: reporter output source type - #2804

Merged
Flix6x merged 26 commits into
mainfrom
feat/reporter-output-source-type
Dec 3, 2026
Merged

Flix6x merged 26 commits into
mainfrom
feat/reporter-output-source-type

Conversation

@BelhsanHmida

@BelhsanHmida BelhsanHmida commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

A community's forecast can be made by summing its houses' forecasts with the AggregatorReporter, but the sum was saved under a reporter source. So FlexMeasures treated it as a report: the chart's tooltip said Type: reporter, source-types: ["forecaster"] filters didn't find it, and a forecast of the community sensor was trained on it, because the forecasting pipeline only leaves out forecaster sources.

This PR lets the reporter config say what its report is. For example, with

{"method": "sum", "output-source-type": "forecaster"}

the community's sum is saved under a forecaster source (Type: forecaster in the chart's tooltip), found by forecaster filters, and left out of the community sensor's training data.

Saving a report under another source type

  • Reporter configs accept an optional output-source-type: any registered kind of data generator (forecaster, reporter, scheduler, or one a plugin adds). An unknown value is refused, naming the valid ones.
  • Leaving it out, or setting it to reporter, keeps the reporter's source as it was: the field has no default and reporter is dropped on load, so existing configs hash the same and keep their sources. Setting another type for an existing reporter starts a new source.
  • It's explicit, rather than derived from the inputs or the belief horizons: reporters such as the tariff reports also record values about the future, which are known prices, not forecasts.

Setting the reporter up again from its source

  • A source of type forecaster with model AggregatorReporter now finds its reporter, so automations and report reruns keep working. When a source's model is not among the data generators of its own type, the other kinds are searched too. A model found under more than one other kind is refused as ambiguous.
  • A source is refused as unavailable if its data generator, as configured, saves under another type than the source's, e.g. a forecaster source whose config has no output-source-type.
  • Registering the aggregator as a forecaster as well was the alternative, but that would let forecast commands, the forecast API and forecast automations accept AggregatorReporter as a forecasting model. Those still refuse such a source; report paths accept it.

Partial aggregates

  • The aggregator looks for its partial aggregates among sources of its own type, so a complete aggregate computed later still supersedes a partial one when the report is saved as a forecast.
  • The status page names missing members for any source type, not just reporter. It looks the sensor's sources up once, for the stalenesses and the missing members of every type.

Picking such a source for a report automation

  • GET /api/v3_0/sources gets a generator-type filter: sources whose data generator is of that kind, whatever type they are saved under, e.g. generator-type=reporter lists a forecaster-type AggregatorReporter source and leaves out a TrainPredictPipeline one. Sources of a non-generator type, such as a demo script named after a reporter, are left out, and an unknown kind gets a 422.

  • The automation source picker uses it instead of the source type, so report automations can pick such a source, and forecast automations no longer list it (they would refuse it).

  • Docs: a reporting example summing house forecasts into a community forecast, when not to set output-source-type, and that a forecast whose "auto" entry filters sources doesn't leave out forecasters by default.

Behaviour changes

  • The automation source picker filters by kind of data generator rather than source type, so it no longer lists sources whose model is not an installed data generator (which it could not set up anyway).
  • MemberFilterSchema (the aggregator's members filter) derives from Schema instead of ReporterConfigSchema, so it doesn't accept output-source-type. It had no other fields from that base.

Look and feel

The same hour of a community's summed forecast, before (Type: reporter) and after (Type: forecaster):

Before

before-asset-graph

After

after-asset-graph

New automation → Reporting: before, the picker lists only the reporter-type sum; after, the forecaster-type sum, too:

Before

before-picker-reporting

After

after-picker-reporting

New automation → Forecasting: before, the picker lists the summed forecast, which a forecast automation then refuses; after, only the real forecaster:

Before

before-picker-forecasting

After

after-picker-forecasting

How to test

pytest flexmeasures/data/tests/test_aggregated_forecast_source_type.py flexmeasures/data/tests/test_data_source.py flexmeasures/data/tests/test_sensor_status_queries.py
pytest flexmeasures/data/models/reporting/tests/test_aggregator.py -k "source_type or forecaster"
pytest flexmeasures/api/v3_0/tests/test_sources_api.py flexmeasures/api/v3_0/tests/test_automations_api.py -k "generator_type or forecaster_source"
pytest flexmeasures/data/tests/test_plugin_automations_fresh_db.py -k source_type

Or by hand: create a report automation with the AggregatorReporter, config {"method": "sum", "output-source-type": "forecaster"}, summing two sensors' forecasts ("source_types": ["forecaster"] on each input). After Run now, hovering the output sensor's chart shows Type: forecaster for the sum, and New automation → Reporting lists the source in the picker.

Further improvements

  • For a report saved as a forecast, the status page's missing-members warning is late. It only judges aggregates old enough to count as stale, which suits measurements that arrive late, but a forecast missing a house is known when it is made. For a day-ahead sum, the warning shows about a day after the run that left the house out. It also judges the latest belief of any forecaster source, so another forecaster recording on the same sensor can hide it.
  • An older FlexMeasures cannot set a reporter up from a source saved under another type, so after a downgrade, automations on such a source fail to run.
  • A forecast whose "auto" entry filters the target's sources still uses those filters as given, so it may need "exclude-source-types": ["forecaster"] added. This is documented, not changed.

Related Items

closes #2785


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

An output-source-type in the reporter config (e.g. forecaster, for a sum of forecasts) replaces the class default 'reporter'.
The field has no default, so configs that leave it out dump unchanged and existing sources keep their attributes hash.
MemberFilterSchema now derives from Schema, as a member filter is no reporter config.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…r, too

A reporter configured to save under a forecaster-type source left that source unable to set its reporter up again,
because only the registry named by the source's type was looked in.
A data generator found that way is only accepted if its config says to save under the source's type.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
The aggregator looked for its partial aggregates, and the sensor status for the members they left out, among reporter-type sources only.
A report saved under another type (see output-source-type) would leave a stale partial aggregate as the latest belief, and drop the missing-members warning.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
The sources API gets a generator_type filter, matching sources by model against the registered data generators of that kind.
The automation source picker uses it instead of the source type, so a report automation can pick an aggregator saving under a forecaster-type source,
and a forecast automation no longer lists such a source, which it would refuse.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Includes when not to set output-source-type, and that a forecast whose "auto" entry filters sources does not leave out forecasters by default.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…nerator that does not exist

Field names reach the wire with dashes.
A typo such as generator-type=reportr now gets a 422, rather than an empty list that reads as if no source matched.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…urce types

Judging every source type for missing members, rather than reporters only, had the status look the sensor's sources up again for each type.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Covers the source and its hash when the field is left out, the label, refusing an unknown type,
leaving the aggregated forecast out of the training data of a forecast, setting the reporter up again from its source,
report automations (API and plugin handler), partial aggregates and their status, and the generator-type filter.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…s missing members

The status looked the sensor's sources up for the stalenesses, and again for the missing members.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…other type

The check ran only for a data generator found among the other kinds,
so a reporter-type source with a config naming the forecaster type set its reporter up, which then went on recording reports under it.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
A source of another type, such as a demo script, can carry a model named after a data generator,
but it stores no data generator to set up.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
The output-source-type of a reporter config and the generator-type filter of the sources API share one validator.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…r anyway

A config saying 'reporter' now has the source of the same config without it,
rather than a source of its own that would split the sensor's reports, and leave partial aggregates of the old source unsuperseded.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@BelhsanHmida BelhsanHmida self-assigned this Nov 2, 2026
@read-the-docs-community

read-the-docs-community Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
📖 204 files changed · 6 added · 144 modified · 54 deleted

Preview · build overview · flexmeasures · built Dec. 1, 2026, 10:33 p.m. UTC

@Flix6x Flix6x left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks Mohamed! I went through this on an isolated instance (the PR merged with today's main): the CLI, the sources API, a report automation through the API and through the UI, and the sensor page as the toy user. It works as described: the sum of the houses' forecasts is saved under a forecaster source, the tooltip says so, the community's forecast no longer trains on it, explicitly setting reporter keeps the old source, unknown values are refused, and reruns and automations find the reporter behind a forecaster-type source while forecast paths refuse it.

Going through it, though, we ended up questioning the approach itself: asking users to stamp the output type by hand. Below is where we landed, and how we got there.

Needs a change

  1. Let the AggregatorReporter derive the output type from its inputs, and drop output-source-type.
    The PR keeps the type explicit because tariff reports also record values about the future that are known prices, not forecasts. That argues against deriving the type from belief horizons, but not against deriving it from the inputs' source types: a sum that includes a forecast is a forecast. Per event, by the beliefs that went into it:

    • any belief from a forecaster source → the event is saved under a forecaster-type source;
    • otherwise, any belief from a scheduler source → scheduler-type;
    • otherwise → reporter-type (other source types, such as user or a script, count like measurements).

    No belief horizons in this rule. Why this order: FlexMeasures acts on a source type in two places, forecast training (which leaves out forecaster sources from the target) and the status page (which expects forecaster and scheduler sources to deliver ahead of time). A sum containing a forecast is no ground truth, so it must not become a training target, which is #2785 itself. We see the three kinds as making different claims: a forecaster predicts, a scheduler prescribes, and a reporter derives, making no claim of its own, so its output should inherit the kind of its inputs.

    The aggregator already records per event under more than one source (partial aggregates in group mode), so a per-event type fits its design. Nobody has to remember a setting, which is what #2785 was about. With that, output-source-type has no use left but mislabeling, so please drop it: adding it later stays compatible, removing it after a release does not. Keep the other half of the PR, setting up a reporter again from a forecaster-type source, and refusing such a source on forecast paths.

    Someone who would rather have a report with a gap than a forecast without one can leave forecasts out of the inputs; the partial-aggregate handling then takes over. Later, the same idea could extend to other reporters per run (e.g. a PandasReporter stamping by the types of the beliefs it loaded), but not in this PR.

  2. Replace the generator-type filter with data-generator, matched case-insensitively and including subclasses.
    How we got there: type and generator-type take the same words (forecaster, reporter, scheduler) for two different things, what the data counts as versus what computed it, and the listing's existing filter is a bare type, so the two read alike. Meanwhile, automations already take data-generator with a class name (AggregatorReporter), and GET /sources/<id> shows a data_generator entry. Filtering on the class and its subclasses gives one key and one vocabulary: data-generator=AggregatorReporter lists only sums, and with case-insensitive matching data-generator=reporter simply matches the base class Reporter, without extra aliases. It can work from app.data_generators with issubclass, matched against DataSource.model as the PR already does for a kind. Better to settle the name now, before the filter is released.

  3. Docs, along with 1 and 2:

    • the example sums house forecasts without output-source-type, and explains that the sum takes its type from its inputs (the rule above); the note on when to set the field goes;
    • a short paragraph on source type versus data generator, with the data-generator filter, e.g. a forecaster-type source made by a reporter;
    • the example writes source_types while the text says source-types: please use the spelling the text and the API use;
    • the note that a forecast whose "auto" entry filters sources must leave out forecasters itself stays.
  4. flexmeasures add report --source crashes with an AttributeError when no reporter can be set up from the source, as get_data_generator returns None and the command doesn't check. This predates the PR, but it's a few lines: print an error naming the source and abort, as the command already does for an invalid period, plus a test.

  5. Changelogs. None of the three is touched. The main changelog needs an entry under v1.2.0, and the API changelog one for the final spec (the data-generator filter on GET /sources).

Suggestions

  1. Sums saved before this change stay reporter-type and keep feeding the community's forecast training. One docs sentence saying to delete them, e.g. with flexmeasures delete beliefs --source <id>, would help.
  2. The automation source picker's placeholder, "Search by id, name or data generator class ...", could become "Search by id, name or data generator".
  3. A follow-up issue, not this PR: DataSource.description ("FlexMeasures's AggregatorReporter forecaster" next to "FlexMeasures's AggregatorReporter model") reads like two different generators, and with per-event types one aggregator gets sources of up to three types. The description is used in the API, the chart legend and tooltips, and the status page, so it deserves a redesign of its own.

Not this PR: the source details modal's layout (added to #2866), and the snake/kebab mix in ?only_latest=false&generator-type=reporter (added to #2540).

@Flix6x Flix6x added this to the 1.2.0 milestone Nov 11, 2026
@Flix6x Flix6x added the Data label Nov 11, 2026
…ad of an output-source-type config field

A sum that includes a forecast is a forecast, so the AggregatorReporter now saves each event under a forecaster-type source if any belief that went into it came from a forecaster, under a scheduler-type source if any came from a scheduler, and under a reporter-type source otherwise.
Nobody has to remember a setting, and the field had no use left but mislabelling, so it is dropped before it is released.
Partial aggregates follow the same rule, and a complete aggregate supersedes a partial one of any type this report saves under.
A reporter is still set up again from a forecaster-type source, and refused on forecast paths.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…tor-type

`data-generator` takes the class name that automations and the source details already use, matched case-insensitively and including subclasses, so `data-generator=Reporter` lists every report and `data-generator=AggregatorReporter` only the sums, whatever their type.
The automation source picker uses it, and its placeholder no longer says "class".

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
… reporter from it

The command crashed with an AttributeError on None instead.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Also explain source type versus data generator with the new filter, and how to recompute sums saved as reports before this change.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@BelhsanHmida

Copy link
Copy Markdown
Contributor Author

@Flix6x Agreed on deriving the type: the aggregator now saves each event by its inputs (forecaster > scheduler > reporter), partial aggregates included, and output-source-type is gone. data-generator replaces generator-type, add report --source now aborts with the source named, and the docs and both changelogs are updated, with your notes from 6 and 7.
On 3: the reporter's input only accepts source_types (unknown keys are refused), so the example keeps it, and the text now says "source-types" is the flex-config spelling.
8 makes sense as its own issue.

@BelhsanHmida
BelhsanHmida requested a review from Flix6x November 18, 2026 23:28

@Flix6x Flix6x left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks Mohamed, the source type now follows the data, exactly as we had in mind, and all eight points of my last review are addressed. I went through it again on an isolated instance at the PR head (4a4560363): the CLI, the sources API, report automations and the UI, as the toy user and as an admin.

What I checked

  • With only method: sum, a sum of the houses' forecasts is saved under a forecaster-type source, a sum of their meter readings under a reporter-type one, and a report over House A's readings and House B's forecasts splits per event: yesterday (House A only) as a report, from today on as a forecast. A forecast of the community leaves only the forecaster-type sums out of its training data.
  • A config that still has output-source-type is refused as an unknown field.
  • flexmeasures add report --source on a forecaster-type sum recomputes, and measurements then go to the reporter-type source; on a source without a reporter it names the source and aborts.
  • Forecast automations still refuse the aggregator's source; report automations accept it, and their runs save per event too.
  • data-generator=AggregatorReporter lists both sums and leaves a demo script carrying that model name out; data-generator=reporter matches every report; the automation source picker uses Forecaster and Reporter.
  • The docs (rule, why, source type vs. data generator), the delete note and the placeholder are in. On source_types: you're right, the reporter's input only takes the underscore spelling today, so the example is correct as it stands (but see point 8).
  • The eight touched test files pass here.

Requested changes

Most of these are about making the new behaviour understandable to users who don't know the difference between a data source and a data generator.

  1. Merge main: the PR now conflicts with it in documentation/changelog.rst, documentation/api/change_log.rst, flexmeasures/api/v3_0/tests/test_automations_api.py and flexmeasures/ui/templates/assets/asset_automations.html.
  2. Move the API changelog entry to v3.0-37. It sits under v3.0-35, which was released on November 11 (with v1.1.1); v3.0-37 is main's upcoming version. The main changelog entries under v1.2.0 are fine as they are.
  3. Explain the 422 for a forecast automation in the user's terms. Setting one up from the aggregator's forecaster-type source gives Data source 6 does not store a forecaster. To a user who sees a source of type forecaster, that is an arbitrary wall, and we can't assume they know the difference between a source and a data generator. Please put it simply and say exactly what to change, e.g. Source 6 is not a forecaster, but a reporter computing sums of forecasts. To use this source, set the automation type to "reporting".
  4. Refuse a data-generator name that matches nothing. An unknown name now gives an empty list, so that sources of an uninstalled plugin can still be found by its name. But when the name matches no installed data generator and no source has it as its model (a typo like data-generator=nonsense), please answer with a 422 naming the problem, e.g. Unknown data generator 'nonsense': no installed data generator or existing source has that name. That is one extra check (does any source have one of the matched models), and an installed generator without sources keeps returning an empty list.
  5. Fix the tooltip of "Existing data source" (asset_automations.html, from #2584). It says: "The automation then records what it computes under that same source, alongside the data it already holds." That is unclear (which data, on which sensor?), and with this PR it is no longer true for the aggregator, whose runs can save under a sibling source of another type. For example: "Optional. Reuse the data generator and configuration of an existing data source, instead of setting the two fields below. The results are saved on the sensor named in the parameters, under that source or, if the data calls for another source type, a matching source of the same data generator."
  6. Show, don't hide, the summed forecast in a forecasting picker. With type forecasting, the source picker leaves out the aggregator's forecaster-type source, so a user who sees summed forecasts on the sensor can't find their source and doesn't learn why. Please list it greyed out, with the same message as in point 3 ("Source 6 is not a forecaster, but a reporter computing sums of forecasts. To use this source, set the automation type to "reporting"."), or with a one-click switch to reporting.
  7. Docs: say why the forecasting tools refuse such a source. In documentation/features/reporting.rst, "A reporter can also be set up again from such a source, for instance with flexmeasures add report --source <id>, while the forecasting CLI, API and automations refuse it." leaves the reader wondering why a forecaster-type source is refused by forecasting. For example: "Such a source stores a reporter, not a forecaster, so use it to set up a report, for instance with flexmeasures add report --source <id>; the forecasting CLI, API and automations don't accept it."
  8. Accept kebab-case in a reporter's input, too. While we document these fields more, let's let the reporter's Input schema (flexmeasures/data/schemas/io.py) take both spellings: kebab-case as the documented one (source-types, exclude-source-types, most-recent-beliefs-only, ...), snake-case still accepted for existing configs (a pre_load mapping would do, refusing a field given in both spellings). And update the docs that advertise the snake-case spelling (reporting.rst, data-pipelining.rst, toy-example-reporter.rst, the tutorial 5 script). This can be a follow-up issue (see also #2540), but then please give it milestone v1.2.0, so it lands in the same version as this PR.

Something we'll pick up ourselves

A rerun from a forecaster-type source on measurements now (rightly) saves under the reporter-type source, and a mixed run under two sources, while flexmeasures add report only says how many beliefs it recorded. We'll add an info-level line saying which source(s) and type(s) a report was saved under (a warning would fire on every mixed run). Not a blocker for this PR.

Follow-up issue (point 8 of my last review: the source description)

Could you open it? Next to the description ("FlexMeasures's AggregatorReporter forecaster" vs "... model"), it could cover a related thing I noticed: an automation lists a single source, while its runs can save under up to three, one per type. Two report automations computing the same sum showed different sources (one set up from the forecaster-type source, one from a data generator and config, which got the reporter-type source), and the second one's forecasts went to the forecaster-type source it doesn't list. Everything is saved correctly; only what an automation shows is off.

It could also consider deriving an automation's type from its source when a source is given (a source that stores a reporter → reporting), refusing only an explicit mismatch, so this wall mostly disappears. That would mean dropping load_default="forecasting" for type in AutomationCreationSchema and falling back to forecasting only when no source is given.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…e takes it

A forecaster-type sum of forecasts stores a reporter, so a forecast automation refuses it;
the refusal now says so in the user's terms, and to set the automation type to reporting.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
A name that is neither an installed data generator nor the model of a source the user can list,
such as a typo, now gets a 422 rather than an empty list.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
A report from the aggregator can be saved under a sibling source of another type,
so the tooltip no longer says that results always go under the picked source.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…picker

Such a source is of type forecaster but stores a reporter, so a forecast automation cannot use it;
rather than leaving it out, the picker lists it greyed out, saying why and which automation type takes it.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@BelhsanHmida

Copy link
Copy Markdown
Contributor Author

Main is merged, and the API entry now sits under v3.0-38, since v3.0-37 went out on Nov 29. The forecast-automation 422 now says what the source is and to set the type to "reporting". The forecast picker lists such a source greyed out with that same message, and an unknown data-generator name gets your 422. The tooltip and the docs sentence use your wording.
8 is now #2946 with milestone v1.2.0, and the source display and type derivation follow-up is #2947.

@Flix6x Flix6x left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks Mohamed, all eight points of my last review are in. I checked them at d63d1bed2, together with #2948 on top:

  • Main is merged, and the data-generator entry sits under v3.0-38, which is right, as v3.0-37 shipped on November 29.
  • A forecast automation set up from a sum of forecasts now gets a 422 that says what the source is and to pick "reporting". The reverse case says "forecasting".
  • data-generator=nonsense gets a 422, while an installed generator without sources still lists none.
  • The "Existing data source" tooltip and the docs sentence read well.
  • The forecasting source picker lists the summed forecast greyed out, saying why.
  • #2946 and #2947 are filed, and the touched tests pass here, as does CI.

One related thing went to #2948 instead: flexmeasures add forecasts --source on such a source crashed with an AttributeError. I pushed a refusal in the automation's words there (f0b0767), with a test.

@Flix6x
Flix6x merged commit 384c3b1 into main Dec 3, 2026
11 checks passed
@Flix6x
Flix6x deleted the feat/reporter-output-source-type branch December 3, 2026 08:54
Flix6x added a commit that referenced this pull request Dec 3, 2026
Keeps both tests at the end of reporting/tests/test_aggregator.py: the one from #2804 and the DST test from this PR.

Signed-off-by: F.N. Claessen <claessen@seita.nl>
Flix6x added a commit that referenced this pull request Dec 3, 2026
…tor types

Since #2804, an AggregatorReporter saves each event under the type of its inputs, so one reporter records as a
forecaster, a reporter or a scheduler. Families of sources were keyed by name, type and model, which split such a
reporter into unrelated sources: its versions were not compared, a complete aggregate did not replace a partial one of
the same belief time (the higher source id decided), and a search naming both preferred whichever came first.

- source_family: name and model, plus the type unless it is a data generator's type; used by
  _select_latest_version_and_belief_per_event, keep_latest_version and the aggregator's superseding lookup.
- Sensor.search_data_sources returns sources in id order, not in whatever order the database returns.
- The superseding lookup goes back to one_deterministic_belief_per_event (reverting aafbbef's workaround),
  which test_a_complete_forecast_supersedes_a_partial_report_recorded_since now passes on its own, too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Flix6x added a commit that referenced this pull request Dec 3, 2026
* Fill segment overlaps with bfill(axis=1) instead of fillna(method=), which pandas 3 removed

* Write hourly resolutions in test fixtures as 1h, because pandas 3 no longer accepts 1H

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v3WRq4uE4AaVmZiHWA
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* Count whole-day resolutions as calendar days in date ranges and resampling

Pandas 3 reads timedelta(days=1) as a frequency of a fixed 24 hours,
so daily steps would no longer land on local midnights after a DST change, as they did under pandas 2.
This would undo #2907 for the GET sensor data endpoint, for example.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v3WRq4uE4AaVmZiHWA
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* Return a Timestamp from apply_offset_chain when given a Timestamp

A pd.Timestamp is also a datetime, so it was returned as a datetime.
With pandas 3's zoneinfo timezones, such a datetime in an hour that a DST change repeats
never equals a time in another timezone (PEP 495).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v3WRq4uE4AaVmZiHWA
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* Convert datetimes and timedeltas to epoch values from nanoseconds explicitly

Pandas 3 no longer stores them in nanoseconds by default,
so chart data and compressed belief records got timestamps in seconds instead of milliseconds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v3WRq4uE4AaVmZiHWA
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* Parse timedeltas explicitly before converting their time unit

Under pandas 3, text divided by a Timedelta leaves an object dtype rather than floats.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v3WRq4uE4AaVmZiHWA
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* Stack annotations that end at the same time, also on pandas 3

Pandas 3 left the grouping column out of each group, and ignored the chained assignment
that collected the contents (Copy-on-Write), so only the first annotation's content was shown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v3WRq4uE4AaVmZiHWA
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* Index Series by position with iloc, and keep float columns float

Pandas 3 reads series[3] as a label rather than a position,
and refuses to set a float into an integer column rather than upcasting it.
In the storage scheduler, the constant penalty for preferring a full storage sooner was read with iloc[0][0].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v3WRq4uE4AaVmZiHWA
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* Avoid what pandas 3.1 deprecates for pandas 4, so the logs are not flooded with Pandas4Warnings

No more inplace reset_index, set_index or rename, positional arguments of sum, implicit sorting in concat,
implicit date formats in to_json, Timestamp.utcnow or the d unit alias.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v3WRq4uE4AaVmZiHWA
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* Changelog entry for pandas 3 support, which includes #2932

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v3WRq4uE4AaVmZiHWA
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* Write epoch milliseconds into JSON records ourselves, as pandas 3.1 deprecates its epoch date format

DataFrame.to_json(date_format="epoch") warns on every call under pandas 3.1, and pandas 3 floors negative durations
where pandas 2 truncated them toward zero. Converting datetime and timedelta columns to milliseconds ourselves
keeps the JSON for charts and annotations exactly as pandas 2 wrote it, without a warning per request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v3WRq4uE4AaVmZiHWA
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* Require timely-beliefs 5.0.0, the first release that supports pandas 3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v3WRq4uE4AaVmZiHWA
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* Lock pandas 3.1.2, so CI and the Docker image run on pandas 3

pyproject still allows pandas 2 (pandas>=2.2.1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v3WRq4uE4AaVmZiHWA
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* Changelog: pandas 3 is now the locked version

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v3WRq4uE4AaVmZiHWA
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* Rename to_calendar_frequency to to_calendar_offset, and document it as a stepping stone

It returns an offset, not a frequency. Its docstring now says it keeps the pandas 2 behaviour rather than converting correctly: a timedelta cannot tell P1D from PT24H, so both count as calendar days, until FlexMeasures keeps nominal and absolute durations apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v3WRq4uE4AaVmZiHWA
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* Test that whole-day resolutions step by calendar days across DST

These tests fail on pandas 3 without to_calendar_offset: daily steps would fall at 23:00 after DST ends, and the day DST ends would no longer add up 25 hours.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v3WRq4uE4AaVmZiHWA
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* Point to_calendar_offset to the issues about nominal durations

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v3WRq4uE4AaVmZiHWA
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* Drop initialize_index's branch for pandas < 1.4, which FlexMeasures no longer supports, and say why timely-beliefs 5.0.0 is required

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* Find the partial aggregate a report supersedes by belief time, whatever order its sources come in

The lookup used one_deterministic_belief_per_event, which between sources of different types keeps the one listed first.
That order came from the database, so a complete forecast saved before could hide a partial report recorded since,
and test_a_complete_forecast_supersedes_a_partial_report_recorded_since failed whenever it ran on its own (and once in CI).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: F.N. Claessen <claessen@seita.nl>

* Count a data generator's sources as one family across the data generator types

Since #2804, an AggregatorReporter saves each event under the type of its inputs, so one reporter records as a
forecaster, a reporter or a scheduler. Families of sources were keyed by name, type and model, which split such a
reporter into unrelated sources: its versions were not compared, a complete aggregate did not replace a partial one of
the same belief time (the higher source id decided), and a search naming both preferred whichever came first.

- source_family: name and model, plus the type unless it is a data generator's type; used by
  _select_latest_version_and_belief_per_event, keep_latest_version and the aggregator's superseding lookup.
- Sensor.search_data_sources returns sources in id order, not in whatever order the database returns.
- The superseding lookup goes back to one_deterministic_belief_per_event (reverting aafbbef's workaround),
  which test_a_complete_forecast_supersedes_a_partial_report_recorded_since now passes on its own, too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: F.N. Claessen <claessen@seita.nl>

---------

Signed-off-by: F.N. Claessen <claessen@seita.nl>
Co-authored-by: Furqan Khan <236162110+furqan-khan07@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.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.

Let reporters that aggregate forecasts save their data under a forecaster-type source

2 participants