Skip to content

Commit

Permalink
docs: improve documentation of flexmeasures (#756)
Browse files Browse the repository at this point in the history
* updated tutorial

Signed-off-by: Nischay Mamidi <NischayPro@gmail.com>

* added docker-compose steps for postgresql

Signed-off-by: Nischay Mamidi <NischayPro@gmail.com>

---------

Signed-off-by: Nischay Mamidi <NischayPro@gmail.com>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Co-authored-by: Nicolas Höning <nicolas@seita.nl>
  • Loading branch information
Nischay-Pro and nhoening committed Jul 27, 2023
1 parent c146ba6 commit 4a68ba8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
38 changes: 37 additions & 1 deletion documentation/host/data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@ Install

We believe FlexMeasures works with Postgres above version 9 and we ourselves have run it with versions up to 14.

On Unix:
On Linux:

.. code-block:: bash
$ # On Ubuntu and Debian, you can install postgres like this:
$ sudo apt-get install postgresql-12 # replace 12 with the version available in your packages
$ pip install psycopg2-binary
$ # On Fedora, you can install postgres like this:
$ sudo dnf install postgresql postgresql-server
$ sudo postgresql-setup --initdb --unit postgresql
On Windows:

Expand All @@ -45,6 +50,35 @@ On Windows:
* ``conda install psycopg2``


Using Docker Compose:


Alternatively, you can use Docker Compose to run a postgres database. Use can use the following ``docker-compose.yml`` as a starting point:


.. code-block:: yaml
version: '3.7'
services:
postgres:
image: postgres:latest
restart: always
environment:
POSTGRES_USER: flexmeasures
POSTGRES_PASSWORD: this-is-your-secret-choice
POSTGRES_DB: flexmeasures
ports:
- 5432:5432
volumes:
- ./postgres-data:/var/lib/postgresql/data
network_mode: host
To run this, simply type ``docker-compose up`` in the directory where you saved the ``docker-compose.yml`` file. Pass the ``-d`` flag to run it in the background.

This will create a postgres database in a directory ``postgres-data`` in your current working directory. You can change the password and database name to your liking. You can also change the port mapping to e.g. ``5433:5432`` if you already have a postgres database running on your host machine.


Make sure postgres represents datetimes in UTC timezone
^^^^^^^^^^^^^

Expand All @@ -66,6 +100,8 @@ Then restart the postgres server.
$ sudo service postgresql restart
.. note:: If you are using Docker to run postgres, the ``timezone`` setting is already set to ``UTC`` by default.


Create "flexmeasures" and "flexmeasures_test" databases and users
^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion documentation/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ The platform operator of FlexMeasures can be an Aggregator.
:caption: Tutorials
:maxdepth: 1

tut/installation
tut/toy-example-from-scratch
tut/toy-example-expanded
tut/installation
tut/posting_data
tut/forecasting_scheduling
tut/building_uis
Expand Down
2 changes: 1 addition & 1 deletion documentation/tut/toy-example-from-scratch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Install Flexmeasures and the database
$ docker run --rm --name flexmeasures-tutorial-fm --env SQLALCHEMY_DATABASE_URI=postgresql://postgres:fm-db-passwd@flexmeasures-tutorial-db:5432/flexmeasures-db --env SECRET_KEY=notsecret --env FLASK_ENV=development --env LOGGING_LEVEL=INFO -d --network=flexmeasures_network -p 5000:5000 lfenergy/flexmeasures
$ docker exec flexmeasures-tutorial-fm bash -c "flexmeasures db upgrade"
.. 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.
.. 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. Alternatively, you can add yourself to the ``docker`` group. See `here <https://docs.docker.com/engine/install/linux-postinstall/>`_ for more information.

Now - what's *very important* to remember is this: The rest of this tutorial will happen *inside* the ``flexmeasures-tutorial-fm`` container! This is how you hop inside the container and run a terminal there:

Expand Down

0 comments on commit 4a68ba8

Please sign in to comment.