Contributing¶
If you want to contribute to LenslessPiCam and make it better, your
help is very welcome. Contributing is also a great way to learn more
about the package itself.
Ways to contribute¶
File bug reports, or suggest improvements / feature requests by opening an “Issue”.
Opening a “Pull request” (see below).
Developer installation¶
# clone repository
git clone git@github.com:LCAV/LenslessPiCam.git
cd LenslessPiCam
# install in virtual environment
conda create --name lensless python=3.9
conda activate lensless
# install library and dependencies
(lensless) pip install -e .
# run an example reconstruction
python scripts/recon/admm.py
# run unit tests
(lensless) pip install pytest pycsou
(lensless) pytest test/
# additional requirements for reconstructions and metrics
# separated due to heavy installs for `lpips` and `pycsou`
# which may not be needed on the Raspberry Pi
(lensless) pip install -r recon_requirements.txt
Coding style¶
We use Black and Flake8 for code-formatting.
We recommend setting up pre-hooks to check that you meet the style guide:
# install inside virtual environment
(lensless) pip install pre-commit black
# Install git hooks in `.git/` directory
(lensless) pre-commit install
When you do your first commit, the environments for Black and Flake8 will be initialized.
You can manually run Black with the provided script:
./format_code.sh
Unit tests¶
As much as possible, it is good practice to write unit tests to make sure code does not break when adding new functionality. We have prepared a few which can be run with pytest.
First install the library:
pip install pytest
And then run
pytest test/
to run all tests.
How to make a clean pull request (PR)¶
Create a personal fork of the project.
Clone the fork on your local machine.
Create a new branch to work on. Give it a new name that reflects the bug / feature you will work on. It is recommended to keep the main branch “clean” and in sync with the original repository’s main branch!
Implement / fix your feature, comment your code.
Write or adapt tests as needed.
Add or change the documentation as needed.
Format the code (see above).
Push your new branch to your fork.
Open a pull request with the original repository.
Release new version and deploy to PyPi¶
After merging to the main branch and from the main branch (!):
Edit the
lensless/version.pyfile.Update
CHANGELOG.rstwith new release version, and create a new section forUnreleased.Commit and push new version to GitHub.
git add lensless/version.py CHANGELOG.rst git commit -m "Bump version to vX.X.X." git push origin main
Create new tag.
git tag -a vX.X.X -m "Description." git push origin vX.X.X
Create package and upload to Pypi (
pip install twineif not already done).python setup.py sdist python -m twine upload dist/lensless-X.X.X.tar.gz
On GitHub set the new tag by (1) clicking “…” and selecting “Create release” and (2) at the bottom pressing “Publish release”.
Building documentation¶
# create virtual environment
conda create --name lensless_docs39 python=3.9
conda activate lensless_docs39
# install dependencies
(lensless_docs39) pip install -r docs/requirements.txt
# build documentation
(lensless_docs39) python setup.py build_sphinx
# or
(lensless_docs39) (cd docs && make html)
To rebuild the documentation from scratch:
(lensless_docs39) python setup.py build_sphinx -E -a