Python tooling development
1 Set up the developer environment
1.1 Running the tests
In order to run tests on Ribasim Python execute
pixi run test-ribasim-python
1.2 Updating example notebooks
Make sure to run Clear All Outputs
on the notebook before committing.
1.3 Prepare model input
Before running the Julia tests or building binaries, example model input needs to created. This is done by running the following:
pixi run generate-testmodels
This places example model input files under ./generated_testmodels/
. If the example models change, re-run this script.
1.4 Setup Visual Studio Code (optional)
Install the Python, ruff and autoDocstring extensions.
1.5 Linting
To run our linting suite locally, execute:
pixi run lint
2 Code maintenance
For new features new tests have to be added. To monitor how much of the code is covered by the tests we use Codecov. For a simple overview of the local code coverage run
pixi shell
pytest --cov=ribasim tests/
from python/ribasim
. For an extensive overview in html
format use
pixi shell
pytest --cov=ribasim --cov-report=html tests/
which creates a folder htmlcov
in the working directory. To see te contents open htmlcov/index.html
in a browser.
The code coverage of pushed branches can be seen here.