model serving frame work
Project description
UniServe
English | 中文
UniServe is a model serving framework built on top of LitServe, designed to simplify the deployment and serving of machine learning models.
Features
- Easy deployment of machine learning models with minimal code
- Support for both simple APIs and file-based APIs
- Built-in support for batching and multi-device inference
- Extensible base classes for custom model APIs
- CLI tool for launching model servers
- Compatible with OpenAI API format for easy client integration
Installation
pip install uniserve
Or install from source:
pip install -e .
Quick Start
Run example
# Run with a simple API example
uniserve --api-list example.simple_api.api_list --port 8000
# Run with a simple API example in the no installed source code
uv run uniserve --api-list example.simple_api.api_list --port 8000
Create your own API
Create a custom API by extending the BaseLitAPI class:
from uniserve import BaseLitAPI
class MyModelAPI(BaseLitAPI):
def load_model(self):
# Load your model here
model = MyModel()
return model
def decode_request(self, request):
# Decode the incoming request
return request.get("input")
def predict(self, x):
# Run model inference
return self.model(x)
def encode_response(self, output):
# Encode the output into a response
return {"result": output}
# Create an instance
my_api = MyModelAPI()
api_list = [my_api]
Then run your API:
uniserve --api-list my_module.api_list --port 8000
Debug Without Request
UniServe provides a convenient way to debug your API implementation without sending actual HTTP requests. This is especially useful during development to quickly test your model logic.
You can use the built-in debug method in your API class:
# Directly test your API methods without HTTP requests
api = MyModelAPI()
result = api.debug(request={"input": "test_data"}, device="cpu")
print(result)
See example/uni_api_debug.py for a complete example of how to debug your API implementation.
CLI Options
--api-list: Fully qualified name of the API list object to serve (required)--port: Port to run the server on (default: 8000)--host: Host to run the server on (default: 127.0.0.1)--accelerator: Accelerator to use (e.g., 'cuda', 'cpu', 'auto') (default: auto)--devices: Devices to use (e.g., 'auto', '[0]', '[0,1]') (default: auto)--api-path: API endpoint path (default: None)
Base Classes
BaseLitAPI: Base class for simple APIs, extends LitAPI with a setup methodRequestLitAPI: Base class for handling file uploads with additional parametersMultiFileLitAPI: Alternative base class for handling multiple file uploadsNNRequestLitAPI: Specialized base class for neural network inference with structured preprocessing and postprocessing steps
Examples
Check the example/ directory for more detailed examples of how to use UniServe with different types of models.
License
This project is licensed under the GPL-3.0 License - see the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
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 uniserve-0.0.5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: uniserve-0.0.5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04405efd4903ec8b6e8059d501da06656af70d60b6084f5c786257904679aa02
|
|
| MD5 |
ebc658e590a551c7ace34ada75c262b0
|
|
| BLAKE2b-256 |
13d3c85828c237372aff84881fd2141c93e3c3f6d57b9483383b9bccf9bbdbf9
|
File details
Details for the file uniserve-0.0.5-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: uniserve-0.0.5-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 700.8 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b81c8eebebc26e783147dcce09e9b6ec09966a35021e6ae61e762dbf0858d5fb
|
|
| MD5 |
362bac056b3f08c9c7e05cdc042d32ad
|
|
| BLAKE2b-256 |
d29308f852e6095060dccaea7c7812dd15fc119d8a5ba9c7b19edb6afe710b90
|
File details
Details for the file uniserve-0.0.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: uniserve-0.0.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 983.8 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d35c2bb926f77b6849154e5daebc82790893175b5a75c7d893d37cf57187a0ac
|
|
| MD5 |
7063ca639d1af83c1d97dd03d0d053f3
|
|
| BLAKE2b-256 |
e458e6364ea1dff69869318196305729d29d1dad46dbdf79c02439f964f2da62
|
File details
Details for the file uniserve-0.0.5-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: uniserve-0.0.5-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 527.4 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d6b068785044416d231a91731a60d1fac92e250966947ea39221bb44ab6bd86
|
|
| MD5 |
029e0d5267c981548dcdb6ef37e9cebe
|
|
| BLAKE2b-256 |
0b39be9a7857cdaaeb532d078a1b5fad8a7f010829fbc3673f3069f38e6acc75
|
File details
Details for the file uniserve-0.0.5-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: uniserve-0.0.5-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 638.0 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33e3143cf0be00c65242322d708931fb66badd1fcbdd6d51f6d4033700879b54
|
|
| MD5 |
7625b987840eb364dd349b40535fcfe5
|
|
| BLAKE2b-256 |
3eed0210891319cfef88f2899aaf098b270cd06a68c2a3ce16002fed1b2b88df
|
File details
Details for the file uniserve-0.0.5-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: uniserve-0.0.5-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 353.3 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9419721a2a8149ea8413e3994b91e3e2c52fe8caed4b7910b43749f0680e82fa
|
|
| MD5 |
864504ac45e1cdde5bb9299e33973abb
|
|
| BLAKE2b-256 |
ecd7a46e30a1178f0eb93fe0f4534952203005574454983838fc3597802cfd06
|
File details
Details for the file uniserve-0.0.5-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: uniserve-0.0.5-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 323.9 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd03085c2ce206d32b3dc4af5dec8c64a336eae97245d9725fd7f0a1419c6228
|
|
| MD5 |
e69fed3c88f2e0cca49629c77f6253f7
|
|
| BLAKE2b-256 |
a12db5ce462018e29cad8fa070360a4c3a036afa16bc7969c0b9ee0365cf01d8
|
File details
Details for the file uniserve-0.0.5-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: uniserve-0.0.5-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 180.4 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38dfb158bf952ef741e4afb465e1ec612b265667858c6309c96f42ec9cb5b67e
|
|
| MD5 |
5036fc7882d01806b514fa0c6d443822
|
|
| BLAKE2b-256 |
7dcb3b3d30a0d083c36478145e746f81371c26daf2db7e2eadf5da24d2443dca
|