From ff0b3b88b04fd1896dc66491cc0cde60830745b8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Mar 2026 18:07:11 +0000 Subject: [PATCH 1/5] Initial plan From 18c2e89e9e09ab46f2723cb235be228bc5becb2e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Mar 2026 18:12:14 +0000 Subject: [PATCH 2/5] Add marker file to prevent duplicate toy assets on docker compose restart Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com> --- docker-compose.yml | 7 ++++++- documentation/dev/docker-compose.rst | 4 ++-- flexmeasures-instance/.create-toy-account-on-first-run | 8 ++++++++ flexmeasures-instance/.gitignore | 7 +++++++ flexmeasures-instance/requirements.txt | 2 ++ 5 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 flexmeasures-instance/.create-toy-account-on-first-run create mode 100644 flexmeasures-instance/.gitignore create mode 100644 flexmeasures-instance/requirements.txt diff --git a/docker-compose.yml b/docker-compose.yml index 36004d2067..65c8b79160 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -85,7 +85,12 @@ services: - | pip install --break-system-packages -r /usr/var/flexmeasures-instance/requirements.txt flexmeasures db upgrade - flexmeasures add toy-account --name 'Docker Toy Account' + if [ -f /usr/var/flexmeasures-instance/.create-toy-account-on-first-run ]; then + flexmeasures add toy-account --name 'Docker Toy Account' + rm /usr/var/flexmeasures-instance/.create-toy-account-on-first-run + else + echo "Not creating toy account (already happened once). You can run 'flexmeasures add toy-account' any time." + fi gunicorn --bind 0.0.0.0:5000 --worker-tmp-dir /dev/shm --workers 2 --threads 4 wsgi:application worker: build: diff --git a/documentation/dev/docker-compose.rst b/documentation/dev/docker-compose.rst index af5878bf6f..8b15cf389b 100644 --- a/documentation/dev/docker-compose.rst +++ b/documentation/dev/docker-compose.rst @@ -72,7 +72,7 @@ In case your configuration loads FlexMeasures plugins that have additional depen Data ------- -The postgres database is a test database with toy data filled in when the flexmeasures container starts. +The postgres database is a test database with toy data filled in when the flexmeasures container starts for the first time. You could also connect it to some other database (on your PC, in the cloud), by setting a different ``SQLALCHEMY_DATABASE_URI`` in the config. The database within the ``dev-db`` postgres container resides in ``/var/lib/postgresql/data``, which we map the local path ``./docker-compose-data/dev-db`` iso as developer you can have persistence for your data across re-building the compose stack. @@ -90,7 +90,7 @@ Seeing it work: Running the toy tutorial A good way to see if these containers work well together, and maybe to inspire how to use them for your own purposes, is the :ref:`tut_toy_schedule`. -The `flexmeasures-server` container already creates the toy account when it starts (see its initial command). We'll now walk through the rest of the toy tutorial, with one twist at the end, when we create the battery schedule. +The `flexmeasures-server` container creates the toy account only the first time it starts (controlled by the ``flexmeasures-instance/.create-toy-account-on-first-run`` file, which is deleted after the first run). We'll now walk through the rest of the toy tutorial, with one twist at the end, when we create the battery schedule. Let's go into the `flexmeasures-worker` container: diff --git a/flexmeasures-instance/.create-toy-account-on-first-run b/flexmeasures-instance/.create-toy-account-on-first-run new file mode 100644 index 0000000000..1c97ca1f6e --- /dev/null +++ b/flexmeasures-instance/.create-toy-account-on-first-run @@ -0,0 +1,8 @@ +# This file controls whether the toy account is created when starting the Docker Compose stack. +# +# The first time you run `docker compose up`, the toy account (with user and assets) is created +# and this file is deleted, so that the toy account is not re-created on subsequent runs. +# +# If you want to re-create the toy account, you can: +# - Place this file back in this directory, or +# - Run `flexmeasures add toy-account` manually. diff --git a/flexmeasures-instance/.gitignore b/flexmeasures-instance/.gitignore new file mode 100644 index 0000000000..e6fe852bd8 --- /dev/null +++ b/flexmeasures-instance/.gitignore @@ -0,0 +1,7 @@ +# Ignore everything in this directory by default +* + +# But keep these files that are tracked by the repository +!.gitignore +!.create-toy-account-on-first-run +!requirements.txt diff --git a/flexmeasures-instance/requirements.txt b/flexmeasures-instance/requirements.txt new file mode 100644 index 0000000000..3648618661 --- /dev/null +++ b/flexmeasures-instance/requirements.txt @@ -0,0 +1,2 @@ +# Add your plugin dependencies here. +# They will be installed each time you run `docker compose up`. From 0b69a9cef151d444897f3e35cced51933fd74b98 Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Thu, 12 Mar 2026 10:07:07 +0100 Subject: [PATCH 3/5] docs: properly place the changelog entry of PR #1993 Signed-off-by: F.N. Claessen --- documentation/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/changelog.rst b/documentation/changelog.rst index 0890c4d01a..6c08f1c232 100644 --- a/documentation/changelog.rst +++ b/documentation/changelog.rst @@ -2,7 +2,6 @@ ********************** FlexMeasures Changelog ********************** -* Support fetching a schedule in a different unit still compatible to the sensor unit [see `PR #1993 `_] v0.32.0 | April XX, 2026 @@ -10,6 +9,7 @@ v0.32.0 | April XX, 2026 New features ------------- +* Support fetching a schedule in a different unit still compatible to the sensor unit [see `PR #1993 `_] * Support saving state-of-charge schedules to sensors with ``"%"`` unit, using the ``soc-max`` flex-model field as the capacity for unit conversion [see `PR #1996 `_] Infrastructure / Support From f88ff177c471e6858534487fd8d78f6d902660fd Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Thu, 12 Mar 2026 10:08:09 +0100 Subject: [PATCH 4/5] docs: changelog entry Signed-off-by: F.N. Claessen --- documentation/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation/changelog.rst b/documentation/changelog.rst index 6c08f1c232..4e5f8315a8 100644 --- a/documentation/changelog.rst +++ b/documentation/changelog.rst @@ -14,6 +14,7 @@ New features Infrastructure / Support ---------------------- +* Stop creating new toy assets when restarting the docker-compose stack [see `PR #2018 `_] * Make the test environment used by agents and by the test workflow identical [see `PR #1998 `_] From bae24ca066ce4b5c7dbd08a992efeab300fb4415 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 12:14:18 +0000 Subject: [PATCH 5/5] Flip marker file logic: create .toy-account-created on first run instead of deleting marker file Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com> --- .gitignore | 1 + docker-compose.yml | 4 ++-- documentation/dev/docker-compose.rst | 2 +- flexmeasures-instance/.create-toy-account-on-first-run | 8 -------- flexmeasures-instance/.gitignore | 7 ------- flexmeasures-instance/requirements.txt | 2 -- 6 files changed, 4 insertions(+), 20 deletions(-) delete mode 100644 flexmeasures-instance/.create-toy-account-on-first-run delete mode 100644 flexmeasures-instance/.gitignore delete mode 100644 flexmeasures-instance/requirements.txt diff --git a/.gitignore b/.gitignore index 9a0227b07a..99258ba876 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,7 @@ logs/ *.dump iframe_figures/ /docker-compose-data +/flexmeasures-instance # Ignore all forecasting artifacts (models, predictions, etc.) flexmeasures/data/models/forecasting/**/artifacts/ diff --git a/docker-compose.yml b/docker-compose.yml index 65c8b79160..8b1a88f5bf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -85,9 +85,9 @@ services: - | pip install --break-system-packages -r /usr/var/flexmeasures-instance/requirements.txt flexmeasures db upgrade - if [ -f /usr/var/flexmeasures-instance/.create-toy-account-on-first-run ]; then + if [ ! -f /usr/var/flexmeasures-instance/.toy-account-created ]; then flexmeasures add toy-account --name 'Docker Toy Account' - rm /usr/var/flexmeasures-instance/.create-toy-account-on-first-run + touch /usr/var/flexmeasures-instance/.toy-account-created else echo "Not creating toy account (already happened once). You can run 'flexmeasures add toy-account' any time." fi diff --git a/documentation/dev/docker-compose.rst b/documentation/dev/docker-compose.rst index 8b15cf389b..936b843d59 100644 --- a/documentation/dev/docker-compose.rst +++ b/documentation/dev/docker-compose.rst @@ -90,7 +90,7 @@ Seeing it work: Running the toy tutorial A good way to see if these containers work well together, and maybe to inspire how to use them for your own purposes, is the :ref:`tut_toy_schedule`. -The `flexmeasures-server` container creates the toy account only the first time it starts (controlled by the ``flexmeasures-instance/.create-toy-account-on-first-run`` file, which is deleted after the first run). We'll now walk through the rest of the toy tutorial, with one twist at the end, when we create the battery schedule. +The `flexmeasures-server` container creates the toy account only the first time it starts (signalled by the ``flexmeasures-instance/.toy-account-created`` file, which is created after the first run). We'll now walk through the rest of the toy tutorial, with one twist at the end, when we create the battery schedule. Let's go into the `flexmeasures-worker` container: diff --git a/flexmeasures-instance/.create-toy-account-on-first-run b/flexmeasures-instance/.create-toy-account-on-first-run deleted file mode 100644 index 1c97ca1f6e..0000000000 --- a/flexmeasures-instance/.create-toy-account-on-first-run +++ /dev/null @@ -1,8 +0,0 @@ -# This file controls whether the toy account is created when starting the Docker Compose stack. -# -# The first time you run `docker compose up`, the toy account (with user and assets) is created -# and this file is deleted, so that the toy account is not re-created on subsequent runs. -# -# If you want to re-create the toy account, you can: -# - Place this file back in this directory, or -# - Run `flexmeasures add toy-account` manually. diff --git a/flexmeasures-instance/.gitignore b/flexmeasures-instance/.gitignore deleted file mode 100644 index e6fe852bd8..0000000000 --- a/flexmeasures-instance/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -# Ignore everything in this directory by default -* - -# But keep these files that are tracked by the repository -!.gitignore -!.create-toy-account-on-first-run -!requirements.txt diff --git a/flexmeasures-instance/requirements.txt b/flexmeasures-instance/requirements.txt deleted file mode 100644 index 3648618661..0000000000 --- a/flexmeasures-instance/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -# Add your plugin dependencies here. -# They will be installed each time you run `docker compose up`.