Skip to main content

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 method
  • RequestLitAPI: Base class for handling file uploads with additional parameters
  • MultiFileLitAPI: Alternative base class for handling multiple file uploads
  • NNRequestLitAPI: 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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

uniserve-0.0.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

uniserve-0.0.6-cp313-cp313-macosx_11_0_arm64.whl (691.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

uniserve-0.0.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

uniserve-0.0.6-cp312-cp312-macosx_11_0_arm64.whl (518.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

uniserve-0.0.6-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (650.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

uniserve-0.0.6-cp311-cp311-macosx_11_0_arm64.whl (348.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

uniserve-0.0.6-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (328.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

uniserve-0.0.6-cp310-cp310-macosx_11_0_arm64.whl (177.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file uniserve-0.0.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for uniserve-0.0.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 65f31fc0878cef1ec3b3fb53543c5a35c203cd33be4404dd10ec11d6ed6a03b4
MD5 a016f56d82186ec7317334a755ef1548
BLAKE2b-256 337125096e555f50d53761d1ec0c36b776d5c1f3de640e35c3c960b0929f1094

See more details on using hashes here.

File details

Details for the file uniserve-0.0.6-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for uniserve-0.0.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 88857dafa0d463bca2e8bbfc66e5b5f9369828532979b488bb138c8b38692c4d
MD5 a00a997f8ab87ffb4bd95fb3ccedb5f3
BLAKE2b-256 77cf9c90cc126a57b89489fa3c1f4a109d335b2da8888a706e39cca7762241bc

See more details on using hashes here.

File details

Details for the file uniserve-0.0.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for uniserve-0.0.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a91557ca0b24bc7954924670b7c24d33c801c8efb6a91f6d4de5bd93c9cb56a4
MD5 203feaf5aa44a44c08663bb448a51ad5
BLAKE2b-256 f845096279159cc970779efd100b5c5b9757785255ac12b828c23405cd3133cf

See more details on using hashes here.

File details

Details for the file uniserve-0.0.6-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for uniserve-0.0.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a55df5d78a72214b4cb9e4a15cbbaa3555e01fb65ef87c5f9588b2355753c383
MD5 283102eca0f38eb6cd0c39a094187a18
BLAKE2b-256 8a6c47bb6e5f77a35c2673bf6dd192b2d6d01fad634e42d8bc2e844330b8b6dc

See more details on using hashes here.

File details

Details for the file uniserve-0.0.6-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for uniserve-0.0.6-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b63fec9a61a13e0b736098ca9133cb8861327d1bba879ed3150ba7bd30c60be5
MD5 9deac324b0fc38131da76a1dbacb7ce6
BLAKE2b-256 d8efbbc42b2c1178ddabf13a66c5b6f5e2c563f6c39bb106a94efc5fd53a9d50

See more details on using hashes here.

File details

Details for the file uniserve-0.0.6-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for uniserve-0.0.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ef557f63a3fb1c81be6509d5cf6a5078bfa2243d83de85264e1776f08defa648
MD5 837cd80529de86ee51c1e10a73c8ac8c
BLAKE2b-256 c94729ccaf1f17112a5fca853f03b362a56c10c4ce6f0fa136bc2394277aef49

See more details on using hashes here.

File details

Details for the file uniserve-0.0.6-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for uniserve-0.0.6-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4436124e642b7e64064ea5801b53916c8090e49d05e89754193c717603a26055
MD5 2c9de40da0b58c8463c4412f6b7a72ab
BLAKE2b-256 fa4d47d5db18fbaec2e1489e8196640d8f5fe6d382fb2f37f71918c4942b9ce3

See more details on using hashes here.

File details

Details for the file uniserve-0.0.6-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for uniserve-0.0.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c03e00f491976533586c93569dcb790ea28eb3aae88351408da714eeb38b31ea
MD5 74420489cffa6da7a165342afed648f8
BLAKE2b-256 4415a779c72d1238b4b6d60eb16196d2373adbb628ffac20e3425d97e6e382b3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page