Skip to content

Support saving state-of-charge schedules to sensors with % unit#1996

Open
Copilot wants to merge 15 commits intomainfrom
copilot/support-saving-soc-schedules
Open

Support saving state-of-charge schedules to sensors with % unit#1996
Copilot wants to merge 15 commits intomainfrom
copilot/support-saving-soc-schedules

Conversation

Copy link
Contributor

Copilot AI commented Mar 3, 2026

  • The StorageScheduler couldn't save SOC schedules to sensors with % unit because convert_units needs a capacity argument for the MWh→% conversion, and that capacity was never extracted from the flex model.
  • Add missing field description in scheduling.rst
  • Changelog entry
  • Added tests:
    • test_save_state_of_charge_percent_sensor
    • test_save_state_of_charge_percent_sensor_skipped_when_zero_soc_max

Please note that copilot kept updating the PR description with every iteration, see https://github.com/orgs/community/discussions/187027.

@read-the-docs-community
Copy link

read-the-docs-community bot commented Mar 3, 2026

Documentation build overview

📚 flexmeasures | 🛠️ Build #31659463 | 📁 Comparing a9f1253 against latest (b1a7022)


🔍 Preview build

Show files changed (7 files in total): 📝 7 modified | ➕ 0 added | ➖ 0 deleted
File Status
changelog.html 📝 modified
genindex.html 📝 modified
_autodoc/STATE_OF_CHARGE.html 📝 modified
_autosummary/flexmeasures.data.models.planning.storage.html 📝 modified
_autosummary/flexmeasures.data.schemas.sensors.html 📝 modified
api/v3_0.html 📝 modified
features/scheduling.html 📝 modified

Copilot AI and others added 2 commits March 3, 2026 16:57
- Add _build_soc_schedule() helper in StorageScheduler to handle % unit
  conversion using soc-max as capacity; skip with warning if soc-max is
  missing or zero
- Add additional_sensor_units parameter to VariableQuantityField to allow
  sensors with extra units (e.g. %) beyond to_unit-compatible ones
- Allow % sensors for state_of_charge field in StorageFlexModelSchema and
  DBStorageFlexModelSchema
- Fix _validate_energy_fields in DBStorageFlexModelSchema to accept %
  sensors for state_of_charge
- Update STATE_OF_CHARGE metadata description to document % unit support
- Add test_save_state_of_charge_percent_sensor covering both save and skip
- Add changelog entry

Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
- Make _build_soc_schedule a @staticmethod (no instance state used)
- Add defensive isinstance(soc_max, Sensor) guard against future
  VariableQuantityField usage for soc-max
- Improve additional_sensor_units docstring to clarify intended use

Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Copilot AI changed the title [WIP] Support saving state-of-charge schedules to sensors with '%' unit Support saving state-of-charge schedules to sensors with % unit Mar 3, 2026
Copy link
Contributor

@Flix6x Flix6x left a comment

Choose a reason for hiding this comment

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

Besides the review comments, I also noticed:

  • the openapi-specs.json where not updated, which surprises me given the update to a flex-model field description
  • the agent environment setup failed on some error (copilot-setup-steps.yml)
  • no agent instructions were updated with lessons learned
  • the sessions shows the coordinator ran, but it does not look like its recommendations were fully followed up on

- Fix PR number in changelog (2002 → 1996)
- Regenerate openapi-specs.json to include updated STATE_OF_CHARGE
  field description
- Redesign test_save_state_of_charge_percent_sensor to verify specific
  SOC percentage values: starting full with 50% storage efficiency gives
  idle-decay pattern 100→50→25→12.5%, plus soc-minima at t+60min=8%
  forces charging and confirms the conversion math
- Split into two focused test functions: positive case with value
  assertions and a separate skip-when-zero-soc-max case
