Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor scheduler interface - API and inner logic #537

Merged
merged 44 commits into from Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
274ca78
Add flex_model & flex_context in API endpoint; refactor design for Sc…
nhoening Nov 23, 2022
814ad4a
add new schema modules
nhoening Nov 23, 2022
59419e2
Merge branch 'main' into refactor-scheduler-interface
nhoening Nov 23, 2022
0cb4928
include two other flex context params in solver test
nhoening Nov 23, 2022
610ab2a
Merge branch 'main' into refactor-scheduler-interface
nhoening Dec 10, 2022
2f77285
also support deprecated flex_context parameters, and align spelling o…
nhoening Dec 10, 2022
6042cd5
correctly handle flex-model validation errors when they come up in th…
nhoening Dec 10, 2022
d3911a1
merge
nhoening Dec 10, 2022
c0cc2ce
changelog: add deprecation warnings and mentions this PR
nhoening Dec 12, 2022
7d6abb7
fix internal link
nhoening Dec 12, 2022
140e5be
move flex-model and flex-context docs to notation module; small fixes…
nhoening Dec 12, 2022
af00092
deprecate soc-sensor-id field, store soc states on the asset attribut…
nhoening Dec 13, 2022
b87de99
check (and potentially fill in defaults for) soc_min and soc_max befo…
nhoening Dec 13, 2022
6ac5a76
make add schedule command work with our refactored scheduling code, s…
nhoening Dec 13, 2022
f3cf7a2
rename the CLI command as it only represents storage right now (and w…
nhoening Dec 13, 2022
8bb30f9
More thorough checks for passed soc-values in StorageScheduler, leads…
nhoening Dec 14, 2022
11633f8
doc improvements from review
nhoening Dec 14, 2022
b784c56
Change parameter names for flex model and context which come through …
nhoening Dec 16, 2022
7321019
Make `flexmeasures add schedule` a subgroup (#557)
Flix6x Dec 16, 2022
4bf8e55
add one missing documentation improvement from review
nhoening Dec 16, 2022
7231c18
make sure hyphens are used in flex-model to the outside world (API, CLI)
nhoening Dec 21, 2022
f667106
smaller review items, mostly documentation
nhoening Dec 21, 2022
e06e235
remove soc checks which added interpretation (should be part of anoth…
nhoening Dec 25, 2022
403660c
fixes to notation docs
nhoening Dec 25, 2022
0da3b30
make sure scheduling tests work on empty queues, with new fixture
nhoening Dec 25, 2022
20de523
remove two tests for previously removed util function
nhoening Dec 25, 2022
c9bc738
batch of small review comments
nhoening Dec 25, 2022
4965575
make get_data_source_info a class method of Scheduler
nhoening Dec 25, 2022
fcbfad9
small simplification of get_data_source_for_job
nhoening Dec 25, 2022
d562bf1
Merge branch 'main' into refactor-scheduler-interface
nhoening Dec 25, 2022
1b8ded8
specify min/max inclusiveness of roundtrip-efficiency parameter
nhoening Dec 25, 2022
f1bc3cb
Merge branch 'refactor-scheduler-interface' of github.com:FlexMeasure…
nhoening Dec 25, 2022
a32b819
create_scheduling_jobs accepts both object and ID
nhoening Dec 27, 2022
07a21a3
fix type hinting
nhoening Dec 27, 2022
0ef19fa
API changelog & flex config introduction
nhoening Dec 27, 2022
480fac9
two missing fixes
nhoening Dec 27, 2022
658f8b5
remove line about previously undocumented & now depreacated line
nhoening Dec 27, 2022
b053994
Deprecation headers for old fields that moved to flex-model and flex-…
Flix6x Dec 27, 2022
c2b7ffa
refactor where the code lives that builds device equality constraints…
nhoening Dec 28, 2022
39b82d7
change a sentence in notation
nhoening Dec 28, 2022
6b26a32
Rename inspection to deserialization
Flix6x Dec 29, 2022
c8bd10a
Fix DummyScheduler in documentation
Flix6x Dec 29, 2022
9ad7c3d
Simplify imports for plugin developers (also facilitates renaming the…
Flix6x Dec 29, 2022
37b56f0
Resolve circular import
Flix6x Dec 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 1 addition & 4 deletions flexmeasures/api/v3_0/sensors.py
Expand Up @@ -276,7 +276,7 @@ def trigger_schedule( # noqa: C901

In this request, you can describe:

- the schedule's main (start, unit, prior)
- the schedule's main features (when does it start, what unit should it report, prior to what time can we assume knowledge)
- the flexibility model for the sensor (state and constraint variables, e.g. current state of charge of a battery, or connection capacity)
- the flexibility context which the sensor operates in (other sensors under the same EMS which are relevant, e.g. prices)

Expand Down Expand Up @@ -450,9 +450,6 @@ def trigger_schedule( # noqa: C901
except ValueError as err:
return invalid_flex_config(str(err))

# From here on, we handle IDs again, not objects
scheduler_kwargs.update(sensor_id=scheduler_kwargs.pop("sensor").id)

job = create_scheduling_job(
**scheduler_kwargs,
enqueue=True,
Expand Down
10 changes: 6 additions & 4 deletions flexmeasures/data/services/scheduling.py
Expand Up @@ -29,7 +29,7 @@


def create_scheduling_job(
sensor_id: int,
sensor: [int | Sensor],
nhoening marked this conversation as resolved.
Show resolved Hide resolved
job_id: Optional[str] = None,
enqueue: bool = True,
**scheduler_kwargs,
Expand All @@ -42,11 +42,13 @@ def create_scheduling_job(

As a rule of thumb, keep arguments to the job simple, and deserializable.
"""
# From here on, we handle IDs again, not objects
if isinstance(sensor, Sensor):
sensor = sensor.id

job = Job.create(
make_schedule,
kwargs=dict(
sensor_id=sensor_id, **scheduler_kwargs
), # TODO: we're passing sensor objects in flex_context. Passing IDs would be cleaner to avoid potential db sessions confusion.
kwargs=dict(sensor_id=sensor, **scheduler_kwargs),
id=job_id,
connection=current_app.queues["scheduling"].connection,
ttl=int(
Expand Down
4 changes: 2 additions & 2 deletions flexmeasures/data/tests/test_scheduling_jobs.py
Expand Up @@ -35,7 +35,7 @@ def test_scheduling_a_battery(db, app, add_battery_assets, setup_test_data):
) # Make sure the scheduler data source isn't there

job = create_scheduling_job(
sensor_id=battery.id,
sensor=battery,
start=start,
end=end,
belief_time=start,
Expand Down Expand Up @@ -109,7 +109,7 @@ def test_assigning_custom_scheduler(db, app, add_battery_assets, is_path: bool):
resolution = timedelta(minutes=15)

job = create_scheduling_job(
sensor_id=battery.id,
sensor=battery,
start=start,
end=end,
belief_time=start,
Expand Down
2 changes: 1 addition & 1 deletion flexmeasures/data/tests/test_scheduling_jobs_fresh_db.py
Expand Up @@ -38,7 +38,7 @@ def test_scheduling_a_charging_station(
) # Make sure the scheduler data source isn't there

job = create_scheduling_job(
sensor_id=charging_station.id,
sensor=charging_station,
start=start,
end=end,
belief_time=start,
Expand Down