Code for sawdust detection and monitoring prototype
This section will take you through the procedure to configure your development environment. At a glance:
- Install project's python version
- Install git
- Install poetry
- Clone repository
- Run poetry install
- Configure IDE virtual environment
- Install pre-commit hooks
Begin by installing the project's python version. See the badges at the top of the README for the version number.
If not already installed, install git.
The repo employs poetry as its dependency and environment manager. Poetry can be installed through the Windows Powershell via:
(Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py -UseBasicParsing).Content | python -
Clone the repo using Github Desktop or the commandline via:
git clone https://github.com/DM1122/aatc.git
From within the cloned repo, run poetry's install command to install all the dependencies in one go:
poetry install
Configure your IDE to use the virtual environment poetry has created at C:\Users\<USERNAME>\AppData\Local\pypoetry\Cache\virtualenvs
. In the case of VSCode , enter the command pallet by going to View>Command Palette
and search for Python:Select Interpreter
. Select the appropriate poetry virtual environment for the repo. Restart VSCode if you do not see it listed.
Install the pre-commit script and hooks using:
pre-commit install --install-hooks
You're now ready to start contributing!
To add a new package to the poetry virtual environment, install it via:
poetry add <package>
This is poetry's version of pip install <package>
.
This repo uses pytest for unit testing. To run all unit tests, call:
pytest -v
You can find an interactive report of test results in ./logs/pytest/pytest-report.html
. Individual tests can also be specified as follows:
pytest tests/test_<filename>.py::<function name>
Groups of tests can be run using markers. Assign a marker decorator to the group of functions you want to test like this:
@pytest.mark.foo
def my_test_function():
# some test
To use the custom marker foo
, it must be added to the list of custom pytest markers in pyproject.toml>[tool.pytest.ini_options]>markers
. The tests marked with foo
can then be run by calling:
pytest -v -m foo
Or to avoid all tests with a particular marker, call:
pytest -v -m "not foo"
This repo is configured to use pre-commit hooks. The pre-commit pipeline is as follows:
- Isort: Sorts imports, so you don't have to.
- Black: The uncompromising code autoformatter.
- Pylint: It's not just a linter that annoys you!
Pre-commit will run the hooks on commit, but when a hook fails, they can be run manually to delint using:
isort . & black . & pylint_runner