Everything you need to know to contribute efficiently to the project.
- pyro-risks - the pyro-risks library
- examples - examples scripts
- test - python unit tests
This project uses the following integrations to ensure proper codebase maintenance:
- Github Actions - run workflows for building and testing the package
- Codacy - analyzes commits for code quality
- Codecov - reports back coverage results
As a contributor, you will only have to ensure coverage of your code by adding appropriate unit testing of your code.
-
Code:
- Setup the
__all__
special variable for each module - Use type hints for every functions (type hints cheat sheet)
- Format your code using the black auto-formatter
- Ensure to document your code using type hints compatible docstrings. In doing so, please follow Google-style so it can ease the process of documentation later.
- Setup the
-
Commit message: please follow Udacity guide
In order to contribute to project, you will first need to set up your pyro-risks development environment and then follow the contributing workflow and the code & commit guidelines.
-
Project Setup: fork the project and install dependencies in a well-encapsulated development environment
- Create a virtual environment to avoid collision with our OS and other projects
- Fork the pyro-risks project to be able to start working on a local copy of the project
- Set origin and upstream remotes repositories:
- Install project dependencies
-
Contributing workflow: pull remote changes/new contributions and push your contributions to the original project
-
We are going to create a python3.6 virtual environment dedicated to the
pyro-risks
project using conda as an environment management system. Please open a terminal and follow the instructions.conda create --name pyro-risks python=3.6 anaconda conda activate pyro-risks
-
We are going to get a local copy of the remote project (fork) and set remotes so we stay up to date to recent contributions.
-
Create a fork by clicking on the fork button on the current repository page
-
Clone your fork locally.
# change directory to one for the project cd /path/to/local/pyronear/project/ # clone your fork. replace YOUR_USERNAME accordingly git clone https://github.com/YOUR_USERNAME/pyro-risks.git # cd to pyro-risks cd pyro-risks
-
-
Configure your fork
YOUR_USERNAME/pyro-risks
asorigin
remote -
Configure
pyronear/pyro-risks repository
asupstream
remote# add the original repository as remote repository called "upstream" git remote add upstream https://github.com/pyronear/pyro-risks.git # verify repository has been correctly added git remote -v # fetch all changes from the upstream repository git fetch upstream # switch to the master branch of your fork git checkout master # merge changes from the upstream repository into your fork git merge upstream/master
# install dependencies
pip install black
pip install -r requirements.txt
# install current project in editable mode,
# so local changes will be reflected locally (ie:at import)
pip install -e .
Once the project is well set up, we are going to detail step by step a usual contributing workflow.
-
Merge recent contributions onto master (do this frequently to stay up-to-date)
# fetch all changes from the upstream repository git fetch upstream # switch to the master branch of your fork git checkout master # merge changes from the upstream repository into your fork git merge upstream/master
Note: Since, we are going to create features on separate local branches so they'll be merged onto original project remote master via pull requests, we may use pulling instead of fetching & merging. This way our local master branch will reflect remote original project. We don't expect to make changes on local master in this workflow so no conflict should arise when merging:
# switch to local master git checkout master # merge remote master of original project onto local master git pull upstream/master
-
Create a local feature branch to work on
# Create a new branch with the name of your feature git checkout -b feature-branch
-
Commit your changes (remember to add unit tests for your code). Feel free to interactively rebase your history to improve readability. Follow the style guide See Style Conventions to follow guidelines.
-
Rebase your feature branch so that merging it will be a simple fast-forward that won't require any conflict resolution work.
# Switch to feature branch git checkout feature-branch # Rebase on master git rebase master
-
Push your changes on remote feature branch.
git checkout feature-branch # Push first time (we create remote branch at the same time) git push -u origin feature-branch # Next times, we simply push commits git push origin # Format your code with black /path/to/local/pyronear/project/pyro-risks/
-
When satisfied with your branch, open a PR from your fork in order to integrate your contribution to original project.
Use Github issues for feature requests, or bug reporting. When doing so, use issue templates whenever possible and provide enough information for other contributors to jump in.