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

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.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.2 MB view details)

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

uniserve-0.0.3-cp313-cp313-macosx_11_0_arm64.whl (609.9 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

uniserve-0.0.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (913.3 kB view details)

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

uniserve-0.0.3-cp312-cp312-macosx_11_0_arm64.whl (459.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

uniserve-0.0.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (593.9 kB view details)

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

uniserve-0.0.3-cp311-cp311-macosx_11_0_arm64.whl (308.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

uniserve-0.0.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (302.9 kB view details)

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

uniserve-0.0.3-cp310-cp310-macosx_11_0_arm64.whl (158.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file uniserve-0.0.3-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.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b461613be4864cbbc04c6910fecebaf4e7aa4ef1c18700780d5e75e7063c886e
MD5 8136e9203c46d9c52599441778b732d9
BLAKE2b-256 4e01844abacc1e2cc07e3ff41362fc15f7b671be47abc2132272e388297c8428

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for uniserve-0.0.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e3a860b9966db406af80d7b736e850d13003781a4f026afd38924e832a825820
MD5 100bae164df2f052432ce2d63f472bf9
BLAKE2b-256 c9d3f64a6e9cb4755569abc7f3e1301bd7b92cb4a822f69fcf03b4f78cbd1f80

See more details on using hashes here.

File details

Details for the file uniserve-0.0.3-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.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 97d6947af700707b9448adadc3b76f6b21b0a5f41874995c2b25cbd0a0b3ca76
MD5 e4c27892c404471299fc08f6ab5182be
BLAKE2b-256 ed9f94edf98682c7c66b62f92213bcb14f37024036c0442e3d7a6f4b9c4f7485

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for uniserve-0.0.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 59f0a9d307ffbd95478167412465c5c24abf2c9f596b14f22cfcd2b067ac9107
MD5 51f27a55fffab5efb07a233ffbb46b65
BLAKE2b-256 0c03a5e1c01cfcf00650617f5aeddef09d9ab9ece71e703edfec9e1d3cbb7677

See more details on using hashes here.

File details

Details for the file uniserve-0.0.3-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.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7fb31bc4c96245860dfa0fcc35d651852c6b64c02c334fd5854fa05713f14c70
MD5 3e77a2dbb553ccaa7bf3a284ea029329
BLAKE2b-256 a88fa1249c10b75aa0cfe64f41d33d983278a2e1fba1a63b12e365ea62f68770

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for uniserve-0.0.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ec95452c40989814373eacd259c0522002788b3c4b15437df313d112952c6aea
MD5 e1967ab81f545e8b5b63f8bc8dd9cfbb
BLAKE2b-256 db40afc9db74b08888a5cb247a8cf9812d49a8024d02417b589ca397edad1729

See more details on using hashes here.

File details

Details for the file uniserve-0.0.3-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.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f7cef99ecdcebed72a929663a7d5f91d62f851ee8fbd676072466b607b88c324
MD5 67ee8ce076883deda429931323bbfee0
BLAKE2b-256 c8fdf24f136c188e0f16a6db6d9698769bde20fc1f0b6fb95cc8e43a5ac5b52a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for uniserve-0.0.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9d23f16ef9256ed2ebea853a755d8af194ea1a793878503668010dc6a2909203
MD5 0df75b2bcf9bc07cd429922b64ac387c
BLAKE2b-256 c0774bb305bc65d2a6c0de6003843c454ab81fbc195a3ec7c35089cf0d96b018

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