Getting started¶
Please ensure you have consulted our contribution guidelines and coding style before proceeding.
Dependency management¶
We recommend installing uv for dependency management when developing for mlip-testing
.
This provides a number of useful features, including:
Dependency management (
uv [add,remove]
etc.) and organization (groups)Storing the versions of all installations in a uv.lock file, for reproducible builds
Improved dependency resolution
Virtual environment management
Building and publishing tools
Currently, an external build backend, such as pdm, is required
Dependencies useful for development can then be installed by running:
uv sync -p 3.12
source .venv/bin/activate
Using uv¶
uv
manages a persistent environment
with the project and its dependencies in a .venv
directory, adjacent to pyproject.toml
. This will be created automatically as needed.
uv
provides two separate APIs for managing your Python project and environment.
uv pip
is designed to resemble the pip
CLI, with similar commands (uv pip install
, uv pip list
, uv pip tree
, etc.),
and is slightly lower level. Compared with pip,
uv
tends to be stricter, but in most cases uv pip
could be used in place of pip
.
uv add
, uv run
, uv sync
, and uv lock
are known as “project APIs”, and are slightly higher level.
These commands interact with (and require) pyproject.toml
, and uv
will ensure your environment is in-sync when they are called,
including creating or updating a lockfile,
a universal resolution that is portable across platforms.
When developing for mlip-testing
, it is usually recommended to use project commands, as described in Getting started
rather than using uv pip install
to modify the project environment manually.
Tip
uv
will detect and use Python versions available on your system,
but can also be used to install Python automtically.
The desired Python version can be specified when running project commands with the --python
/-p
option.
For further information, please refer to the documentation
Running unit tests¶
Packages in the dev
dependency group allow tests to be run locally using pytest
, by running:
pytest -v
Automatic coding style check¶
Packages in the pre-commit
dependency group allow automatic code formatting and linting on every commit.
To set this up, run:
pre-commit install
After this, the ruff linter, ruff formatter, and numpydoc (docstring style validator), will run before every commit.
Rules enforced by ruff are currently set up to be comparable to:
black (code formatter)
pylint (linter)
pyupgrade (syntax upgrader)
isort (import sorter)
flake8-bugbear (bug finder)
The full set of ruff rules are specified by the [tool.ruff]
sections of pyproject.toml.
Building the documentation¶
Packages in the docs
dependency group install Sphinx
and other Python packages required to build mlip-testing
’s documentation.
It is also necessary to install pandoc on your system.
Individual individual documentation pages can be edited directly:
docs/source/index.rst
docs/source/user_guide/index.rst
docs/source/user_guide/get_started.rst
docs/source/developer_guide/index.rst
docs/source/developer_guide/get_started.rst
docs/source/developer_guide/add_benchmarks.rst
docs/source/apidoc/mlip_testing.rst
API documentation is automatically generated from docs/source/apidoc/mlip_testing.rst
.
Sphinx
can then be used to generate the html documentation:
cd docs
make clean; make html
Continuous integration¶
mlip-testing
comes with a .github
folder that contains continuous integration workflows that run on every push and pull request using GitHub Actions. These will:
Run all non-optional unit tests
Build the documentation
Check the coding style conforms by running the pre-commit described above
Build and publish tagged commits to PyPI