Repository navigation
Feat: accept kebab-case field names in a reporter's input - #2948
BelhsanHmida wants to merge 35 commits into
Conversation
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>
…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>
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>
SupportsLegacyFieldAliases lets the canonical spelling win, which leaves a schema that refuses unknown fields with a vague "Unknown field" for the legacy one. The opt-in refuse_both_spellings flag names both spellings instead. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Each multiword field of a reporter's input, such as source-types, is now spelled in kebab-case, like the flex-config and the report parameters. The snake_case spelling is still accepted, so existing reports and automations keep working, but a field given in both spellings is refused, naming both. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
A reporter's input can now name its user sources as user-source-ids, and report jobs carry it that way, so the check for waiting jobs that refer to a data source looks under both spellings. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
A data generator saving its parameters drops each input's window, which changes from run to run. A reporter's input now dumps that window in kebab-case, which was kept, so each run would have made a new data source. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
A copy into another organisation checks the data sources and organisations an automation names. It looked only under each field's current spelling, so a report automation stored with user_source_ids or source_account_ids skipped that check. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Also name source-account-ids in the reporting docs, where they listed an account_id filter that does not exist. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
📖 12 files modified
Preview · build overview · flexmeasures · built Dec. 2, 2026, 3:07 p.m. UTC |
Flix6x
left a comment
There was a problem hiding this comment.
Thanks Mohamed! I went through #2804's new commits and this PR together, at both heads, on a test database. I ran flexmeasures add report with the AggregatorReporter and the PandasReporter, and a report automation run by a worker, each with the input in snake_case and in kebab-case.
#2804 (all eight points of my last review)
All done, mostly in my own wording: main merged, the API entry under v3.0-38 (right, since v3.0-37 shipped on November 29), the forecast automation's 422 and the greyed-out summed forecast in the picker that says why, the 422 for an unknown data-generator, the tooltip and the docs sentence. Thanks for filing #2946 and #2947 too. I'll approve #2804 separately.
What I checked here
- Kebab-case input is refused at #2804's head and accepted here. Kebab-case and snake_case give the same events, the same totals and the same data source, for both reporters, also with several kebab-case fields at once.
- An input giving a field in both spellings is refused, naming both.
- A report automation with kebab-case input is created, stores the input as given, queues a job in kebab-case, and the worker computes the same report under the same source.
jobs check-source-references,save_parametersand copying an automation handle both spellings. The upgrade note on restarting workers together with the web processes is clear.- The new tests, the reporter tests, the report CLI and API tests and the automation tests pass here, and so does CI.
Requested changes
- Names: please use
priorandsource-accountinstead ofbelief-timeandsource-account-ids, as you suggested. The report's own parameters and the data requests already call this cut-offprior. Sensor references and data requests call the account filtersource-account, as the table indata-pipelining.rstshows. Each filter then has one name everywhere. The snake_case aliases simply mapbelief_timetopriorandsource_account_idstosource-account(andDataGenerator's list of window fields to leave off a source would needprior). - Snake_case only for the fields that had it.
Input.legacy_field_aliasesis derived from all declared multiword fields, so every field added later gets a snake_case spelling it never had (and the field-naming test requires that). New fields should be kebab-case only. Please write the alias dict out, listing the multiword fields as of v1.1 (withbelief_time→priorandsource_account_ids→source-accountafter the rename), and adjust the test accordingly.
Fixed by us on this branch
flexmeasures add forecasts --source <id>crashed on a summed forecast's source, withAttributeError: 'NoneType' object has no attribute 'set_job_trigger': the command didn't check whetherget_data_generatorreturned a forecaster. This predates #2804, but #2804 makes forecaster-type sources that store a reporter common, and its docs now say the forecasting CLI doesn't accept them. I'm pushing a fix to this branch right after this review: the command will abort with the same message as the automation's 422 (_source_refusal), asadd report --sourcedoes, with a test.
Follow-up issue (not this PR)
Could you open one under #2540 for the multiword fields of a report outside input? These are check_output_resolution, belief_horizon and the PandasReporter's use_latest_version_only in the parameters, and required_input, required_output, df_input, df_output and skip_if_empty in the PandasReporter's config. Today a report written in kebab-case still mixes spellings. The issue could also cover this: an AggregatorReporter input with horizons_at_most (or another search criterion the aggregator sets itself, such as the event window) crashes with TypeError: ... got multiple values for keyword argument, in either spelling. It should be refused with a clear message instead.
A forecaster-type source may store a reporter, such as the AggregatorReporter that saves a sum of forecasts, so get_data_generator returns None for it and the command crashed with an AttributeError. Abort instead, in the words a forecast automation refuses such a source with (_source_refusal), as `add report --source` already refuses a source it cannot set up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: F.N. Claessen <claessen@seita.nl>
|
Follow-ups of my review:
|
Description
A reporter's input only took snake_case field names (
source_types,most_recent_beliefs_only), while the flex-config and the report parameters around it use kebab-case, and"source-types"was refused as an unknown field.This PR makes kebab-case the documented spelling of a reporter's input, and keeps snake_case working for existing reports and automations. For example:
An input giving a field in both spellings is refused:
Inputschema gets a kebab-casedata_key:event-starts-after,event-ends-before,belief-time,beliefs-after,horizons-at-least,horizons-at-most,user-source-ids,source-account-ids,source-types,exclude-source-types,most-recent-beliefs-only,most-recent-events-only,most-recent-only,use-latest-version-per-event,one-deterministic-belief-per-event,one-deterministic-belief-per-event-per-sourceandsum-multiple.The Python names stay as they are, so the reporters themselves are unchanged, and so is a Python caller passing deserialized input, such as
compute(input=[dict(source_types=["forecaster"])]).SupportsLegacyFieldAliases, with the aliases derived from the declared fields, so a field added later cannot miss its legacy spelling.SupportsLegacyFieldAliasesgets an opt-inrefuse_both_spellingsflag. Without it, the canonical spelling wins and the other is left behind, which a schema refusing unknown fields reports as a bare "Unknown field". The API schemas using the mixin keep their behaviour.flexmeasures jobs check-source-referencesalso finds a source named underuser-source-ids, which is how report jobs now carry it.save_parameters=True) still leaves each input's window (event-starts-after,event-ends-before,belief-time) off its data source, now that the input dumps it in kebab-case.regularisereport template and the docs (reporting, data pipelining, the toy reporter tutorial and its script) use kebab-case. The reporting docs listed anaccount_idfilter, which does not exist; it is nowsource-account-ids.documentation/changelog.rstFor hosts and plugin developers
save_parameters=True, which no built-in reporter does) stores a multiword input field in kebab-case from now on. Its data source is identified by those stored parameters, so its first run after the upgrade records under a new data source.Names to confirm
Two fields were spelled mechanically, where a name used elsewhere could replace them. Please confirm or pick the other:
belief_timebecamebelief-time. The report parameters and data requests call the same cut-offprior, sopriorwould read the same everywhere, but it also renames the field rather than only respelling it.source_account_idsbecamesource-account-ids. Sensor references and data requests call this filtersource-account, which would give the filter one name everywhere (see the table in the data pipelining docs).Look & Feel
flexmeasures add automation --type reporting --parameters report.yaml, wherereport.yamlgives one input both spellings:The same report in kebab-case and in snake_case records the same values under the same data source, through
flexmeasures add reportand through a report automation, for thePandasReporterand theAggregatorReporter.How to test
Or by hand: run
flexmeasures add report --reporter PandasReporterwith an input usingsource-types: [forecaster], then withsource_types: [forecaster]on another output sensor, and compare the two sensors' data and sources. Then give one input both spellings and see it refused.Further Improvements
flexmeasures add reportshows invalid parameters as a traceback, for any validation error, not only this one.Related Items
Closes #2946.
Follow-up to #2804, from its review. Part of #2540.
Sign-off