Skip to content

Commit

Permalink
Merge branch 'main' into 433-patch-sensor-stricter-auth
Browse files Browse the repository at this point in the history
  • Loading branch information
nhoening committed Aug 7, 2023
2 parents 59c0d3b + 552a0e9 commit c2cb648
Show file tree
Hide file tree
Showing 27 changed files with 1,514 additions and 654 deletions.
2 changes: 1 addition & 1 deletion ci/run_mypy.sh
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
12 changes: 7 additions & 5 deletions documentation/dev/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ Alternatively, the CBC solver can be installed with:
$ apt-get install coinor-cbc
Alternatively, HiGHS solver can be installed with pip:

.. code-block:: bash
$ pip install highspy
Configuration
^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -143,6 +138,13 @@ Otherwise, you need to add some other user first. Here is how we add an admin:
(The account-id you need in the 2nd command is printed by the 1st)


.. note::

If you are on Windows, then running & developing FlexMeasures will not work 100%. For instance, the queueing only works if you install rq-win (https://github.com/michaelbrooks/rq-win) manually and the make tooling is difficult to get to work as well.
We recommend to use the Windows Sub-system for Linux (https://learn.microsoft.com/en-us/windows/wsl/install) or work via Docker-compose (https://flexmeasures.readthedocs.io/en/latest/dev/docker-compose.html).



Logfile
--------

Expand Down
23 changes: 21 additions & 2 deletions flexmeasures/app.py
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit c2cb648

Please sign in to comment.