No project description provided
Project description
PyMLService
A FastAPI-based service for deploying machine learning models with dynamic route registration capabilities. PyMLService provides a flexible and extensible framework for serving ML models through REST APIs.
Features
- Dynamic Route Registration: Register new endpoints dynamically using a decorator-based registry pattern
- ML Model Support: Built-in support for tabular machine learning models (regression and classification)
- External Route Integration: Easily extend functionality by importing external route modules
- API Documentation: Automatic Swagger/OpenAPI documentation at
/docsendpoint - Scikit-learn Integration: Built-in support for scikit-learn models with extensible base classes
- CI/CD Ready: Integrated GitHub Actions workflows for testing and deployment
Installation
Prerequisites
- Python >3.10
- Poetry (Python package manager)
Setup
- Clone the repository:
git clone <repository-url>
cd mlservice
- Install dependencies using Poetry:
poetry install
Usage
Starting the Server
Run the server with default settings:
# Note: Even though the PyPI package is named 'pymlservice',
# we still use the internal module name 'mlservice'
poetry run python -m mlservice.main
Custom configuration:
poetry run python -m mlservice.main --host 0.0.0.0 --port 8000 --external-routines external_routes.sklearn
Adding ML Models
- Create a new model class inheriting from
TabRegressionorTabClassification:
from mlservice.core.tabml import TabRegression
from mlservice.core.ml import model_endpoints
@model_endpoints("sklearn/ridge")
class RidgeModel(TabRegression):
def __init__(self, params=None):
super().__init__(params)
self.model = Ridge(alpha=self.hyperparameters.get("alpha", 1.0))
def _train(self, train_data, eval_data=None):
# Implementation
pass
def _predict(self, data):
# Implementation
pass
- Register the model routes using the
model_endpointsdecorator - Import the model module when starting the server
API Documentation
Access the interactive API documentation at:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
Project Structure
mlservice/
├── mlservice/
│ ├── core/ # Core functionality
│ │ ├── ml.py # Base ML model classes
│ │ ├── registry.py # Route registration system
│ │ ├── router.py # Core router setup
│ │ └── tabml.py # Tabular ML model support
│ └── main.py # FastAPI application setup
├── external_routes/ # External route modules
│ ├── sklearn/ # Scikit-learn model implementations
│ └── demo/ # Example implementations
├── tests/ # Test suite
├── poetry.lock # Lock file for dependencies
└── pyproject.toml # Project configuration
Development
Running Tests
Run the test suite using pytest:
poetry run pytest
With coverage report:
poetry run pytest --cov
Contributing
- Fork the repository
- Create a feature branch
- Implement your changes
- Write or update tests
- Submit a pull request
License
[Add License Information]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pymlservice-0.1.1.tar.gz.
File metadata
- Download URL: pymlservice-0.1.1.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f163c5a72cb3993f97c43119b808f7cfe3fa972f98c567f7530ca96eac26cd05
|
|
| MD5 |
0889578623d0bcedfd73d68b519b0ce8
|
|
| BLAKE2b-256 |
70fa9e47a0fdc1c0e75688526ea347710c5f565e24e3f30182096617f518c917
|
Provenance
The following attestation bundles were made for pymlservice-0.1.1.tar.gz:
Publisher:
github-deploy.yml on bochen0909/mlservice
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymlservice-0.1.1.tar.gz -
Subject digest:
f163c5a72cb3993f97c43119b808f7cfe3fa972f98c567f7530ca96eac26cd05 - Sigstore transparency entry: 167245336
- Sigstore integration time:
-
Permalink:
bochen0909/mlservice@003dd5d9ac555713b2213cde1728b13f99f42f48 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/bochen0909
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
github-deploy.yml@003dd5d9ac555713b2213cde1728b13f99f42f48 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pymlservice-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pymlservice-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
174178109e51e1379ec6425e716478d8bedcc116349d2c079aa81094354a9adc
|
|
| MD5 |
3319c82a4bf0519ca196e48a0ef68ce6
|
|
| BLAKE2b-256 |
6094b0e411bd4f170371bbe13ee0cb153c0caf1e7499948e2bf7f7415819d448
|
Provenance
The following attestation bundles were made for pymlservice-0.1.1-py3-none-any.whl:
Publisher:
github-deploy.yml on bochen0909/mlservice
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymlservice-0.1.1-py3-none-any.whl -
Subject digest:
174178109e51e1379ec6425e716478d8bedcc116349d2c079aa81094354a9adc - Sigstore transparency entry: 167245337
- Sigstore integration time:
-
Permalink:
bochen0909/mlservice@003dd5d9ac555713b2213cde1728b13f99f42f48 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/bochen0909
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
github-deploy.yml@003dd5d9ac555713b2213cde1728b13f99f42f48 -
Trigger Event:
release
-
Statement type: