Skip to content

Development

Setup

pip install -e ".[dev]"          # pytest, build, twine, ruff
pip install -e ".[docs]"         # mkdocs-material, mkdocstrings

Tests

pytest -m "not swat"                        # unit tests on synthetic fixtures
SWATPY_TEST_DOWNLOAD=1 pytest -m swat -rs   # real SWAT2012 project (+ runs on linux x86_64)
pytest tests/test_readout.py -k monthly     # a single test / subset

The unit tests use a small synthetic SWAT2012 model and synthetic output files in tests/data, generated by tests/data/make_fixtures.py. The swat tests download the rev 637 demo project and Linux executable from SWATdata into ~/.cache/swatpy-tests.

Lint

ruff check .   # E9/F63/F7/F82 only (syntax, undefined names)

Docs

The documentation lives in docs/ and is built with MkDocs:

mkdocs serve             # live preview at http://127.0.0.1:8000
mkdocs build --strict    # build into site/

The API reference is generated from docstrings by mkdocstrings. On push to master the .github/workflows/docs.yml workflow builds the site and deploys it to GitHub Pages.

Releasing

Releases are published to PyPI with trusted publishing from GitHub Actions (.github/workflows/publish.yml):

  1. set __version__ in swatpy/__init__.py and the version in CITATION.cff;
  2. create a GitHub release with the tag v<version>, which builds, checks and uploads to PyPI;
  3. a manual run of the workflow uploads to TestPyPI instead.