Developer Guide
Quick start¶
Thanks for contributing! 🙏 Below you can find an overview of the commands to get you up and running quickly.
First clone the repository from GitHub
git clone <GITHUB-REPO>and install the package locally in editable mode (-e):
cd aiida-epw
pip install -e .The “default” approach to developing is to install the development extras in your current environment:
pip install -e .[pre-commit,tests,docs]🔧 Pre-commit
To make sure your changes adhere to our formatting/linting preferences and commit-message convention, install the pre-commit hooks:
pre-commit installThey will then run on every git commit.
You can also run them on e.g. all files using:
pre-commit run -aDrop the -a option in case you only want to run on staged files.
🧪 Tests
You can run all tests in the tests directory with pytest:
pytestOr select the test module:
pytest tests/parsers/test_pw.pySee the pytest documentation for more information.
📚 Documentation
We use MyST as our documentation framework.
Go into the docs directory and start the documentation server with:
myst startand open the documentation in your browser via the link shown. Every time you save a file, the corresponding documentation page is updated automatically!
A GitHub action is set up to automatically deploy the documentation to GitHub Pages. See the corresponding GitHub Pages documentation for the steps required.
uv is a Python package and project manager.
See the documentation on how to install uv.
🔧 Pre-commit
To make sure your changes adhere to our formatting/linting preferences and commit-message convention, install the pre-commit hooks:
uvx pre-commit installThey will then run on every git commit.
You can also run them on e.g. all files using:
uvx pre-commit run -aDrop the -a option in case you only want to run on staged files.
🧪 Tests
You can run all tests in the tests directory with pytest:
uv run pytestOr select the test module:
uv run pytest tests/parsers/test_pw.pySee the pytest documentation for more information.
📚 Documentation
We use MyST as our documentation framework.
Go into the docs directory and start the documentation server with:
myst startand open the documentation in your browser via the link shown. Every time you save a file, the corresponding documentation page is updated automatically!
A GitHub action is set up to automatically deploy the documentation to GitHub Pages. See the corresponding GitHub Pages documentation for the steps required.
You can use Hatch to run development tools in isolated environments. To see a table of the available environments and their scripts, run:
hatch env show🔧 Pre-commit
To make sure your changes adhere to our formatting/linting preferences and commit-message convention, install the pre-commit hooks:
hatch run pre-commit:installThey will then run on every git commit.
You can also run them on e.g. all files using:
hatch run pre-commit:run -aDrop the -a option in case you only want to run on staged files.
🧪 Tests
You can run all tests in the tests directory using:
hatch testOr select the test module:
hatch test tests/parsers/test_pw.pyYou can also run the tests for a specific Python version with the -py option:
hatch test -py 3.11Or all supported Python versions with --all:
hatch test --allSee the Hatch documentation for more information.
📚 Documentation
We use MyST as our documentation framework. Start the documentation server with:
hatch run docs:serveand open the documentation in your browser via the link shown. Every time you save a file, the corresponding documentation page is updated automatically!
A GitHub action is set up to automatically deploy the documentation to GitHub Pages. See the corresponding GitHub Pages documentation for the steps required.
Pre-commit rules¶
From the extensive Ruff ruleset, we ignore the following globally:
| Code | Rule | Rationale / Note |
|---|---|---|
TRY003 | raise-vanilla-args | Formatting warning/exception messages beforehand makes the code less readable, for a minor benefit in readability of the exception. |
EM101 | raw | Same as TRY003 |
EM102 | f | Same as TRY003 |
PLR2004 | magic | We have a lot of “magic values” to compare with in scientific code; naming them all would reduce readability for little benefit. |
FBT002 | boolean | We understand the concept, but adhering to this rule is not a small change in syntax; disable for now. |
TID252 | relative-imports | We don’t mind relative imports; as long as you don’t go up a level, they’re more readable (less verbose). |
And the following rules for the files in the tests directory:
| Code | Rule | Rationale / Note |
|---|---|---|
INP001 | implicit | When tests are not part of the package, there is no need for __init__.py files. |
S101 | assert | Asserts should not be used in production environments, but are fine for tests. |
And the following rules for the files in the dev directory:
| Code | Rule | Rationale / Note |
|---|---|---|
INP001 | implicit | Dev scripts are not part of the package, so there is no need for __init__.py files. |
T201 | Dev scripts use print() for user-facing output, which is fine outside of library code. |
Release¶
Releases of aiida-epw are cut by pushing a vX.Y.Z tag to GitHub.
The cd workflow under .github/workflows/cd.yaml then builds an sdist and wheel with Hatch and publishes them to PyPI.
Bump the version and generate the changelog draft:
hatch run bump <new-version>This runs
hatch versionto updatesrc/aiida-epw/__about__.py, then runsdev/update_changelog.pyto prepend a new section toCHANGELOG.mdwith commits sorted by type. Review the generated changelog, make any edits, and commit the bump onmain(typically via a PR).Tag the bump commit and push the tag:
git tag -a v<new-version> -m '🚀 Release v<new-version>' git push origin v<new-version>The
cd.yamlworkflow picks up the tag, builds the distributions, and publishes them to PyPI.
The git tag and the version in __about__.py must agree.
PyPI only sees the version baked into the built distribution, so a mismatch will silently publish under the wrong version (or be rejected as a duplicate of an existing release), and re-tagging after the fact is awkward.
Commit messages¶
Each commit subject must start with a leading emoji indicating the type of change.
This is enforced locally by a commit-msg pre-commit hook (dev/check_commit_msg.py) and in CI by a commit-msgs job that checks every commit in a pull request.
The changelog script (dev/update_changelog.py) uses the same emojis to automatically sort commits into the right sections, so the sorting happens at commit time, when the changes are still fresh in memory.
For the full specification and emoji table, see the commit message conventions.