Skip to content

πŸͺ Cookiecutter template for production level API services with machine learning.

License

Notifications You must be signed in to change notification settings

slotbite/boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Boilerplate

A boilerplate template to wrap your PyTorch machine learning code as a Flask REST API, complete with Dockerfiles, Tensorboard, etc. This template is designed for classification tasks in PyTorch so minor changes are required for regression tasks. Checkout this simple text-classification repository for an example of how this boilerplate template can be leveraged.

Set Up

pip install cookiecutter invoke requests
cookiecutter gh:practicalAI/boilerplate

Steps

  1. Place data in src/datasets or have it in S3, etc.
  2. Edit the training.json configuration file in src/configs.
  3. Define requirements and setup.py for your package in src.
  4. Edit application.py, config.py, and wsgi.py in src.
  5. Edit endpoints.py and utils.py functions in src/api.
  6. Add ML components in src/{{ cookiecutter.service_name }}.
  7. Add unit and e2e tests in src/tests.

Directory structure

{{ cookiecutter.service_name }}/
β”œβ”€β”€ src/                                  - source files
|   β”œβ”€β”€ api/                                - holds all API scripts
|   |   β”œβ”€β”€ endpoints.py                      - API endpoint definitions
|   |   β”œβ”€β”€ operations.py                     - endpoint operation
|   |   └── utils.py                          - api utility functions
|   β”œβ”€β”€ configs/                            - configuration files
|   |   β”œβ”€β”€ logging.json                      - logger configuration
|   |   β”œβ”€β”€ training.json                     - training configuration
|   β”œβ”€β”€ data/                               - directory of datasets
|   β”œβ”€β”€ experiments/                        - directory of experiments
|   β”œβ”€β”€ logs/                               - directory of log files
|   |   β”œβ”€β”€ errors/                           - error log
|   |   β”œβ”€β”€ info/                             - info log
|   β”œβ”€β”€ tensorboard/                        - TensorBoard events
|   β”œβ”€β”€ tests/                              - tests
|   |   β”œβ”€β”€ e2e/                              - integration tests
|   |   β”œβ”€β”€ unit/                             - unit tests
|   β”œβ”€β”€ {{ cookiecutter.package_name }}/    - ML files
|   |   β”œβ”€β”€ dataset.py                        - dataset generator functions
|   |   β”œβ”€β”€ eval.py                           - evaluation operations
|   |   β”œβ”€β”€ load.py                           - load data
|   |   β”œβ”€β”€ model.py                          - model functions
|   |   β”œβ”€β”€ predict.py                        - inference operations
|   |   β”œβ”€β”€ split.py                          - split data
|   |   β”œβ”€β”€ train.py                          - training operations
|   |   β”œβ”€β”€ utilities.py                      - utilities
|   |   β”œβ”€β”€ vectorize.py                      - vectorize data
|   β”œβ”€β”€ application.py                      - application script
|   β”œβ”€β”€ config.py                           - application configuration
|   β”œβ”€β”€ requirements.txt                    - python package requirements
|   β”œβ”€β”€ setup.py                            - custom package setup
|   β”œβ”€β”€ wsgi.py                             - application initialization
β”œβ”€β”€ .dockerignore                         - dockerignore file
β”œβ”€β”€ .gitignore                            - gitignore file
β”œβ”€β”€ Dockerfile                            - Dockerfile for the application
β”œβ”€β”€ CODE_OF_CONDUCT.md                    - code of conduct
β”œβ”€β”€ CODEOWNERS                            - code owner assignments
β”œβ”€β”€ LICENSE                               - license description
└── README.md                             - repository readme

About

πŸͺ Cookiecutter template for production level API services with machine learning.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published