Skip to content

Commit

Permalink
Improve from scratch tutorial for UI views (#443)
Browse files Browse the repository at this point in the history
* better description of the UI part in the from-scratch tutorial, plus help if sudo is needed for Docker

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* allow access tokens to be passed as env vars as well

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* changelog entry

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* spell it 'macOS' as it is the preferred spelling

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
  • Loading branch information
nhoening committed Jun 16, 2022
1 parent e495c51 commit a436797
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions documentation/changelog.rst
Expand Up @@ -14,6 +14,7 @@ Bugfixes

Infrastructure / Support
----------------------
* Allow access tokens to be passed as env vars as well [see `PR #443 <http://www.github.com/FlexMeasures/flexmeasures/pull/443>`_]

v0.10.1 | June XX, 2022
===========================
Expand Down
2 changes: 2 additions & 0 deletions documentation/host/docker.rst
Expand Up @@ -57,6 +57,8 @@ Browsing ``http://localhost:5000`` should work now and ask you to log in.
Of course, you might not have created a user. You can use ``docker exec -it <flexmeasures-container-name> bash`` to go inside the container and use the :ref:`cli` to create everything you need.


.. _docker_configuration:

Configuration and customization
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
13 changes: 9 additions & 4 deletions documentation/tut/toy-example-from-scratch.rst
Expand Up @@ -65,6 +65,8 @@ Install Flexmeasures and the database
$ docker stop flexmeasures-tutorial-db
$ docker stop flexmeasures-tutorial-fm
.. note:: A tip on Linux/macOS ― You might have the ``docker`` command, but need `sudo` rights to execute it. ``alias docker='sudo docker'`` enables you to still run this tutorial.


.. tab:: On your PC

Expand All @@ -87,7 +89,7 @@ Install Flexmeasures and the database
$ export SQLALCHEMY_DATABASE_URI="postgresql://flexmeasures-user:fm-db-passwd@localhost:5432/flexmeasures-db" SECRET_KEY=notsecret LOGGING_LEVEL="INFO" DEBUG=0
$ flexmeasures db upgrade
.. note:: When installing with ``pip``, on some platforms problems might come up (e.g. MacOs, Windows). One reason is that FlexMeasures requires some libraries with lots of C code support (e.g. Numpy). One way out is to use Docker, which uses a prepared Linux image, so it'll definitely work.
.. note:: When installing with ``pip``, on some platforms problems might come up (e.g. macOS, Windows). One reason is that FlexMeasures requires some libraries with lots of C code support (e.g. Numpy). One way out is to use Docker, which uses a prepared Linux image, so it'll definitely work.


Add some structural data
Expand Down Expand Up @@ -158,11 +160,14 @@ Yes, that is quite a large battery :)

.. note:: Obviously, you can use the ``flexmeasures`` command to create your own, custom account and assets. See :ref:`cli`. And to create, edit or read asset data via the API, see :ref:`v3_0`.

We can also look at the battery asset in the UI of FlexMeasures (start FlexMeasures with ``flexmeasures run``, username is "toy-user@flexmeasures.io", password is "toy-password"):
We can also look at the battery asset in the UI of FlexMeasures (in Docker, the FlexMeasures web server already runs, on your PC you can start it with ``flexmeasures run``).
Visit `http://localhost:5000/assets <http://localhost:5000/assets>`_ (username is "toy-user@flexmeasures.io", password is "toy-password") and select "toy-battery":

.. image:: https://github.com/FlexMeasures/screenshots/raw/main/tut/toy-schedule/asset-view.png
:align: center

.. note:: You won't see the map tiles, as we have not configured the :ref:`MAPBOX_ACCESS_TOKEN`. If you have one, you can configure it via ``flexmeasures.cfg`` (for Docker, see :ref:`docker_configuration`).


Add some price data
---------------------------------------
Expand Down Expand Up @@ -241,7 +246,7 @@ Let's look at the price data we just loaded:
Again, we can also view these prices in the FlexMeasures UI:
Again, we can also view these prices in the `FlexMeasures UI <http://localhost:5000/sensors/3/>`_:

.. image:: https://github.com/FlexMeasures/screenshots/raw/main/tut/toy-schedule/sensor-data-prices.png
:align: center
Expand Down Expand Up @@ -297,7 +302,7 @@ Great. Let's see what we made:
Here, negative values denote output from the grid, so that's when the battery gets charged.

We can also look at the charging schedule in the FlexMeasures UI (reachable via the asset page for the battery):
We can also look at the charging schedule in the `FlexMeasures UI <http://localhost:5000/sensors/2/>`_ (reachable via the asset page for the battery):

.. image:: https://github.com/FlexMeasures/screenshots/raw/main/tut/toy-schedule/sensor-data-charging.png
:align: center
Expand Down
3 changes: 2 additions & 1 deletion flexmeasures/utils/config_utils.py
Expand Up @@ -155,9 +155,10 @@ def read_env_vars(app: Flask):
At the moment, these are:
- All required variables
- Logging settings
- access tokens
- plugins (handled in plugin utils)
"""
for var in required + ["LOGGING_LEVEL"]:
for var in required + ["LOGGING_LEVEL", "MAPBOX_ACCESS_TOKEN", "SENTRY_SDN"]:
app.config[var] = os.getenv(var, app.config.get(var, None))
# DEBUG in env can come in as a string ("True") so make sure we don't trip here
app.config["DEBUG"] = int(bool(os.getenv("DEBUG", app.config.get("DEBUG", False))))
Expand Down

0 comments on commit a436797

Please sign in to comment.