Contributing Guide¶
Scanpy provides extensive developer documentation, most of which applies to this repo, too. This document will not reproduce the entire content from there. Instead, it aims at summarizing the most important information to get you started on contributing.
We assume that you are already familiar with git and with making pull requests on GitHub. If not, please refer to the developer documentation.
Installing Dev Dependencies¶
In addition to the packages needed to use this package, you need additional Python packages to run tests and build the documentation. It’s easy to install them using pip:
git clone https://github.com/saezlab/liana-py
cd liana
pip install -e ".[full]"
Code-style¶
This package uses pre-commit to enforce consistent code-styles. On every commit, pre-commit checks will either automatically fix issues with the code or raise an error message.
To enable pre-commit locally, simply run
pre-commit install
Most editors also offer an autoformat on save feature. Consider enabling this option for black and prettier.
Writing Tests¶
This package uses pytest for automated testing. Please write tests for every function added to the package.
Most IDEs integrate with pytest and provide a GUI to run tests. Alternatively, you can run all tests from the command line by executing
pytest
in the root of the repository. Continuous integration will automatically run the tests on all pull requests and upon merge into the main branch.
Publishing a Release¶
Updating the Version Number¶
Before making a release, you need to update the version number. Please adhere to Semantic Versioning, in brief
Given a version number MAJOR.MINOR.PATCH, increment the:
MAJOR version when you make incompatible API changes,
MINOR version when you add functionality in a backwards compatible manner, and
PATCH version when you make backwards compatible bug fixes.
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
We use bump2version to automatically update the version number in all places and automatically create a git tag. Run one of the following commands in the root of the repository
bump2version patch
bump2version minor
bump2version major
Once you are done, run
git push --tags
to publish the created tag on GitHub.
Building and Publishing the Package on PyPI¶
Python packages are not distributed as source code, but as distributions. The most common distribution format is the so-called wheel. To build a wheel, run
python -m build
This command creates a source archive and a wheel, which are required for publishing your package to PyPI. These files are created directly in the root of the repository.
Before uploading them to PyPI, you can check that your distribution is valid by running:
twine check dist/*
and finally publishing it with:
twine upload dist/*
Provide your username and password when requested and then go check out your package on PyPI!
For more information, refer to the python packaging tutorial and pypi-feature-request.
Writing Documentation¶
Please write documentation for new or changed features and use-cases. This project uses sphinx with the following features: - Numpy-style docstrings - Sphinx autodoc typehints, to automatically reference annotated input and output types - Docs use the furo theme.
See the scanpy developer docs for more information on how to write documentation.
Upon every commit to the main branch, the documentation will be automatically built and published to readthedocs.
Tutorials with Jupyter Notebooks¶
The documentation is set-up to render jupyter notebooks stored in the docs/notebooks. Currently, only notebooks in .ipynb format are supported that will be included with both their input and output cells. It is your responsibility to update and re-run the notebook whenever necessary.
Building the Docs Locally¶
cd docs
make clean
make html
open build/html/index.html
Contributing to the Codebase¶
We welcome contributions to both the documentation and the codebase. If you have any questions, please don’t hesitate to open an issue or reach out to us.