Developing
Setting up a development environment using Docker
Note
I'm using JetBrain's PyCharm IDE for local development, which has builtin support for Git and Docker. Therefor some steps or information below may or may not match your own development stack.
-
Install Docker on your system. E.g. how-to for Ubuntu and consider Docker rootless.
-
Clone DSMR-reader repository from GitHub:
git clone <link to your fork>
cd dsmr-reader/
- Symlink Compose/ev files required (or just copy them):
# Either symlink
ln -s provisioning/container/compose.dev.yml compose.yml
ln -s provisioning/container/dev.env compose.env
# Or copy
cp provisioning/container/compose.dev.yml compose.yml
cp provisioning/container/dev.env compose.env
- Try running Docker (compose):
# This should build all the containers for local development
docker-compose up -d
- Containers built? See if this command works:
docker exec -it dev-dsmr-app poetry run /app/src/manage.py check
# Expected output: "System check identified no issues (0 silenced)"
- When using PyCharm, you can add a new Interpreter using Docker Compose. Just select
dev-dsmr-appand set/opt/venv/bin/pythonas interpreter path. It should now map all dependencies used/installed in the container.
Running DSMR-reader locally
When running it with the default Docker compose config, the Django Development Server application will be accessible at:
Any Python code changes you make will cause the Django Development Server to reload itself automatically.
Translations
- Update the code and add translatable strings.
- Run
makemessagesto extract those strings:
docker compose exec dev-dsmr-app poetry run /app/src/manage.py makemessages -l nl
- Open
dsmr_frontend/locale/en/LC_MESSAGES/django.powith PO Editor or a similar tool and translate the new strings. - After translation, run
compilemessagesto compile the PO-translations into the MO-files:
docker compose exec dev-dsmr-app poetry run /app/src/manage.py compilemessage
Code style
docker compose exec dev-dsmr-app poetry run black .
docker compose exec dev-dsmr-app poetry run flake8 -v
Tests
docker compose exec -e DJANGO_SETTINGS_MODULE=dsmrreader.config.test dev-dsmr-app poetry run pytest
The -e DJANGO_SETTINGS_MODULE=dsmrreader.config.test part is important, as some tests may fail otherwise.
Other stuff
There is some more to it, such as tests and documentation. If you ever need to work on those, just see how similar stuff works in the project. Or ask for more information.