Skip to content

Stop creating new toy assets when restarting the docker-compose stack #2013

@Flix6x

Description

@Flix6x

Current situation

  1. User runs docker compose up using the docker-compose.yml: toy account, toy user and toy assets created. Assets:
    • NL transmission zone
    • toy-building
    • toy-battery
    • toy-solar
  2. User reruns docker compose up: toy account and toy user already exist (not recreated), but some of the toy assets are recreated. Assets:
    • NL transmission zone
    • toy-building (x2)
    • toy-battery (x2)
    • toy-solar (x2)
  3. Et cetera. Assets after N down -> up:
    • NL transmission zone
    • toy-building (x N)
    • toy-battery (x N)
    • toy-solar (x N)

Ideas

  1. Adjust cli.data_add.add_toy_account to prevent new toy assets being created if they exist already.
  2. Adjust docker-compose.yml to not rerun flexmeasures add toy-account --name 'Docker Toy Account' when that account already exists.
    if ! flexmeasures list accounts | grep -q "Docker Toy Account"; then
        flexmeasures add toy-account --name 'Docker Toy Account'
    fi
    
  3. Adjust docker-compose.yml to not rerun flexmeasures add toy-account --name 'Docker Toy Account' after the first time docker compose up ran.
    if [ ! -f /app/instance/.toy_account_created ]; then
        flexmeasures add toy-account --name 'Docker Toy Account'
        touch /app/instance/.toy_account_created
    fi
    

Considerations

From a user perspective, I like the third option best. Why? Because I imagine that as a first-time user it's nice that you get a toy site to play around with, but once you set up your own site you will probably delete the toy site/account and it would feel really weird when it reappears the next time you run docker compose up. Even better might be to do the opposite, by having the marker file (named .create-toy-account) in the repo, and removing it the first time docker compose up runs. That way it's slightly nicer in the sense that a) the marker file does not need to live indefinitely on the user's device, and b) having the file explicitly in our repo better signals this design pattern, where temporary marker files are used for first-time use, and this can even be clearly documented inside the file itself.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions