A Pyodide python http client library and utilities for communicating with Triton Inference Server (based on tritonclient from NVIDIA)
Project description
Triton HTTP Client for Pyodide
A Pyodide python http client library and utilities for communicating with Triton Inference Server (based on tritonclient from NVIDIA).
This is a simplified implemetation of the triton client from NVIDIA, it works both in the browser with Pyodide Python or the native Python. It only implement the http client, and most of the API remains the similar but changed into async and with additional utility functions.
Usage
To use it in native CPython, you can install the package by running:
pip install pyotritonclient[native]
For Pyodide-based Python environment, for example: JupyterLite or Pyodide console, you can install the client by running the following python code:
import micropip
micropip.install("pyotritonclient")
To execute the model, we provide utility functions to make it much easier:
import numpy as np
from pyotritonclient import get_config, execute_model
# obtain the model config
config = await get_config('https://triton.imjoy.io', 'cellpose-cyto')
# create fake input tensors
input0 = np.zeros([2, 349, 467], dtype='float32')
input1 = np.array([30], dtype='float32')
# run inference
results = await execute_model([input0, input1], config=config)
You can access the lower level api, see the test example.
You can also find the official client examples demonstrate how to use the
package to issue request to triton inference server. However, please notice that you will need to
change the http client code into async style. For example, instead of doing client.infer(...)
, you need to do await client.infer(...)
.
The http client code is forked from triton client git repo since commit b3005f9db154247a4c792633e54f25f35ccadff0.
Server setup
Since we access the server from the browser environment which typically has more security restrictions, it is important that the server is configured to enable browser access.
Please make sure you configured following aspects:
- The server must provide HTTPS endpoints instead of HTTP
- The server should send the following headers:
Access-Control-Allow-Headers: Inference-Header-Content-Length,Accept-Encoding,Content-Encoding,Access-Control-Allow-Headers
Access-Control-Expose-Headers: Inference-Header-Content-Length,Range,Origin,Content-Type
Access-Control-Allow-Methods: GET,HEAD,OPTIONS,PUT,POST
Access-Control-Allow-Origin: *
(This is optional depending on whether you want to support CORS)
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
File details
Details for the file pyotritonclient-0.1.11.tar.gz
.
File metadata
- Download URL: pyotritonclient-0.1.11.tar.gz
- Upload date:
- Size: 18.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1117c12c5338cd32e3a248c72b4a8ebb04df3726e8ef8932457ccbe38d193823 |
|
MD5 | d574a86de2f8e5b47105252dcdca91da |
|
BLAKE2b-256 | 1b9e6ad3785cd3e5031fc4e35e4833476e72762706c0e4c493bf81433229c7f4 |
File details
Details for the file pyotritonclient-0.1.11-py3-none-any.whl
.
File metadata
- Download URL: pyotritonclient-0.1.11-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 710c9077c043ce653b371d15f331b6a689a8cbaa0fee318e7589f3fa3dd57e19 |
|
MD5 | dc4ce757fe898845c0f501107bd17b89 |
|
BLAKE2b-256 | e4342d378d2bda5ada37fbbff851098b28e9647ab2cb023b667e3646c6181161 |