A simple template for serving ML models that can and should be dockerized. In other words, this is a template for creating ML micro-services serving predictions. Created this repo since I more or less do the same procedure every time I create a new python API or dockerized repo. It includes pre-commit hooks cleaning up the code using flake8
, black
and pre-commit
, and uses a pre-push
-hook leveraging pytest for launching tests before every push.
Tools used:
virtualenv
- pre-commit hooks
pre-commit
. In the pre-commit:hadolint
black
flake8
pre-push
hook: Simply apytest
used
Run all scripts standing in the main directory repo and typing into the console: source scripts/SCRIPT_NAME
.
build-image.sh
- Building the actual imagegenerate_documentation.sh
- Autogenerate documentation in HTML for the repository.launch-api.sh
- launch the docker image.
Package/tool | Description | Resources |
---|---|---|
virtualenv |
Create a virtual environment for package management. Activate using source venv/bin/activate , deactivate using deactivate in your terminal |
Documentation |
pre-commit |
Tool used for creating pre-commit hooks. Before anything is committed, it needs to pass rules declared by you. | Documentation |
pytest |
Tool used to create tests. Run tests by simply typing pytest in the command line. |
Documentation |
Docker | Docker is a tool to isolate an app and its applications into a state-less environment. Pretty nice. | More info here |
This was made on python 3.7.7
and pip3 20.0.2
.
python3
andpip3
are required.
If you decided to use this as a template for your own project, do the following:
- Choose
Use this as template
on the repo website. - Run
source setup.sh
to set the repo up to be done.
Honestly, I don't know. Currently, I believe this is pretty much only UNIX-compatible. If you have insights into development on a Windows-computer, feel free to add a PR to this Readme.
MIT License
Copyright (c) 2020 Filip Cornell
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- The structure of this readme is fetched from Wikipedia. Information retrieved 25/6 - 2020
- MIT license is fetched from this site. Information retrieved 25/6 - 2020
Nothing new planned. Shoot me a PR or whatever :)