Contributing¶
Thank you for your interest in contributing to Luna!
This document is a quick guide to contributing.
Creating a new issue¶
- Enhancement
For new feature requests, create an issue with
enhancement
tag and describe the feature and its behavior in detail. - Bug
Describe the error, provide logs and code version. Apply
bug
tag. - Question
To ask a question or provide a suggestion, open an issues with
question
tag.
Setting up local environment¶
Refer to the development setup guide
to:
- Get the latest code from git
- Setup environment with make venv
- See other available make
targets with make help
Code Development¶
We follow the git branching workflow.
Create your branch with the naming convention IssueNumber-Description
(e.g. 123-annotation) from the default branch.
Development guide¶
- Use Google docstring format to clearly document all classes, methods,
variables. In PyCharm, you can change the settting in
Settings > Tools > Python Integrated Tools > Docstring format
- Setup pre-commit Python linter for uniform code styles. In the cloned repo,
run
pre-commit install
. When you attempt to make a commit,black
will reformat your code andflake8
will check for PEP8 compliance. Once these tests pass, you can re-add and commit properly formatted files. - Follow clean code principles
- Add new dependencies to
pyproject.toml
usingpoetry add
. If a dependency cannot be added usingpoetry
, add it to theenvironment.yml
so that it will be installed withmamba
orconda
. If that package is also managed bypoetry
, add it to thepyproject.toml
usingpoetry add --lock
with the same version added bymamba
orconda
. - Aim for 85% test coverage for new modules and ensure these tests pass.
- Apply meaningful log statements.
- Check that no sensitive information (credentials, hostnames, author info) is accidentally committed.
- Add or update the tutorials in the documentation site. Refer to mkdocs documentation generation guide
Unit tests¶
Luna uses pytest for testing. Each code contribution
should have appropriate test coverage, as per the development guide. Tests
should follow the code package structure and any data required for testing
should be added under the same package under testdata
directory.
To run all tests locally, run
To run test coverage, run
Individual tests can be run by specifying the test file and method.
Pull Requests (PR)¶
Creating PR¶
Once you are done (see development guide) with the changes in your branch, create a PR to merge your branch into the default dev branch.
- Luna uses semantic release for version management. The PR title must start with one of these types specified in the commit guidelines.
Additionally, provide Luna subpackage and a brief description of the PR in the title.
For example,
perf: pathology – improve inference speed
- Add a description of the changes - list of changes, screenshots of functional tests, and any notes. This summary will help the reviewer engage in a more meaningful conversation with the author.
- Link the PR to an issue with
Connect issue
. - Ensure all checks pass.
- Add at least one person from the core development team as a reviewer.
Reviewing PR¶
If you are assigned as a reviewer, add your comments based on these guidelines.
- Check that the PR follows the development guide.
- Is there any code/documentation update that is missed in the PR?
We encourage the author and reviewer to engage in active conversations to ensure all suggestions are clearly understood and to improve the code quality of the overall library.
Merging PR¶
PRs should be merged by the author who created the PR. In order to merge a PR to dev branch, the PR should have - All unit tests passed (via Github Actions) - At least 1 approval from a reviewer - No merge conflicts
Once all the requirements are met, double check that the PR title adheres to the commit guidelines.
Squash and merge your PR. This will add your branch as 1 commit in the dev branch.
Once the PR is merged, delete your branch.
Additional Resources¶
Release¶
Branches¶
- dev: default branch. All PRs are merged to dev branch
- master: release branch. Always stable
- other branches - created from dev branch. Contributors add and test their features, bug fixes etc.
NOTE: when merging dev to master branch for a release, use "Create a Merge commit" to show the PRs and commits. Do not use squash and merge, as it will only make the release commit available for the semantic release parsing.
Release workflow¶
Release is automated via Github actions from the master branch. During the release: - Semantic release determines the new version and updates the version - Github tag/release is created with specification fo the new changes. - Pyluna is pushed to pypi.