Skip to content

Make HEMS report generation dockerizable + fix false-negative on async uploads#216

Merged
Flix6x merged 2 commits into
mainfrom
qa/hems-report-cli-override
Jul 1, 2026
Merged

Make HEMS report generation dockerizable + fix false-negative on async uploads#216
Flix6x merged 2 commits into
mainfrom
qa/hems-report-cli-override

Conversation

@Flix6x

@Flix6x Flix6x commented Jul 1, 2026

Copy link
Copy Markdown
Member

Summary

Joint effort with FlexMeasures/flexmeasures#2260, which adds a manually-triggered QA workflow that runs the HEMS tutorial against a dockerized FlexMeasures stack as part of release testing. Getting that working surfaced two independent problems in this repo, both fixed here (and both part of this PR's diff):

  • CLI-command override for report generation. examples/HEMS/reporters.py shells out to a bare flexmeasures on PATH, which only works if that CLI is installed locally and configured against the same database as the server being scripted against (per the existing three-terminal docs/HEMS.rst instructions). That breaks down when the server runs elsewhere, e.g. inside a Docker Compose service. Added FLEXMEASURES_CLI_CMD and FLEXMEASURES_CLI_CONFIG_DIR env vars so callers can point report generation at a flexmeasures process running anywhere (e.g. docker compose exec -T server flexmeasures), with file paths translated accordingly. Documented in docs/HEMS.rst.

  • Bugfix: file upload falsely treated 202 Accepted as an error. FlexMeasuresClient._post_sensor_data_file() hardcoded response.status != 200 as its failure condition, but sensors/<id>/data/upload can legitimately return 202 Accepted when the server queues the upload as an async job. This silently broke the HEMS tutorial's very first data-loading step, so it never got anywhere near forecasting, scheduling, or reporting. Fixed to accept any 2xx status, matching the convention check_for_status() already uses elsewhere in this client. Added a regression test (test_post_sensor_data_with_file_accepted).

These two PRs should land together: FlexMeasures/flexmeasures#2260's QA workflow won't successfully complete its HEMS step until this PR is merged.

Test plan

  • uv run poe test — 183 passed
  • black --check / flake8 clean on changed files
  • Ran the full HEMS tutorial (HEMS_setup.py) locally against a dockerized FlexMeasures server, using FLEXMEASURES_CLI_CMD/FLEXMEASURES_CLI_CONFIG_DIR pointed at docker compose exec -T server flexmeasures: all 6 simulation steps completed, all data uploads succeeded (no more false "202" failures), all report-generation calls (AggregatorReporter, PandasReporter x2 per step) succeeded via the dockerized CLI, ending in "HEMS Tutorial completed successfully!" with zero reporter/upload failures.

🤖 Generated with Claude Code

Flix6x and others added 2 commits July 1, 2026 23:25
The HEMS tutorial's report-generation step shells out to a bare
`flexmeasures` on PATH, which only works if that CLI is configured
against the same database as the server being scripted against.
Add FLEXMEASURES_CLI_CMD and FLEXMEASURES_CLI_CONFIG_DIR env vars so
callers can point report generation at a `flexmeasures` running
elsewhere, e.g. inside a Docker Compose service
(`docker compose exec -T server flexmeasures`), which unblocks
running this step as part of automated release QA.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
_post_sensor_data_file() hardcoded `status != 200` as the failure
condition, but the sensors/<id>/data/upload endpoint can legitimately
return 202 Accepted when the server processes the upload as an async
job. This made every file upload look like a failure whenever the
server queues the work, which is what silently broke the HEMS
tutorial's data-loading step (PART 2) before it ever reached
forecasting/scheduling/reporting.

Match check_for_status()'s existing convention elsewhere in this
client: accept any 2xx, only raise on a genuine non-2xx status.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coveralls

coveralls commented Jul 1, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 28550912284

Coverage remained the same at 96.359%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 1 of 1 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: 714
Covered Lines: 688
Line Coverage: 96.36%
Coverage Strength: 2.89 hits per line

💛 - Coveralls

@Flix6x Flix6x merged commit 8dc8a73 into main Jul 1, 2026
11 of 12 checks passed
@Flix6x Flix6x deleted the qa/hems-report-cli-override branch July 1, 2026 22:11
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.

2 participants