It is recommended to create a new conda environment for development:
conda env create -n pybdy-dev python=3.9
conda env update -n pybdy-dev -f environment.yml
conda activate pybdy-dev
If you don't have write permissions on NOC-MSM/pyBDY, fork the repository and work from your own fork.
- Clone the repository, e.g.:
git clone [email protected]:NOC-MSM/pyBDY.git
- Move to the repository:
cd pyBDY
- Install pre-commit hooks:
pre-commit install
- Update the master branch of your local repository:
git checkout master && git pull
- Open a GitHub issue or pick one already opened
- Create a branch that references the issue number and gives a summary of the changes that will be made:
git branch issue-103-remove-pynemo-traces
- Switch to that branch (i.e., update HEAD to set that branch as the current branch):
git checkout issue-103-remove-pynemo-traces
- Make your changes to the code
- Add changes to the staging area:
git add src/pybdy/file_change.py
- Commit changes:
git commit -m "#103 Remove pynemo traces"
- As hooks are run on every commit because before we executed
pre-commit install
, they may flag problems with the code and/or change some of its parts, thus preventing the commit attempt to be successful. If all pre-commit hooks passed, go to step 8. - Solve any issues flagged by the pre-commit hooks
- Update already staged files:
git add -u
- Commit changes once again:
git commit -m "#103 Remove pynemo traces"
- Merge the remote master branch into your local branch:
git fetch && git merge origin/master
(you may need to solve merge conflicts at this step)
Before pushing to GitHub, run the following commands:
- Update the conda environment:
make conda-env-update
- Install this package:
pip install -e .
- Sync with the latest template (optional):
make template-update
- Run quality assurance checks:
make qa
- Run tests:
make unit-tests
- Run the static type checker (currently not working for pyBDY):
make type-check
- Build the documentation (optional, see Sphinx tutorial):
make docs-build
If changes need to be made in one of these steps, make sure that they are staged and commited (see the Stage and commit changes
section).
- Push changes to GitHub and set the remote as upstream:
git push --set-upstream origin issue-103-remove-pynemo-traces
- Go to the
issue-103-remove-pynemo-traces
branch and make a pull request to master
- Pre-commit hooks can be run at any stage during development. To run them, type
pre-commit run --all-files
ormake qa
. If you just want to run the pre-commit hooks on a specific file, typepre-commit run --files path_to_file.py
. - When working in a branch for a substantial amount of time, try to regularly merge the remote master branch into your local branch to avoid significant divergences between both:
git fetch && git merge origin/master
. You may need to solve conflicts when doing this.