- Drop redundant resolution=timedelta(0) from search_beliefs() call
  (sensor has event_resolution=0, so no resampling occurs either way)

Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 3, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh pr list --head copilot/support-saving-soc-schedules (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@Flix6x
Copy link
Contributor

Flix6x commented Mar 4, 2026

@copilot

  • Evaluate whether the coordinator agent's previous recommendations have been fully followed up on.
  • Rerun the coordinator agent and follow up on its recommendations.
  • Make sure the test-specialist can run tests relevant to this PR using copilot-setup-steps.yml to set up its environment.
  • Evaluate why I needed to commit 830d0e4 and update relevant agent instructions accordingly.

Copilot AI added 3 commits March 4, 2026 10:23
Context:
- PR #1996 ran generate-openapi-specs hook in agent dev environment
- Hook introduced two unintended regressions alongside the intentional change:
  1. Version field changed from '0.31.0' to '0.1.dev4' (setuptools_scm
     generated a dev version because the agent checkout lacked full tag history)
  2. 'Asia/Brunei' was dropped from the timezone enum (pytz version mismatch)
- Repo owner had to manually commit a fix (830d0e4) to revert these regressions

Change:
- Added 'generate-openapi-specs Hook: Known Regressions' section to the
  Pre-commit Hooks checklist with the two known regression types, a concrete
  diff-inspection workflow, and a cross-reference in the Domain Knowledge entry
…able

Context:
- PR #1996 showed the Environment Setup section only pointed to
  .github/workflows/copilot-setup-steps.yml without providing concrete
  commands an agent can run — agents had to open and interpret the workflow
  YAML themselves, which led to incomplete or incorrect setup

Change:
- Added 'Concrete setup steps for the agent environment' block with the
  four commands that translate the workflow: apt-get dependencies,
  make install-for-test, environment variable exports, and pre-commit install
- Added a note clarifying that PostgreSQL/Redis are started automatically
  by the GitHub Actions runner; local developers must start them manually
…terns

Context:
- PR #1996 coordinator review (not captured in agent instructions) recommended:
  1. Making _build_soc_schedule a @staticmethod (commit e03e91a)
  2. Adding isinstance(soc_max, Sensor) guard against future VariableQuantityField
     usage (commit e03e91a)
  3. These patterns apply broadly to Scheduler and DataGenerator subclasses
- Agent files were not updated after the refactor, so the lessons were lost

Change:
- Added '@staticmethod for Methods Without Instance State' pattern under the
  flex-model checklist: when a method doesn't use self/cls, propose @staticmethod
- Added 'Defensive isinstance() Guards for flex-model Fields' pattern: flex-model
  fields using VariableQuantityField can be Sensor or plain value; always guard
  with isinstance(field_value, Sensor) before numeric comparisons
- Extended flex-context checklist with a VariableQuantityField guard item
Copy link
Contributor Author

Copilot AI commented Mar 4, 2026

@copilot

  • Evaluate whether the coordinator agent's previous recommendations have been fully followed up on.
    ...

Done in commits 130fc11d, d68a8be7, and 0fc09422:

  1. Coordinator re-ran and found three gaps that weren't captured after the previous session.

  2. tooling-ci-specialist.md (130fc11d): Added a "generate-openapi-specs Hook: Known Regressions" checklist — the two regression types from commit 830d0e4e (wrong version string from setuptools_scm, dropped timezone from pytz version mismatch) plus a concrete diff-inspection workflow to catch them before committing.

  3. test-specialist.md (d68a8be7): The copilot-setup-steps.yml reference now includes the four concrete bash commands that translate the workflow steps, so agents no longer need to interpret the workflow YAML themselves.

  4. architecture-domain-specialist.md (0fc09422): Captured the two patterns from commit e03e91a that were recommended by the coordinator but never written back to agent instructions — @staticmethod for methods without instance state, and defensive isinstance(field_value, Sensor) guards for VariableQuantityField flex-model fields.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh auth status runc 4ab8.pid /var/run/docker/runtime-runc/mob--log-format y /opt/hostedtoolcache/Python/3.11--systemd-cgroup by/817422a445876grep ntime.v2.task/mo-q 0aa60ca3cf0a6c99-- bash --no�� --noprofile --detach bash by/817422a445876bash by/817422a445876--norc 6adb136505150049--noprofile 2e6ce2ad42cd6ff04fe/log.json (http block)

If you need me to access, download, or install something from one of these locations, you can either:

…ontext

Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Copilot AI changed the title Support saving state-of-charge schedules to sensors with % unit fix: provide PG* defaults in composite action for Copilot agent context Mar 4, 2026
@Flix6x Flix6x changed the title fix: provide PG* defaults in composite action for Copilot agent context Support saving state-of-charge schedules to sensors with % unit Mar 4, 2026
@Flix6x Flix6x marked this pull request as ready for review March 4, 2026 13:12
@Flix6x Flix6x added this to the 0.32 milestone Mar 4, 2026
Flix6x added 5 commits March 4, 2026 14:20
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
…ules' into copilot/support-saving-soc-schedules
Signed-off-by: F.N. Claessen <claessen@seita.nl>
@Flix6x Flix6x requested a review from nhoening March 4, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants