Skip to content

Commit

Permalink
document demo and play mode; small fixes/improvements in demo mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nhoening committed Apr 19, 2021
1 parent 2c6d543 commit 945fbbb
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 3 deletions.
9 changes: 8 additions & 1 deletion documentation/configuration.rst
Expand Up @@ -26,11 +26,14 @@ Level above which log messages are added to the log file. See the ``logging`` pa

Default: ``logging.WARNING``


.. _modes-config:

FLEXMEASURES_MODE
^^^^^^^^^^^^^^^^^

The mode in which FlexMeasures is being run, e.g. "demo" or "play".
This is used to turn on certain extra behaviours.
This is used to turn on certain extra behaviours, see :ref:`modes-dev` for details.

Default: ``""``

Expand Down Expand Up @@ -369,13 +372,17 @@ Default: ``None``
Demonstrations
--------------

.. _demo-credentials-config:

FLEXMEASURES_PUBLIC_DEMO_CREDENTIALS
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

When ``FLEXMEASURES_MODE=demo``\ , this can hold login credentials (demo user email and password, e.g. ``("demo at seita.nl", "flexdemo")``\ ), so anyone can log in and try out the platform.

Default: ``None``

.. _demo-year-config:

FLEXMEASURES_DEMO_YEAR
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
41 changes: 41 additions & 0 deletions documentation/dev/modes.rst
@@ -0,0 +1,41 @@
.. _modes-dev:

Modes
============

FlexMeasures can be run in specific modes (see the :ref:`modes-config` config setting).
This is useful for certain special situations. Two are supported out of the box and we document here
how FlexMeasures behaves differently in these modes.

Demo
-------

In this mode, the server is assumed to be used as a demonstration tool. Most of the following adaptations therefore happen in the UI.

- [Data] Demo data is often from an older source, and it's a hassle to change the year to the current year. FlexMeasures allows to set :ref:`demo-year-config` and when in ``demo`` mode, the current year will be translated to that year in the background.
- [UI] Logged-in users can view queues on the demo server (usually only admins can do that)
- [UI] Demo servers often display login credentials, so visitors can try out functionality. Use the :ref:`demo-credentials-config` config setting to do this.
- [UI] The dashboard shows all non-empty asset groups, instead of only the ones for the current user.
- [UI] The analytics page mocks confidence intervals around power, price and weather data, so that the demo data doesn't need to have them.
- [UI] The portfolio page mocks flexibility numbers and a mocked control action.

Play
------

In this mode, the server is assumed to be used to run simulations.

Big features
^^^^^^^^^^^^^

- [Data] Allows overwriting existing data when saving data to the database.
- [API] The inferred recording time of incoming data is immediately after the event took place, rather than the actual time at which the server received the data.
- [API] Posting price or weather data does not trigger forecasting jobs.
- [API] The ``restoreData`` endpoint is registered, enabling database resets through the API.
- [API] When posting weather data for a new location, a new weather sensor is automatically created, instead of returning the nearest available weather sensor to post data to.

Small features
^^^^^^^^^^^^^^^

- [API] Posted UDI events are not enforced to be consecutive.
- [API] Names in ``GetConnectionResponse`` are the connections' unique database names rather than their display names (this feature is planned to be deprecated).
- [UI] The dashboard plot showing the latest power value is not enforced to lie in the past (in case of simulating future values).
1 change: 1 addition & 0 deletions documentation/index.rst
Expand Up @@ -85,6 +85,7 @@ The platform operator of FlexMeasures can be an Aggregator.
dev/api
dev/ci
dev/plugins
dev/modes

.. toctree::
:caption: Integrations
Expand Down
3 changes: 3 additions & 0 deletions flexmeasures/data/services/time_series.py
Expand Up @@ -257,6 +257,9 @@ def convert_query_window_for_demo(
end = (query_window[-1] + timedelta(days=1)).replace(year=demo_year)
else:
end = query_window[-1]

if start >= end:

This comment has been minimized.

Copy link
@Flix6x

Flix6x Apr 19, 2021

Contributor

>

start, end = (end, start)
return start, end


Expand Down
6 changes: 5 additions & 1 deletion flexmeasures/ui/utils/plotting_utils.py
Expand Up @@ -564,7 +564,11 @@ def get_latest_power_as_plot(asset: Asset, small: bool = False) -> Tuple[str, st
First returned string is the measurement time, second string is the html string."""

if current_app.config.get("FLEXMEASURES_MODE", "") == "demo":
before = server_now().replace(year=2015)
demo_year = current_app.config.get("FLEXMEASURES_DEMO_YEAR", None)
if demo_year is None:
before = server_now()
else:
before = server_now().replace(year=demo_year)
elif current_app.config.get("FLEXMEASURES_MODE", "") == "play":
before = None # type:ignore
else:
Expand Down
2 changes: 1 addition & 1 deletion flexmeasures/ui/utils/view_utils.py
Expand Up @@ -131,7 +131,7 @@ def set_time_range_for_session():
.astimezone(time_utils.get_timezone())
)

# Our demo server works only with the current year's data
# Our demo server's UI should only work with the current year's data
if current_app.config.get("FLEXMEASURES_MODE", "") == "demo":
session["start_time"] = session["start_time"].replace(year=datetime.now().year)
session["end_time"] = session["end_time"].replace(year=datetime.now().year)
Expand Down

1 comment on commit 945fbbb

@Flix6x
Copy link
Contributor

@Flix6x Flix6x commented on 945fbbb Apr 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good.

Please sign in to comment.