Aggregate the portfolio the flex-context already describes - #2579
Ahmad-Wahid wants to merge 4 commits into
Conversation
Context: - Issue #2573: a scheduled site already lists its portfolio in its flex-context, under `inflexible-consumption` and `inflexible-production`, and can name the sensors their aggregates belong on. A report should not have to restate that. Change: - A `portfolio` config field ("consumption" or "production") reads the sensors to aggregate from the asset's flex-context, with each entry's source filters passed on to the belief search unchanged. - When the parameters name no output, the same portfolio's `aggregate-consumption` or `aggregate-production` says where the aggregate is recorded; an output named in the parameters still wins. - `portfolio` uses `asset` to find the flex-context rather than as a subtree to walk, so it aggregates what the portfolio lists and not every sensor below the asset. - The deprecated `inflexible-device-sensors` is refused, because it says nothing about whether a sensor records consumption or production. - `output_sensors` reports a sensor taken from the flex-context, so an automation checks the report against the sensor it will really be written to. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Context: - Issue #2573 lets the AggregatorReporter read its portfolio, and the sensor it records on, from the asset's flex-context. Change: - Add a fixture describing the site's consumption portfolio in its flex-context, and cover a report that names neither input nor output, the source filters an entry carries, an output override, a missing asset, a portfolio the flex-context does not describe, the refusal of the deprecated field, an unknown direction, and having nowhere to record at all. - Update the specialized-schema guard: the aggregator's `output` is now optional by design, so the guard holds it to recording on at most one sensor instead. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Context: - Issue #2573 adds the `portfolio` config field to the AggregatorReporter. Change: - Describe what `portfolio` reads from the flex-context, that the context resolves up the asset tree, that source filters are passed through, that `asset` is not walked as a subtree here, and why the deprecated field is refused. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Context: - PR #2579 lets the AggregatorReporter take its portfolio, and the sensor it records on, from the asset's flex-context. Change: - Add a New features entry, next to the one for the reporter's own sensor selection. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Documentation build overview
46 files changed ·
|
|
This is the right direction, but I'd rework it in a few ways (and retarget it at main, see my comment on #2525). Wrong quantity on Per-commodity contexts are missed. The aggregate and inflexible fields can also sit inside the flex-context's Use Source filters. The flex-config's source filters mix two things. Provenance (e.g. Smaller things from reading the code:
|
Description
A site that is scheduled has already said what it is made of. Its flex-context lists the sensors of
its inflexible load under
inflexible-consumptionandinflexible-production, and it can name thesensors those aggregates belong on, under
aggregate-consumptionandaggregate-production. A reportthat aggregates the same portfolio should not have to restate it.
A new
portfolioconfig field on theAggregatorReporter, takingconsumptionorproduction,does both halves of that idea:
The parameters name no sensors at all. The sensors to aggregate come from the asset's
inflexible-consumption, and the result is recorded on the sensor itsaggregate-consumptionnames.An
outputnamed in the parameters still wins, for a one-off report that belongs elsewhere.The flex-context resolves up the asset tree, exactly as it does for scheduling, so a portfolio
defined on a site also serves the assets below it.
Source filters are passed through. Each entry may carry
source-types,exclude-source-types,sourcesorsource-account, and those reach the belief search unchanged, so a portfolio pointing ata forecaster's values aggregates exactly those rather than everything on the sensor.
portfoliousesassetto find the flex-context, not as a subtree to walk. This is the onedesign decision worth a second look: the two readings of
assetare genuinely different, and walkingthe subtree as well would silently aggregate every sensor that happens to sit below the site —
which is what my first draft did, and what a test caught.
sensorsstill contributes alongside aportfolio when you want to add something.
The deprecated
inflexible-device-sensorsis refused, with a message saying why: it is a flatlist that says nothing about whether a sensor records consumption or production, so it cannot answer
for either portfolio. Splitting it is the migration the schema already wants.
output_sensorsreports a sensor taken from the flex-context, so an automation checks the reportagainst the sensor it will really be written to — which matters now that #2297 has landed.
documentation/changelog.rstHow to test
Eight tests are added, on a fixture that describes the site's consumption portfolio in its
flex-context and points
aggregate-consumptionat a sensor that already holds a previous report.They cover a report naming neither input nor output, an entry's source filters reaching the search, an
output override, a missing asset, a portfolio the flex-context does not describe, the refusal of the
deprecated field, an unknown direction, and having nowhere to record at all.
Each was verified to fail with the code it covers disabled. The nine breaks used were: ignoring the
portfolio's inputs, not resolving the output from the flex-context, letting
portfolioalso walk thesubtree, dropping an entry's source filters, not erroring on a missing asset, not flagging the
deprecated field, not overriding
output_sensors, removing theportfoliovalue validator, andremoving the at-most-one-output validator.
A test that had to change
test_specialized_reporter_schemas_preserve_required_dataflow_fieldsasserted that the aggregator'soutputstays required. That is no longer the contract — the config can supply it — so the guard nowholds the aggregator to recording on at most one sensor instead, and the "something must supply an
output" rule is enforced at compute time with its own message and its own test. The
ProfitOrLossReporterhalf of the guard is untouched. Both halves were verified to still fail whenthe constraint they name is removed.
Related items
Closes #2573. Stacked on #2525 (issue #2520), whose
asset/sensor-name-pattern/sensor-unitsselection this builds on; review that one first.
Note that both branches are currently 14 commits behind
main, which has since gained #2297 andrenamed the reporter parameter
belief_timetoprior. Neither touches the aggregator, so the stackwas left tight rather than merged; #2525 needs the merge first, and it could not be done here because
that branch is checked out elsewhere.
Sign-off
🤖 Generated with Claude Code