Repository navigation
feat: Let the CLI refuse unfilled report template placeholders through the service check - #2945
Open
BelhsanHmida wants to merge 270 commits into
Open
BelhsanHmida wants to merge 270 commits into
BelhsanHmida wants to merge 270 commits into
Conversation
Consolidates the shared automations concept (model, lifecycle, runner deployment, provenance) into documentation/features/automations.rst, with the per-feature pages linking to it and keeping only their type-specific parameter semantics. Part of #2288 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Hosts can now discover and use ready-made report definitions (reporter class + complete config + parameters skeleton) instead of authoring YAML from scratch: - Two templates ship in flexmeasures/data/templates/reports: energy-costs (ProfitOrLossReporter) and self-consumption (PandasReporter), each with FILL_IN sensor placeholders and a recommended rolling reporting window for recurring use. - `flexmeasures show report-templates` lists them; `--name <name>` prints the full YAML (with comments) to pipe to a file. - `flexmeasures add report` and `flexmeasures add automation --type reports` accept `--template <name>`, using the template as defaults under any --config/--parameters files and other options (user keys win; user-provided timing fields replace the template's window). - Unfilled placeholders produce a clear validation error listing the fields to fill in. Part of #2288 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
- API automation creation now checks that the caller may read every sensor referenced in the parameters/config and record data on the sensors the automation writes to, closing a cross-account data read/write hole. - `add report --as-job` implies --save-config (the worker rebuilds the reporter from its data source, so jobs without stored config always crashed). - Report automation parameters are validated with the chosen reporter's own parameters schema, not the base schema. - Invalid start-offset/end-offset strings are rejected at creation instead of being silently skipped at run time (which yielded empty report windows). - run_report_job wipes the shared cached reporter's parameter state, like the automation runner already did, so consecutive jobs in one worker process don't pollute each other. - Default report windows now anchor to the end of the last *successfully* covered window, recorded by the reporting job upon success — failed jobs no longer create permanent reporting gaps, and the enqueue-time minute-rollover gap is gone (the recorded anchor is the window end itself). - The cron-period fallback window is computed in the platform timezone, matching how the runner decides when automations fire. - Job stats for schedules automations also scan flex-model device sensors (which may belong to child assets), so failed per-device jobs show up. - The trigger provenance kwarg is excluded from the job cache hash, so identical schedule requests from different origins dedupe again. Part of #2288 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
…essage format PR #2303 makes click report the validation message rather than the offending value, which changes the exact wording of this error. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Merge current main, resolve the shared forecasting and documentation changes, regenerate the lockfile, and move the automation migration after the current migration head. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Reject cron expressions with seconds, year fields, or aliases because the automation runner executes once per minute. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Test valid five-field expressions and reject unsupported seconds, year, and alias formats. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Keep the per-minute Redis guard after failures because an attempt may already have queued some forecast jobs. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Verify that retrying a failed partial queueing attempt does not create duplicate jobs. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Convert YAML dates to ISO strings, accept empty files, and report non-object config or parameter files as usage errors. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Test YAML dates and timestamps, empty files, and invalid top-level list values for automation options. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Hide automation names and IDs from asset job responses when the current user cannot read the source automation. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Verify inaccessible automation provenance is redacted while authorized callers still receive the full identity. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Show a persistent API error instead of presenting failed automation requests as an empty list. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Check that the automations page renders the warning target and hides the table when loading fails. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Avoid interpreting cron wildcard asterisks as RST italic markup when generating OpenAPI documentation. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Verify cron wildcards remain unchanged while ordinary italic markup is still converted. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Document five-field cron expressions, at-most-once queueing attempts, and the automations API endpoint. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Record the automation endpoints, authorization-aware provenance, and five-field runner behavior. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Include the created_via field in the asset jobs OpenAPI example. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Add the trigger method required by the forecasting CLI to the regressor parsing test double. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Bring the forecast automation branch up to date with current main while preserving both branches' CLI, API, documentation, dependency lock, and generated OpenAPI changes. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Require every automation to reference a data generator and prevent deleting a data source while an automation still depends on it, matching the retention policy for belief and annotation sources. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Verify referenced generators cannot be deleted, generator references cannot be cleared, and automation API fixtures always use valid generators. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Allow forecast output only on the automation asset or its descendants and revalidate that relationship before every scheduled run, including explicit sensor-to-save targets. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Cover same-asset, child, grandchild, ancestor, and unrelated output targets, explicit sensor-to-save behavior, and runtime revalidation after an asset is moved. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Document output-sensor scope, runtime relationship checks, and the requirement to retain a generator while its automation exists. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Join the automation and main Alembic branches so installations have a single database upgrade target. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Context: - PR #2293 is stacked on the reviewed forecast automation branch. Change: - Merge the reviewed parent and preserve schedule automation behavior across the five semantic conflicts. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
… flow is stored unconverted Meter sensors record instantaneous readings, so the flow computed from them has a resolution of 0, which failed the output resolution check against any 15-minute output sensor. The template now skips that check, as the reports we run do. Its comments also say that the output sensor needs the meter's unit, such as kWh rather than kW, since the flow is not converted. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…adings-to-flow The flow is stored as counted, so a kW output sensor got a 15-minute flow in kWh as if it were kW, four times too small. The form's label for the output sensor now says which unit it needs. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
… earlier one Choosing Regularise and then Valid range left the report named Regularise. A name the user typed still stays. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…window A bound typed as text, such as abc, was stored as text and failed only when the report ran, comparing numbers to a string. Value fields now take numbers only, reading a decimal comma as a point, so 37,5 is 37.5. Clearing either end of the rolling window made a report that cannot run, so both are now required. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
…ate-ui Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
….2.0 Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Main finds the tab in front within the automation type tabs only, so the new-form tests render the tabs as the page does; its example test calls the field toggle by the name it has on this branch. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…s it as the docstring Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…report templates API Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…as the API's other fields are Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…ab-case Today's snake_case data generator fields are listed and kept working; the list may only shrink. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…rom GET /api/v3_0/sensors Units are free text, so the units in use are checked once each, and the sensors filtered on those that fit. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
A template's form block lists the unit or dimension a sensor field takes, and the fields whose sensors share a unit; the placeholder descriptions carry this, for the New automation form to narrow its sensor searches to. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…g unit A field searches for the unit or dimension its template says it takes, and a field sharing a unit with others follows the sensor picked for one of them; an input added to a sum takes what the template's own inputs take. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
… placeholder Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…heck Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…service check flexmeasures add automation leaves the refusal to the service, which creating the automation already runs, and flexmeasures add report calls the service check, so the CLI, the API and the form word it the same way. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Documentation build overview
13 files changed ·
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The CLI refused a report definition with an unfilled
FILL_INplaceholder in its own words, while the API and the New automation form used the service's check, so the same mistake got two different messages.This PR lets the CLI use the service check too. For example,
flexmeasures add report --template energy-costsnow says "config: Replace the 'FILL_IN' template placeholder at consumption_price_sensor.", the wording the API and the form give.flexmeasures add automationleaves the refusal to the service, which creating the automation already runs.flexmeasures add reportcallsrefuse_unfilled_placeholdersand prints each message under its part of the definition (configorparameters).documentation/changelog.rstLook & Feel
How to test
Or by hand: run either command above without filling in the template, and compare the message with the one
POST /api/v3_0/assets/<id>/automationsgives for the same template.Related Items
Closes #2939
Follow-up to #2797
Sign-off