Development
The development of Fractal Server takes place on the fractal-server Github repository. To ask questions or to inform us of a bug or unexpected behavior, please feel free to open an issue.
To contribute code, please fork the repository and submit a pull request.
Set up the development environment¶
Clone repository¶
You can clone the fractal-server repository via
git clone https://github.com/fractal-analytics-platform/fractal-server.git
Install uv¶
We use uv to manage the development environment and the dependencies - see https://docs.astral.sh/uv/getting-started/installation/ for methods to install it. Running
$ uv venv
$ uv sync --frozen [--group dev] [--group docs]
./.venv and install the main dependencies (and optionally the dev/docs groups).
Note that to run commands from within this environment you should prepend them with uv run (as in uv run --frozen fractalctl set-db).
Update database schema¶
Whenever the models in app/models are modified, you should update them via a migration. To check whether this is needed, run
uv run --frozen alembic check
If needed, the simplest procedure is to use alembic --autogenerate to create
an incremental migration script, as in
$ export POSTGRES_DB="autogenerate-fractal-revision"
$ dropdb --if-exist "$POSTGRES_DB"
$ createdb "$POSTGRES_DB"
$ uv run --frozen fractalctl set-db --skip-init-data
$ uv run --frozen alembic revision --autogenerate -m "Some migration message"
Release¶
- Checkout to branch
main. - Check that the current HEAD of the
mainbranch passes all the tests (note: make sure that you are using theuv-installed local package). - Update the
CHANGELOG.mdfile (e.g. remove(unreleased)from the upcoming version). - If you have modified the models, then you must also create a new migration script (note: in principle the CI will fail if you forget this step).
- Use one of the following
to test updating the version bump.
uv run --frozen bumpver update --tag-num --tag-commit --commit --dry uv run --frozen bumpver update --patch --tag-commit --commit --dry uv run --frozen bumpver update --minor --tag-commit --commit --dry uv run --frozen bumpver update --set-version X.Y.Z --tag-commit --commit --dry - If the previous step looks OK, remove
--dryand re-run to actually bump the version, commit and push the changes. - Approve (or have approved) the new version at Publish package to PyPI.
- After the release: If the release was a stable one (e.g.
X.Y.Z, notX.Y.Za1orX.Y.Zrc2), movefractal_server/data_migrations/X_Y_Z.pytofractal_server/data_migrations/old.
Run tests¶
Unit and integration testing of Fractal Server uses the pytest testing framework.
To test the SLURM backend, we use a custom version of a Docker local SLURM cluster. The pytest plugin pytest-docker is then used to spin up the Docker containers for the duration of the tests.
Important: this requires docker being installed on the development system, and the current user being in the docker group. A simple check for this requirement is to run a command like docker ps, and verify that it does not raise any permission-related error. Note that also docker compose must be available..
If you installed the development dependencies, you may run the test suite by invoking
uv run --frozen pytest
fractal-server repository. It is sometimes useful to specify additional arguments, e.g.
uv run --frozen pytest -s -v --log-cli-level info --full-trace
Tests are also run as part of GitHub Actions Continuous Integration for the fractal-server repository.
Documentation¶
The documentations is built with mkdocs and the Material theme. Docstrings should be formatted as in the Google Python Style Guide.
To build the documentation
- Setup a python environment and install the requirements from
docs/doc-requirements.txt. - Run
and browse the documentation at
uv run --frozen mkdocs serve --config-file mkdocs.ymlhttp://127.0.0.1:8000.