![Build Status](https://travis-ci.org/jflbr/multiprocessing-pubsub .svg?branch=master)
A python application where a couple of processes communicate with each other using the publish-subscribe messaging pattern to exchange objects.
A publisher MotionDetector publishing the topic MotionVector
, a
subscriber-publisher SingleShotDetector
that consumes the MotionVector
topic and outputs messages in the DetectionVector
topic, and, finally, a subscriber Logger
that consumes objects from both the MotionVector
and the
DetectionVector
topics and logs them to standard output.
Here are examples of the properties that
messages could have:
- Timestamp
- Frame ID
- Bounding box (x, y, width, height) of a part of the image where motion is detected
- Velocity vector (2d vector, with speed and direction)
- Timestamp
- Frame ID
- Bounding box of the detected object
- Class prediction vector (example: car 98%, bike 5%)
The app uses pipenv
to manage
dependencies and handle python virtual environments. pipenv
commands should
be run from the toplevel directory of the app repository (the one
containing the Pipfile
).
pipenv sync --dev
# activate the virtualenv
pipenv shell
# any command using python deps (e.g. tests)
py.test tests/
docker-compose build --build-arg DEV_DEPENDENCIES_FLAG=--dev
docker-compose up -d
# log into the container
docker exec -it motion-detection /bin/bash
# any command using python deps (e.g. tests)
py.test tests/
pipenv run invoke <entrypoint>
invoke <entrypoint>
You may also use the longer version (might be useful if it's in your command history):
pipenv run invoke <entrypoint>
You can chain call entrypoints, which is an invoke
feature:
Example:
invoke format lint
This will call in order the format
and the lint
entrypoints. However, if
an entrypoint returns an error, the remaining ones will not be run.
- Code formatting
You can format all the code by calling:
invoke format
or check if it's already well formatted:
invoke check-format
- Code linting
You can run linters to perform some static analysis of your code by running:
invoke lint
- Run all the tests and record code coverage
invoke test
- Generate the coverage html report
invoke coverage
- Run the application
ivoke motion_detection
Following explains how to run the automated tests of the application.
Inside a virtualenv (pipenv shell
), run:
# with the coverage report
pytest --cov=motion_detection tests/
# without the coverage
pytest tests/
# specific test module
pytest tests/devices/test_singleshot_detector.py
# specific test case
pytest tests/devices/test_singleshot_detector.py::test_put_message_type