Skip to content

Feat/schedule resolution#1857

Merged
Flix6x merged 25 commits intomainfrom
feat/schedule-resolution
Feb 4, 2026
Merged

Feat/schedule resolution#1857
Flix6x merged 25 commits intomainfrom
feat/schedule-resolution

Conversation

@Flix6x
Copy link
Copy Markdown
Contributor

@Flix6x Flix6x commented Dec 9, 2025

Description

  • Support setting a resolution when triggering a schedule via the API
  • A similar --resolution option in the CLI for flexmeasures add schedule
  • Fix conversion of the storage efficiency per device (which is defined relative to the resolution of each device's power sensor) to the scheduling resolution (which defaulted to the smallest non-zero resolution amongst the devices)
  • Fix resampling the scheduling results to the resolution of the power sensor of each device
  • Added changelog item in documentation/changelog.rst

Look & Feel

...

How to test

  • Added coverage for sensor API in test_trigger_and_get_schedule
  • Added coverage for asset API in test_asset_trigger_and_get_schedule

Further Improvements

  • Needs to be followed up with a flexmeasures-client PR

Related Items

Closes #1856.

...

@Flix6x Flix6x added this to the 0.31.0 milestone Dec 9, 2025
@Flix6x Flix6x self-assigned this Dec 9, 2025
@Flix6x Flix6x added enhancement New feature or request API Scheduling labels Dec 9, 2025
@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented Dec 9, 2025

Documentation build overview

📚 flexmeasures | 🛠️ Build #31254451 | 📁 Comparing a028b6c against latest (36400dd)


🔍 Preview build

Show files changed (4 files in total): 📝 4 modified | ➕ 0 added | ➖ 0 deleted
File Status
changelog.html 📝 modified
_autosummary/flexmeasures.api.v3_0.assets.html 📝 modified
_autosummary/flexmeasures.api.v3_0.sensors.html 📝 modified
api/v3_0.html 📝 modified

@Flix6x Flix6x requested a review from nhoening January 6, 2026 00:15
Signed-off-by: F.N. Claessen <[email protected]>
Copy link
Copy Markdown
Contributor

@nhoening nhoening left a comment

Choose a reason for hiding this comment

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

I tested this in the CLI via the first tutorial and ran into a problem.

I used docker compose and ran the script, only with --resolution PT2H added to the flexmeasures add schedule command.

The function ensure_prices_are_not_empty() complained (see below), I suspect because get_continuous_series_sensor_or_quantity() cannot get the data if the resolution passed to it doesn't match the sensor resolution? I did not pursue that until the end (TimedBelied.search()).

 File "/usr/local/lib/python3.12/dist-packages/flexmeasures/cli/data_add.py", line 1444, in add_schedule
    success = make_schedule(
              ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/flexmeasures/data/services/scheduling.py", line 584, in make_schedule
    consumption_schedule: SchedulerOutputType = scheduler.compute()
                                                ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/flexmeasures/data/models/planning/storage.py", line 1318, in compute
    ) = self._prepare(skip_validation=skip_validation)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/flexmeasures/data/models/planning/storage.py", line 187, in _prepare
    ensure_prices_are_not_empty(up_deviation_prices, consumption_price)
  File "/usr/local/lib/python3.12/dist-packages/flexmeasures/data/models/planning/utils.py", line 96, in ensure_prices_are_not_empty
    raise UnknownPricesException(error_message)
flexmeasures.data.models.planning.exceptions.UnknownPricesException: Prices unknown for planning window. (sensor 1)

Copilot AI added a commit that referenced this pull request Feb 2, 2026
- Add dedicated 'Scheduling resolution' section in forecasting_scheduling.rst
  explaining when to use custom resolution, how it works, limitations, and defaults
- Add note in API scheduling section with example of resolution field usage
- Update toy-example-from-scratch.rst to reference new scheduling_resolution section
- Add practical demonstration in run-tutorial2-in-docker.sh showing PT1H resolution
- Add cross-reference note in features/scheduling.rst describing_flexibility section
- Include DOCUMENTATION_CHANGES.md summarizing all changes and rationale

This addresses the need to document the new --resolution parameter added in PR #1857
and helps users understand when and how to use it, along with important limitations
around sensor resolution compatibility and data source resolution requirements.
@Flix6x Flix6x reopened this Feb 3, 2026
@Flix6x
Copy link
Copy Markdown
Contributor Author

Flix6x commented Feb 3, 2026

@nhoening I fixed the issue in timely-beliefs; the tutorial should now work with a 2-hour resolution. Please verify.

@Flix6x Flix6x merged commit 12a42ee into main Feb 4, 2026
8 checks passed
@Flix6x Flix6x deleted the feat/schedule-resolution branch February 4, 2026 09:38
Flix6x added a commit that referenced this pull request Feb 6, 2026
…ne (#1945)

* feat: add API support for resolution field

Signed-off-by: F.N. Claessen <[email protected]>

* feat: test whether new field makes it into the job kwargs

Signed-off-by: F.N. Claessen <[email protected]>

* feat: pass on the resolution to make_schedule

Signed-off-by: F.N. Claessen <[email protected]>

* fix: resample from scheduling resolution to sensor resolution

Signed-off-by: F.N. Claessen <[email protected]>

* fix: convert storage efficiency from sensor resolution to scheduling resolution

Signed-off-by: F.N. Claessen <[email protected]>

* feat: only allow resolutions that are a multiple of the sensor resolution

Signed-off-by: F.N. Claessen <[email protected]>

* feat: cover new feature in a test

Signed-off-by: F.N. Claessen <[email protected]>

* fix: optional arguments

Signed-off-by: F.N. Claessen <[email protected]>

* fix: only use coarser resolution for tests where the targets are still on the tick

Signed-off-by: F.N. Claessen <[email protected]>

* fix: don't resample the instantaneous soc sensor data

Signed-off-by: F.N. Claessen <[email protected]>

* fix: don't resample instantaneous power sensor data

Signed-off-by: F.N. Claessen <[email protected]>

* docs: changelog entry

Signed-off-by: F.N. Claessen <[email protected]>

* feat: add CLI support, too

Signed-off-by: F.N. Claessen <[email protected]>

* fix: pass on resolution when converting from a simultaneous scheduling job to sequential scheduling jobs

Signed-off-by: F.N. Claessen <[email protected]>

* refactor: test util now allows overriding to a custom scheduling resolution

Signed-off-by: F.N. Claessen <[email protected]>

* fix: support overriding the scheduling resolution in case of multi-asset scheduling

Signed-off-by: F.N. Claessen <[email protected]>

* feat: test multi-asset scheduling with a custom resolution

Signed-off-by: F.N. Claessen <[email protected]>

* fix: Python3.9 compatibility

Signed-off-by: F.N. Claessen <[email protected]>

* Revert "fix: Python3.9 compatibility"

This reverts commit e252d27.

Signed-off-by: F.N. Claessen <[email protected]>

* fix: Python3.9 compatibility (now staged the correct revision)

Signed-off-by: F.N. Claessen <[email protected]>

* Initial plan

* docs: Add comprehensive documentation for --resolution parameter

- Add dedicated 'Scheduling resolution' section in forecasting_scheduling.rst
  explaining when to use custom resolution, how it works, limitations, and defaults
- Add note in API scheduling section with example of resolution field usage
- Update toy-example-from-scratch.rst to reference new scheduling_resolution section
- Add practical demonstration in run-tutorial2-in-docker.sh showing PT1H resolution
- Add cross-reference note in features/scheduling.rst describing_flexibility section
- Include DOCUMENTATION_CHANGES.md summarizing all changes and rationale

This addresses the need to document the new --resolution parameter added in PR #1857
and helps users understand when and how to use it, along with important limitations
around sensor resolution compatibility and data source resolution requirements.

* fix: Pass timedelta directly to TimedBelief.search() for architectural consistency

- Remove unnecessary to_offset().freqstr conversion in get_power_values()
- Maintain type consistency with get_series_from_quantity_or_sensor()
- Let timely-beliefs framework handle resolution conversions internally
- Respects domain model: resolution is a timedelta in Scheduler domain
- No behavioral change: TimedBelief.search() already supports timedelta
- Improves code clarity and maintains separation of concerns

This fix ensures consistent resolution handling across the scheduling
pipeline and respects the timely-beliefs framework boundaries.

Fixes the 'Prices unknown for planning window' issue when scheduling
resolution differs from sensor event_resolution by ensuring proper
type handling throughout the data retrieval pipeline.

* Fix resolution parameter bug and add tutorial documentation

Co-authored-by: Flix6x <[email protected]>

* fix: update timely-beliefs to deal with downsampling against non-midnight origins

Signed-off-by: F.N. Claessen <[email protected]>

* ci: update test-specialist to enforce running tests

Signed-off-by: F.N. Claessen <[email protected]>

* ci: update test-specialist adding commit discipline for test changes

Signed-off-by: F.N. Claessen <[email protected]>

* ci: update review-lead to enforce running tests and adding commit discipline

Signed-off-by: F.N. Claessen <[email protected]>

* ci: update architecture-domain-specialist to enforce running tests

Signed-off-by: F.N. Claessen <[email protected]>

* ci: update other specialist, too

Signed-off-by: F.N. Claessen <[email protected]>

* revert: not a fix to the assigned issue

Signed-off-by: F.N. Claessen <[email protected]>

* docs: remove note in at first glance odd place

Signed-off-by: F.N. Claessen <[email protected]>

* Revert "docs: remove note in at first glance odd place"; on second thought, it does look like a good place to reference the resolution

This reverts commit 16f73a3.

* dev: comment out untested changed to tutorial 2

Signed-off-by: F.N. Claessen <[email protected]>

---------

Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Co-authored-by: F.N. Claessen <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Flix6x <[email protected]>
Co-authored-by: F.N. Claessen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scheduling with custom resolution

2 participants