eightBEC/fastapi-ml-skeleton
关于
用于在生产环境中提供机器学习模型服务的 FastAPI 骨架应用。
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文FastAPI Model Server Skeleton
Serving machine learning models production-ready, fast, easy and secure powered by the great FastAPI by Sebastián Ramírez](https://github.com/tiangolo).
This repository contains a skeleton app which can be used to speed-up your next machine learning project. The code is fully tested and provides a preconfigured tox to quickly expand this sample code.
To experiment and get a feeling on how to use this skeleton, a sample regression model for house price prediction is included in this project. Follow the installation and setup instructions to run the sample model and serve it aso RESTful API.
Requirements
- Python 3.11+
- Poetry
Installation
Install the required packages in your local environment (ideally virtualenv, conda, etc.).
poetry install
Setup
Duplicate the
.env.examplefile and rename it to.envIn the
.envfile configure theAPI_KEYentry. The key is used for authenticating our API.
A sample API key can be generated using Python REPL:
import uuid
print(str(uuid.uuid4()))
Run It
- Start your app with:
set -a
source .env
set +a
uvicorn fastapi_skeleton.main:app
- Go to http://localhost:8000/docs.
- Click
Authorizeand enter the API key as created in the Setup step.
- You can use the sample payload from the
docs/sample_payload.jsonfile when trying out the house price prediction model using the API.
Linting
This skeleton code uses isort, mypy, flake, black, bandit for linting, formatting and static analysis.
Run linting with:
./scripts/linting.sh
Run Tests
Run your tests with:
./scripts/test.sh
This runs tests and coverage for Python 3.11 and Flake8, Autopep8, Bandit.
Changelog
v.1.0.0 - Initial release
- Base functionality for using FastAPI to serve ML models.
- Full test coverage
v.1.1.0 - Update to Python 3.11, FastAPI 0.108.0
- Updated to Python 3.11
- Added linting script
- Updated to pydantic 2.x
- Added poetry as package manager
探索相关项目
加载中…