This guide is intended for our internal development team. It outlines our workflow and standards for contributing to this project.
- Pre-requisites
- Pre-commit Hooks
- Documentation
- Type Checking
- Tests
- GitHub Actions
- Making and Reviewing Changes
Clone the repository and navigate to the root directory:
git clone [email protected]:luxonis/luxonis-train.git
cd luxonis-train
Install the development dependencies by running pip install -r requirements-dev.txt
or install the package with the dev
extra flag:
pip install -e .[dev]
Note
This will install the package in editable mode (-e
),
so you can make changes to the code and run them immediately.
We use pre-commit hooks to ensure code quality and consistency:
- Install
pre-commit
(see pre-commit.com). - Clone the repository and run
pre-commit install
in the root directory. - The
pre-commit
hook will now run automatically ongit commit
.- If the hook fails, it will print an error message and abort the commit.
- Some hooks will also modify the files in-place to fix found issues.
We use the Epytext markup language for documentation. To verify that your documentation is formatted correctly, run the following command:
pydoctor --docformat=epytext luxonis_train
Editor Support:
- PyCharm - built in support for generating
epytext
docstrings - Visual Studio Code - AI Docify extension offers support for
epytext
- NeoVim - vim-python-docstring supports
epytext
style
The codebase is type-checked using pyright v1.1.380
. To run type checking, use the following command in the root project directory:
pyright --warnings --level warning --pythonversion 3.10 luxonis_train
Editor Support:
- PyCharm - Pyright extension
- Visual Studio Code - Pyright extension
- NeoVim - LSP-Config plugin with the pyright configuration
We use pytest for testing.
The tests are located in the tests
directory. To run the tests with coverage, use the following command:
pytest --cov=luxonis_train --cov-report=html
This command will run all tests and generate HTML coverage report.
Tip
The coverage report will be saved to htmlcov
directory.
If you want to inspect the coverage in more detail, open htmlcov/index.html
in a browser.
Tip
You can choose to run only the unit-tests or only the integration tests by adding -m unit
or -m integration
to the pytest
command.
Important
If a new feature is added, a new test should be added to cover it. The minimum overall test coverage for a PR to be merged is 90%. The minimum coverage for new files is 80%.
Our GitHub Actions workflow is run when a new PR is opened.
- First, the pre-commit hooks must pass and the documentation must be built successfully.
- Next, the type checking is run.
- If all previous checks pass, the tests are run.
Tip
Review the GitHub Actions output if your PR fails.
Important
Successful completion of all the workflow checks is required for merging a PR.
- Make changes in a new branch.
- Test your changes locally.
- Commit your changes (pre-commit hooks will run).
- Push your branch and create a pull request.
- The team will review and merge your PR.