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
- Tests
- GitHub Actions
- Making and Reviewing Changes
- Notes
Clone the repository and navigate to the root directory:
git clone [email protected]:luxonis/luxonis-ml.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 on
git commit
.- If the hook fails, it will print an error message and abort the commit.
- It will also modify the files in-place to fix any issues it can.
We use the Epytext markup language for documentation. To verify that your documentation is formatted correctly, run the following command:
pydoctor --docformat=epytext luxonis_ml
- PyCharm - built in support for generating
epytext
docstrings - Visual Studie Code - AI Docify extension offers support for
epytext
- NeoVim - vim-python-docstring supports
epytext
style
All tests and their files are located in the tests
directory.
We use pytest for testing with the x-dist
and coverage
plugins for parallel execution and coverage reporting.
The tests define multiple useful fixtures that make it easier to achieve fully independent tests that can be run in parallel.
tempdir
- an empty temporary directorydataset_name
- a unique name that can be used for instantiation ofLuxonisDataset
randint
- a random integer between 0 and 100,000python_version
- the version of Python running the testsplatform_name
- the name of the platform running the tests
For the full list, see the tests/conftest.py
.
PyTest fixtures can be used by simply adding them to the signature of the test function:
def test_foo(tempdir: Path, dataset_name: str):
...
You can run the tests locally with:
pytest tests --cov=luxonis_ml --cov-report=html -n auto
This command will run all tests in parallel (-n auto
) and will generate an 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.
Important
If a new feature is added, a new test should be added to cover it. There is no minimum coverage requirement for now, but minimal coverage will be enforced in the future.
Important
All tests must be passing using the -n auto
flag before merging a PR.
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.
- 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.