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

feat: save/fetch Reporter as DataSource #751

Merged
merged 90 commits into from Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
6684258
feat: revision to add `attributes` column to the `data_source` table
victorgarcia98 Jun 6, 2023
abfe310
feat: add `attributes` column to the DataSource model
victorgarcia98 Jun 6, 2023
c5fddad
feat: add sensors relationship in DataSource
victorgarcia98 Jun 6, 2023
c2de8fc
fix: make sensors relationship viewonly
victorgarcia98 Jun 20, 2023
a26ed8e
feat: add report_config to Reporter class
victorgarcia98 Jun 6, 2023
d9cef3d
feat: add PandasReporter report and reporter schemas
victorgarcia98 Jun 6, 2023
d2ef590
fix: update fixture by removing beliefs_search_configs and adding inp…
victorgarcia98 Jun 6, 2023
54b5dda
feat: add report config to PandasReporter
victorgarcia98 Jun 6, 2023
8028431
feat: add helper methods to DataSource
victorgarcia98 Jun 23, 2023
364c8ec
Merge branch 'feature/add-attributes-column-data-source' into feature…
victorgarcia98 Jun 23, 2023
fd175d4
fix: modernize AggregatorReporter
victorgarcia98 Jun 23, 2023
4567c23
feat: add attributes hash
victorgarcia98 Jun 26, 2023
773dc9d
feat: add attributes to the function get_or_create_source
victorgarcia98 Jun 26, 2023
4ec5d3e
Merge branch 'feature/reporting/add-attributes-column-data-source' in…
victorgarcia98 Jun 26, 2023
6d632b8
feat: add attribute hash to get_or_create_source
victorgarcia98 Jun 26, 2023
696d363
Merge branch 'feature/reporting/add-attributes-column-data-source' in…
victorgarcia98 Jun 26, 2023
68eae91
feat: save/fetch data generator to/from data source
victorgarcia98 Jun 26, 2023
3049416
refactor: adapt reporters to use new DataGenerator class
victorgarcia98 Jun 26, 2023
76cf197
fix: use default method on load
victorgarcia98 Jun 28, 2023
39f4023
fix: adapt tests of the schemas
victorgarcia98 Jun 27, 2023
d19c2fa
fix: use a DataGenerator with a schema defined
victorgarcia98 Jun 28, 2023
8670d6c
Merge branch 'main' into feature/reporting/add-attributes-column-data…
victorgarcia98 Jun 28, 2023
793ac22
Merge branch 'feature/reporting/add-attributes-column-data-source' in…
victorgarcia98 Jun 28, 2023
c644875
Merge branch 'main' into feature/reporting/add-attributes-column-data…
victorgarcia98 Jun 29, 2023
ef63067
changing backref from "dynamic" to "select"
victorgarcia98 Jun 29, 2023
8ea2702
feat: add hash_attributes static method
victorgarcia98 Jun 29, 2023
e717a4e
fix: use hash_attributes static method
victorgarcia98 Jun 29, 2023
ec3b370
feat: adding attributes_hash to the DataSource unique constraint list
victorgarcia98 Jun 29, 2023
ab4b0ae
fix: add constraint to migration and downgrade
victorgarcia98 Jun 29, 2023
6b3a585
fix: only returning keys from the attributes field
victorgarcia98 Jun 29, 2023
3d373df
Merge remote-tracking branch 'origin/feature/reporting/add-attributes…
victorgarcia98 Jun 29, 2023
8748a3b
Merge branch 'feature/reporting/add-attributes-column-data-source' in…
victorgarcia98 Jun 29, 2023
3a88e00
refactor: rename _inputs_schema to _input_schema
victorgarcia98 Jun 29, 2023
ad9d24b
fix: typing
victorgarcia98 Jun 29, 2023
33d4522
fix: avoid future data leakage
victorgarcia98 Jun 29, 2023
1119c1f
refactor: rename PandasReporterInputConfigSchema to PandasReporterInp…
victorgarcia98 Jun 29, 2023
dc800a4
docs: clarify description of the fake_data mock variable
victorgarcia98 Jun 29, 2023
54b67f7
docs: fix docstring
victorgarcia98 Jul 2, 2023
1c75541
fix: use default value
victorgarcia98 Jul 2, 2023
9211978
fix: allow creating new attributes with the method `set_attributes`
victorgarcia98 Jul 2, 2023
dbf01b6
docs: add changelog entry
victorgarcia98 Jul 2, 2023
95518e0
docs: fix docstring
victorgarcia98 Jul 2, 2023
3cdf91b
fix: use default value
victorgarcia98 Jul 2, 2023
b347cb2
fix: allow creating new attributes with the method `set_attributes`
victorgarcia98 Jul 2, 2023
6c55893
docs: add changelog entry
victorgarcia98 Jul 2, 2023
ba6d14c
Merge branch 'feature/reporting/add-attributes-column-data-source' in…
victorgarcia98 Jul 2, 2023
e565198
fix: add reporters and schedulers into the data_generators attribute …
victorgarcia98 Jul 3, 2023
1b648ad
fix: raise Exceptions instead of returning None
victorgarcia98 Jul 3, 2023
b9c0b3f
fix: move sensor attribute from config to inputs
victorgarcia98 Jul 3, 2023
f239be4
fix: use same structure for data generators and add test
victorgarcia98 Jul 3, 2023
eac2d7c
refactor: use input_resolution instead of resolution
victorgarcia98 Jul 3, 2023
d303801
doc: update schema docstring
victorgarcia98 Jul 3, 2023
2abbeb6
refactor: rename input_resolution to resolution
victorgarcia98 Jul 3, 2023
9f8bd11
fix: remove sensor from config
victorgarcia98 Jul 3, 2023
006661a
docs: add comment
victorgarcia98 Jul 3, 2023
076a653
fix: remove df_output
victorgarcia98 Jul 3, 2023
d493dff
Merge remote-tracking branch 'origin/feature/reporting/save-reporters…
victorgarcia98 Jul 3, 2023
36d3856
fix:. for data in data["data"] haha
victorgarcia98 Jul 3, 2023
6169cd3
doc: add docstring to compute and __init__ in DataGenerator
victorgarcia98 Jul 3, 2023
a695d8b
refactor: rename inputs to input
victorgarcia98 Jul 3, 2023
091283b
fix: removing constructor
victorgarcia98 Jul 3, 2023
52289f6
docs: improve docstring
victorgarcia98 Jul 3, 2023
139b842
Merge branch 'main' into feature/reporting/save-reporters-data-source
victorgarcia98 Jul 6, 2023
5520c73
test: add data to confest
victorgarcia98 Jul 7, 2023
3bb13e2
test: add test_dst_transition
victorgarcia98 Jul 7, 2023
d51fc39
fix: never returning None
victorgarcia98 Jul 7, 2023
e9564d9
test: add test to check timely-beliefs resampling and calling an aggr…
victorgarcia98 Jul 9, 2023
81b6269
Merge remote-tracking branch 'origin/feature/reporting/save-reporters…
victorgarcia98 Jul 9, 2023
132cf46
test: change output sensor id
victorgarcia98 Jul 10, 2023
ff2f478
docs: add docstring to the data_source propert of the class DataGener…
victorgarcia98 Jul 10, 2023
0fc8de2
docs: edit data_source docstring
victorgarcia98 Jul 10, 2023
2c4f8bc
refactor: ranming input_sensors to input_variables
victorgarcia98 Jul 10, 2023
9daa2bb
Merge branch 'main' into feature/reporting/save-reporters-data-source
victorgarcia98 Jul 10, 2023
d6daace
Merge branch 'main' into feature/reporting/save-reporters-data-source
victorgarcia98 Jul 20, 2023
50d0406
Merge branch 'main' into feature/reporting/save-reporters-data-source
victorgarcia98 Aug 2, 2023
4673492
rename input to parameters
victorgarcia98 Aug 2, 2023
0a4e302
Merge branch 'main' into feature/reporting/save-reporters-data-source
victorgarcia98 Aug 3, 2023
c2e37a9
remove unnecessary import
victorgarcia98 Aug 3, 2023
cfc554e
add save_config attribute
victorgarcia98 Aug 3, 2023
18f3b02
Merge branch 'main' into feature/reporting/save-reporters-data-source
victorgarcia98 Aug 3, 2023
b389951
remove leftover comment
victorgarcia98 Aug 3, 2023
59de8ea
add inline comments
victorgarcia98 Aug 3, 2023
abd24d7
Merge remote-tracking branch 'origin/main' into feature/reporting/sav…
victorgarcia98 Aug 3, 2023
c035f40
Merge branch 'main' into feature/reporting/save-reporters-data-source
victorgarcia98 Aug 3, 2023
8470fed
deprecation message for app.reoprters and app.schedulers
victorgarcia98 Aug 3, 2023
a55e661
fix typo
victorgarcia98 Aug 3, 2023
1ed7e5e
use data source created by the data generator
victorgarcia98 Aug 3, 2023
4b676b0
Merge remote-tracking branch 'origin/feature/reporting/save-reporters…
victorgarcia98 Aug 3, 2023
1e8704e
feat: support YAML in `flexmeasures add report` command (#752)
victorgarcia98 Aug 3, 2023
0a38d76
Polish `PandasReporter` schemas (#788)
victorgarcia98 Aug 7, 2023
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
2 changes: 1 addition & 1 deletion ci/run_mypy.sh
@@ -1,7 +1,7 @@
#!/bin/bash
set -e
pip install --upgrade 'mypy>=0.902'
pip install types-pytz types-requests types-Flask types-click types-redis types-tzlocal types-python-dateutil types-setuptools types-tabulate
pip install types-pytz types-requests types-Flask types-click types-redis types-tzlocal types-python-dateutil types-setuptools types-tabulate types-PyYAML
# We are checking python files which have type hints, and leave out bigger issues we made issues for
# * data/scripts: We'll remove legacy code: https://trello.com/c/1wEnHOkK/7-remove-custom-data-scripts
# * data/models and data/services: https://trello.com/c/rGxZ9h2H/540-makequery-call-signature-is-incoherent
Expand Down
2 changes: 2 additions & 0 deletions documentation/changelog.rst
Expand Up @@ -25,6 +25,8 @@ New features
* Added API endpoints `/sensors/<id>` for fetching a single sensor, `/sensors` (POST) for adding a sensor, `/sensors/<id>` (PATCH) for updating a sensor and `/sensors/<id>` (DELETE) for deleting a sensor. [see `PR #759 <https://www.github.com/FlexMeasures/flexmeasures/pull/759>`_] and [see `PR #767 <https://www.github.com/FlexMeasures/flexmeasures/pull/767>`_] and [see `PR #773 <https://www.github.com/FlexMeasures/flexmeasures/pull/773>`_] and [see `PR #784 <https://www.github.com/FlexMeasures/flexmeasures/pull/784>`_]
* The CLI now allows to set lists and dicts as asset & sensor attributes (formerly only single values) [see `PR #762 <https://www.github.com/FlexMeasures/flexmeasures/pull/762>`_]
* Add `ProcessScheduler` class to optimize the starting time of processes one of the policies developed (INFLEXIBLE, SHIFTABLE and BREAKABLE), accessible via the CLI command `flexmeasures add schedule for-process` [see `PR #729 <https://www.github.com/FlexMeasures/flexmeasures/pull/729>`_ and `PR #768 <https://www.github.com/FlexMeasures/flexmeasures/pull/768>`_]
* Users will be able to see (e.g. in the UI) exactly which reporter created the report (saved as sensor data), and hosts will be able to identify exactly which configuration was used to create a given report [see `PR #751 <https://www.github.com/FlexMeasures/flexmeasures/pull/751>`_, `PR #752 <https://www.github.com/FlexMeasures/flexmeasures/pull/752>`_ and `PR #788 <https://www.github.com/FlexMeasures/flexmeasures/pull/788>`_]
* The CLI `flexmeasures add report` now allows passing `config` and `parameters` in YAML format as files or editable via the system's default editor [see `PR #788 <https://www.github.com/FlexMeasures/flexmeasures/pull/788>`_]

Bugfixes
-----------
Expand Down
1 change: 1 addition & 0 deletions documentation/cli/change_log.rst
Expand Up @@ -9,6 +9,7 @@ since v0.15.0 | July XX, 2023

* Allow deleting multiple sensors with a single call to ``flexmeasures delete sensor`` by passing the ``--id`` option multiple times.
* Add ``flexmeasures add schedule for-process`` to create a new process schedule for a given power sensor.
* Add support for describing ``config`` and ``parameters`` in YAML for the command ``flexmeasures add report``, editable in user's code editor using the flags ``--edit-config`` or ``--edit-parameters``.
* Add ``--kind process`` option to create the asset and sensors for the ``ProcessScheduler`` tutorial.

since v0.14.1 | June XX, 2023
Expand Down
23 changes: 21 additions & 2 deletions flexmeasures/app.py
Expand Up @@ -5,6 +5,7 @@
from __future__ import annotations

import time
from copy import copy
import os
from pathlib import Path
from datetime import date
Expand Down Expand Up @@ -123,8 +124,26 @@ def create( # noqa C901
from flexmeasures.utils.coding_utils import get_classes_module
from flexmeasures.data.models import reporting, planning

app.reporters = get_classes_module("flexmeasures.data.models", reporting.Reporter)
app.schedulers = get_classes_module("flexmeasures.data.models", planning.Scheduler)
reporters = get_classes_module("flexmeasures.data.models", reporting.Reporter)
schedulers = get_classes_module("flexmeasures.data.models", planning.Scheduler)

app.data_generators = dict()
app.data_generators["reporter"] = copy(
reporters
) # use copy to avoid mutating app.reporters
app.data_generators["scheduler"] = schedulers

# deprecation of app.reporters
app.reporters = reporters
app.schedulers = schedulers

def get_reporters():
app.logger.warning(
'`app.reporters` is deprecated. Use `app.data_generators["reporter"]` instead.'
)
return app.data_generators["reporter"]

setattr(app, "reporters", property(get_reporters))

# add auth policy

Expand Down