Skip to content

Issue 393 RESTful scheduling api#396

Merged
Flix6x merged 34 commits intomainfrom
Issue-393_RESTful_scheduling_API
Mar 24, 2022
Merged

Issue 393 RESTful scheduling api#396
Flix6x merged 34 commits intomainfrom
Issue-393_RESTful_scheduling_API

Conversation

@Flix6x
Copy link
Copy Markdown
Contributor

@Flix6x Flix6x commented Mar 22, 2022

Implement RESTful endpoints for triggering scheduling jobs and fetching schedules. Deprecates the UDI Event ID in favor of letting the server create a Universally Unique Identifier (UUID), which is returned when a schedule is triggered. The UUID is used as a job id and can be used to fetch the exact schedule whose creation was triggered (for a limited time, similarly to what we had before with UDI Event IDs).

  • Implement /api/v3_0/sensors/<id>/schedules/trigger [POST], which creates a scheduling job and returns the job's ID. Note that by default, rq makes a random UUID. The endpoint replaces postUdiEvent.
  • Implement /api/v3_0/sensors/<id>/schedules/<uuid> [GET], which checks job status and returns the most recent schedule based on the job's kwargs["start"]. Not guaranteed to give the same result when queried at a later time, unless we also look for the schedule based on the job's kwargs["belief_time"]. In fact, the ID will not be known after a week, because we only store it temporarily in redis. Afterwards, the schedule can still be retrieved through /api/v3_0/sensors/<id>/data [GET], with appropriate filter values for "start", "prior" and "source". The endpoint replaces getDeviceMessage.
  • Optional "type" field, ignored, OR add changelog entry hint to stop including a message type when switching to the new endpoints.
  • Support optional "source" in /sensors/data [GET]. Moved to Support optional "source" in /sensors/data [GET] #398.
  • Support passing a custom uuid, which may be a UDI event ID. Moved to Support passing a custom uuid to /schedules/trigger [POST] #399.

closes #393
closes #397

Flix6x added 9 commits March 22, 2022 11:34
…dules/trigger and /sensors/<id>/schedules/<job_id>

Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
…in the endpoint documentation

Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
…g flexibility states together with triggering schedules

Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
@Flix6x Flix6x added documentation Improvements or additions to documentation API Scheduling labels Mar 22, 2022
@Flix6x Flix6x self-assigned this Mar 22, 2022
Flix6x added 4 commits March 22, 2022 15:09
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Mar 22, 2022

Pull Request Test Coverage Report for Build 2036804269

  • 84 of 117 (71.79%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 68.466%

Changes Missing Coverage Covered Lines Changed/Added Lines %
flexmeasures/api/v3_0/sensors.py 84 117 71.79%
Totals Coverage Status
Change from base Build 2029588426: 0.04%
Covered Lines: 6998
Relevant Lines: 9690

💛 - Coveralls

@Flix6x Flix6x requested a review from nhoening March 22, 2022 14:36
@Flix6x Flix6x marked this pull request as ready for review March 22, 2022 14:50
Signed-off-by: F.N. Claessen <felix@seita.nl>
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.

Approve of the scope of this PR. Only minor comments I believe.

As for the type field, I guess I'd not even introduce it in our API v3.

Comment thread documentation/tut/posting_data.rst
Comment thread flexmeasures/api/v3_0/sensors.py Outdated
Comment thread flexmeasures/api/v3_0/sensors.py
Comment thread flexmeasures/api/v3_0/sensors.py Outdated
Comment thread flexmeasures/api/v3_0/sensors.py
Comment thread flexmeasures/api/v3_0/sensors.py Outdated
Comment thread flexmeasures/api/v3_0/sensors.py Outdated
Comment thread flexmeasures/api/v3_0/tests/test_sensor_schedules.py
Flix6x added 8 commits March 24, 2022 13:51
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
…or roundtrip efficiency; also test whether the soc-min and soc-max fields get through validation

Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
# Conflicts:
#	documentation/api/change_log.rst
#	documentation/api/v3_0.rst
Signed-off-by: F.N. Claessen <felix@seita.nl>
Flix6x added 8 commits March 24, 2022 16:32
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
…ing a schedule

Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
@nhoening
Copy link
Copy Markdown
Contributor

Addendum: I believe you should also change the --from parameter to --start on the front page of the documentation.

Flix6x added 4 commits March 24, 2022 22:08
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
…ing to the new endpoints

Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
@Flix6x Flix6x merged commit 9054fec into main Mar 24, 2022
@Flix6x Flix6x deleted the Issue-393_RESTful_scheduling_API branch March 24, 2022 22:09
@Flix6x Flix6x added this to the 0.9.0 milestone Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API documentation Improvements or additions to documentation Scheduling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update tutorial for Forecasting & scheduling RESTful scheduling API

3 participants