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

Group sensors by (generic) asset #157

Merged
merged 16 commits into from Aug 25, 2021
Merged

Conversation

create-issue-branch[bot]
Copy link
Contributor

closes #155

Flix6x and others added 6 commits July 20, 2021 13:38
…ericAsset.

Check out the revision files for details on how to set up user defined table contents while migrating.
…d add corresponding Marshmallow schemas to validate input parameters
@Flix6x Flix6x self-assigned this Jul 27, 2021
@Flix6x
Copy link
Contributor

Flix6x commented Jul 27, 2021

This PR sets up two new tables to be used for our ongoing migration to a new data model, with corresponding classes GenericAsset and GenericAssetType. It serves to let Sensors be grouped by a GenericAsset.

Assets, Markets and WeatherStations should already have a corresponding Sensor (since database revision a528c3c81506). For each of these, a GenericAsset will be set up, grouping only a single Sensor. Also for any new Sensor (i.e. without a corresponding Asset, Market or WeatherStation), a new GenericAsset will be set up. To group new Sensors under a single GenericAsset, see the upgrade instruction below.

Upgrading

Verify that the current revision is 04f0e2d2924a (head) before checking out this branch:

flexmeasures db current
git fetch
git checkout issue-155-Group_sensors_by_generic_asset

Upgrading without making custom Sensor groups

In case you only have Sensors with a corresponding Asset, Market or WeatherStation, run:

flexmeasures db upgrade
flexmeasures db current

And verify that the current revision is b6d49ed7cceb.

Upgrading while making custom Sensor grouping

In case you have Sensors without a corresponding Asset, Market or WeatherStation, and you wish to group some of these together, upgrade in two separate steps and check the new database tables at each step.
For example, to group Sensors 10, 11 and 12 under a new GenericAsset named "incineration line 1", of a new GenericAssetType named "waste power plant":

flexmeasures db upgrade +1 -x '{"name": "waste power plant"}'
flexmeasures db upgrade +1 -x '{"asset_type_name": "waste power plant", "sensor_ids": [10, 11, 12], "asset_name": "incineration line 1"}'

For more options (such as specifying multiple groups and/or owners), see the revision files 565e092a6c5e and b6d49ed7cceb.

@Flix6x Flix6x marked this pull request as ready for review July 27, 2021 18:05
@Flix6x Flix6x requested a review from nhoening July 27, 2021 18:07
Copy link
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.

This looks excellent, great to see you're mastering Alembic this well.

I have a few possible improvements to suggest, mostly small stuff. I'll also push my own addition, so that the new dev-classes can be visualized in our util script.

flexmeasures/data/scripts/cli_tasks/data_add.py Outdated Show resolved Hide resolved
flexmeasures/data/models/generic_assets.py Show resolved Hide resolved
flexmeasures/data/models/generic_assets.py Outdated Show resolved Hide resolved
flexmeasures/data/models/time_series.py Outdated Show resolved Hide resolved
flexmeasures/data/schemas/generic_assets.py Outdated Show resolved Hide resolved
flexmeasures/api/v1/tests/conftest.py Outdated Show resolved Hide resolved
@nhoening
Copy link
Contributor

nhoening commented Aug 2, 2021

I think this also warrants a changelog entry under Infrastructure/Support, on the topic of experimental integration with timely beliefs.

@Flix6x Flix6x requested a review from nhoening August 24, 2021 12:17
@Flix6x Flix6x merged commit 0ad268d into main Aug 25, 2021
@Flix6x Flix6x deleted the issue-155-Group_sensors_by_generic_asset branch August 25, 2021 20:43
@Flix6x Flix6x added this to In progress in Data model based on timely beliefs via automation Sep 1, 2021
@Flix6x Flix6x added this to the 0.6.0 milestone Sep 1, 2021
@Flix6x Flix6x moved this from In progress to Done in Data model based on timely beliefs Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Group sensors by (generic) asset
2 participants