Skip to content

Improve the HEMS tutorial for production use, asynchronous ingestion, cleanup, and interrupted-run recovery. - #222

Open
nhoening wants to merge 14 commits into
mainfrom
feat/hems-script-improvements
Open

Improve the HEMS tutorial for production use, asynchronous ingestion, cleanup, and interrupted-run recovery.#222
nhoening wants to merge 14 commits into
mainfrom
feat/hems-script-improvements

Conversation

@nhoening

@nhoening nhoening commented Aug 14, 2026

Copy link
Copy Markdown
Member

Improve the HEMS tutorial for production use, asynchronous ingestion, cleanup, and interrupted-run recovery.

  • Recommend an account-admin HEMS user instead of a global administrator.
  • Keep price and weather assets inside the configured account.
  • Add HTTPS configuration support.
  • Add data-only cleanup that preserves asset and sensor IDs.
  • Add a new function to delete sensor data
  • Track completed tutorial phases on the community asset.
  • Support recreate, wipe-data, and resume workflows.
  • Fix: the upload function now returns results
  • Fix: Wait for asynchronous ingestion before forecasting, scheduling, and reporting. Supporting FlexMeasures <=0.33 job-status (non-202) behavior, as well.
  • Stop on forecast and report failures instead of continuing with incomplete data.
  • Improve Docker Compose and report-CLI documentation.

Production issues addressed

  • Forecasts no longer start before uploaded training data has been ingested.
  • Simulation reporters no longer read measurements while ingestion is pending.
  • Interrupted runs can resume without repeating completed phases.
  • A data wipe removes uploads, forecasts, schedules, measurements, and report outputs while retaining the asset structure and IDs.
  • Legacy setups without phase markers cannot be resumed ambiguously.

Verification

  • Tested against a live FlexMeasures 0.33 server.
  • 173 non-S2 tests pass.
  • Formatting, linting, compilation, and diff checks pass.

Remaining limitation

Report generation still requires a FlexMeasures CLI connected to the server database. It should be separated from the API-driven setup until reporting APIs are available.

…be admin: account-admin suffices - improve docs and function names as all assets are in account

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
… on circumventing rate limiting as well

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
… tests

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
…not the strucure

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
@nhoening
nhoening requested a review from BelhsanHmida August 14, 2026 10:53
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
@coveralls

coveralls commented Aug 14, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 32086241636

Coverage increased (+0.08%) to 96.658%

Details

  • Coverage increased (+0.08%) from the base build.
  • Patch coverage: 21 of 21 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 748
Covered Lines: 723
Line Coverage: 96.66%
Coverage Strength: 9.67 hits per line

💛 - Coveralls

@nhoening nhoening self-assigned this Aug 14, 2026
nhoening and others added 5 commits August 14, 2026 20:35
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
…; add some helpful prints in the startup

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
HEMS cleanup relies on depth zero to select only top-level assets, but the client discarded that value as falsy. This could broaden cleanup queries and make nested name collisions unsafe.

Preserve zero-valued asset query parameters and expose the server's source and event-time filters for sensor data deletion. Add regression coverage for both request payloads.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Interrupted asset creation, partial data wipes, and legacy site names could leave users with unsafe or destructive recovery paths. Global name lookups could also select assets outside the intended community or account.

Make structure repair idempotent, preserve existing IDs, and offer explicit keep, rename, recreate, continue-wipe, and exit choices where applicable. Validate stored workflow state, scope asset and sensor resolution, retain canonical ingestion jobs, and document the recovery behavior.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
FlexMeasures 0.33 returns ingestion IDs under job_id and expands asset and sensor queries to include roots or descendants. The HEMS recovery flow treated these valid responses as missing or ambiguous, preventing clean runs and incomplete-structure repair.

Accept both job field names, deduplicate repeated roots by ID, and constrain sensor matches to exact owners while retaining genuine ambiguity checks. Align deletion confirmation and recovery documentation, remove the obsolete global lookup helper, and add regression coverage.

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

@BelhsanHmida BelhsanHmida left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I completed a final review. looks good to me now. i pushed some follow-ups

The follow-up fixes make cleanup respect depth=0, add filtered sensor-data deletion, provide explicit and safe recovery choices for incomplete setups and interrupted wipes, preserve existing IDs when requested, scope asset and sensor lookups correctly, and support both FlexMeasures 0.33 job_id responses and newer job responses.

I manually verified the complete workflow on FlexMeasures 0.33, including resume, wipe recovery, incomplete-structure repair, legacy-name choices, scoped lookup, recreation cancellation, and cleanup. The full automated suite also passes: 220 tests, Black, Flake8, compilation, and git diff --check.

I found no remaining blockers. From my review, the PR is ready.

Building A asset graph:

Image

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
The pre-commit workflow reordered the HEMS workflow test imports, causing CI to fail because the generated formatting diff was not committed.

Apply the deterministic import order so the repository remains unchanged when the full pre-commit suite runs.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants