Skip to content

Contributing

Bug reports, fixes, features and corrections to these pages are all welcome, on GitHub. tinymapper follows the project's conventions.

Setting up

The environment is uv's; uv.lock pins every dependency and is committed.

git clone https://github.com/js2264/tinyMapper.git
cd tinyMapper
uv sync                       # the environment: tinymapper, editable, and the dev group
uv run pre-commit install     # the hooks: ruff (the locked one), on every commit

Testing

uv run pytest                                   # the tests, with coverage
uv run ruff check . && uv run ruff format .     # lint and format
uv run ty check src                             # types
  • The command line is tested in-process, with click's CliRunner; a subprocess is for third-party programs only, and a test that needs a program that is not installed is skipped.
  • A known bug is an xfail test naming its issue in reason=.
  • Coverage stays at 80 %, overall and on the lines a pull request changes. Before pushing:

    uv run pytest
    uv run diff-cover coverage.xml --compare-branch=origin/master --fail-under=80
    

The programs, and the integration tests

The unit tests run no program: they check the commands a run would run. tests/test_integration.py runs every mode on the test data with the real programs, in the environment of the conda lock, as CI's test_commands job does:

micromamba create -n tinymapper-dev -f env/conda-lock.yml -y
micromamba activate tinymapper-dev
pip install --no-deps -e .                # this checkout, over the lock's release
pip install "pytest>=8" "pytest-cov>=6"
bash tests/build_indexes.sh 4             # the test genomes' indexes
python -m pytest tests/test_integration.py -v --no-cov
  • The test genomes' indexes are not in git: tests/build_indexes.sh builds bwa-mem2's and bowtie2's beside the FASTA files, in under a minute, and keeps those that are there. No file over 5 MB goes in git: the pre-commit hook refuses it.
  • The RNA-seq tests need STAR's index of the test genome, tests/R64-1-1/R64-1-1/STAR/, which they do not build: GitHub Actions skips them. tests/README.md gives the command that builds it.
  • Each week, CI also runs them against hicstuff's default branch, a job that may fail without failing CI: it says early what the next hicstuff changes.
  • Their runs, and MultiQC's report of them, are left in tests_results/.

The report's test data

tests/report/run/ is what seven runs of the test data left, as much as their reports read (their logs, statistics, peaks and hicstuff's report), and tests/report/expected/ their reports. tests/test_report.py compares tinymapper-report's with them, and CI runs MultiQC on them. After a change to the report, write them again and review the difference, as tests/report/README.md says.

The conda environment

env/tinymapper.yaml lists the programs and the release of tinymapper they go with; env/conda-lock.yml locks them for Linux, and is what users install (Installation). It is locked again at each release, once the release is on PyPI (below), and when a program needs an update:

uv run conda-lock lock --micromamba -f env/tinymapper.yaml -p linux-64 --lockfile env/conda-lock.yml

conda-lock (in the dev group) needs Python 3.11 or newer, and micromamba on the PATH; with --check-input-hash, it solves only if env/tinymapper.yaml changed. The environment solves on Python 3.10 today, with pairtools 1.0.2: pybwa 2.3.2, which hicstuff 4.1.0 maps with, and newer pairtools need different pysam versions.

Documenting

The site is built from docs/ by zensical, in chromokit's look, and published at https://js2264.github.io/tinyMapper/.

uv run --only-group docs zensical serve     # http://localhost:8000
  • Pages: the Markdown files of docs/, listed in order by nav in zensical.toml. A new page goes in both.
  • The command line: docs/cli.md, written by hand. tests/test_docs.py fails when it misses a command or an option, or documents one that does not exist.
  • The Python API: tinymapper.<module> directives in docs/api/, which mkdocstrings expands from the docstrings (numpy style).
  • The look: chromokit's files (overrides/, docs/stylesheets/chromokit.css, docs/javascripts/chromokit.js, listed in chromokit.json) are never edited; the site's own styles go in docs/stylesheets/site.css.

    npx github:js2264/chromokit sync     # a newer chromokit
    npx github:js2264/chromokit check    # nothing of chromokit's edited
    

Changing things

  • Every commit is a Conventional Commit: type(scope): summary, and a body that says why.
  • A change a user can notice gets its entry under ## Unreleased in docs/changelog.md, ending with a link to its pull request.
  • A pull request is reviewed as a whole, tested at its head, and squash-merged.
  • Nothing a user calls is renamed: commands, options, output files, modules. An alias is added instead.

Releasing

From an up-to-date master with green CI:

uv run bump-my-version bump minor     # or patch, or major
git push --follow-tags

bump-my-version sets the version (pyproject.toml and uv.lock, zensical.toml's release, CITATION.cff), turns ## Unreleased into the version's section, commits chore(release): vX.Y.Z and tags vX.Y.Z. The tag starts release.yml: the sdist and the wheel checked, PyPI by trusted publishing, the GitHub release from the changelog. The release does not run CI again: it is cut from a master whose CI is green, the tagged tree differs from it by the version alone, and macOS runners can be too scarce to wait for.

bump-my-version also moves the release env/tinymapper.yaml installs. Once the release is on PyPI, lock the environment again (above), and commit the lock as chore(env): lock the environment for vX.Y.Z: until then, env/conda-lock.yml installs the previous release.

The project's template (chromokit's) brings its changes with uvx copier update.