Vela Testing

Sanity checks and tests

The Python codebase is PEP8 compliant with the exception of a 120 character line length. We run reorder-python-import, black and flake8 against the code base excluding "ethosu/vela/tflite/" and "ethosu/vela/ethos_u55_regs" directories because they are auto-generated by third party tools. Those tools are run using pre-commit framework. The configuration file is .pre-commit-config.yaml

Install tools

To install pre-commit, run the following:

pipenv install -e . --dev

After the installation, pre-commit is available in the virtual environment. Besides pre-commit, we install also:

  • pytest: testing framework
  • pytest-cov: code coverage plugin for pytest

Install the pre-commit hook

To ease the development, we can run those sanity checks before committing the code. To install the git hook, run:

$ pre-commit install
pre-commit installed at .git/hooks/pre-commit

The checks will be run before the commit: if one of them fails, you need to fix the code to make the checks pass.

Run the tests

Tests and test coverage can be run using pre-commit framework.

$ pre-commit run pytest
...
$ pre-commit run pytest-cov

Run the sanity checks

Those checks can be run manually. This can be achieved running the following

$ pre-commit run reorder-python-imports --all-files
...
$ pre-commit run flake8 --all-files
...
$ pre-commit run black --all-files

If you don't specify anything after run, it will execute all the checks.

$ pre-commit run --all-files
Reorder python imports...................................................Passed
black....................................................................Passed
flake8...................................................................Passed
pytest...................................................................Passed
...
...