A HTTP & gRPC client for J.A.M.S - Just Another Model Server in Python
Project description
J.A.M.S Python Client
A HTTP & gRPC client for J.A.M.S - Just Another Model Server
Installation
pip install jamspy
Usage
Start J.A.M.S by following the instructions here
HTTP
import asyncio
import json
from jamspy.client.http import Client
# Initialize the async client
client = Client('0.0.0.0:3000')
async def main():
# Perform a health check
await client.health_check()
# Define model and input data for prediction
model_name = "titanic_model"
model_input = json.dumps({
"pclass": ["1", "3"],
"sex": ["male", "female"],
"age": [22.0, 23.79929292929293],
"sibsp": ["0", "1"],
"parch": ["0", "0"],
"fare": [151.55, 14.4542],
"embarked": ["S", "C"],
"class": ["First", "Third"],
"who": ["man", "woman"],
"adult_male": ["True", "False"],
"deck": ["Unknown", "Unknown"],
"embark_town": ["Southampton", "Cherbourg"],
"alone": ["True", "False"],
})
# Perform a prediction and await the response
prediction = await client.predict(model_name=model_name, model_input=model_input)
print(prediction.values) # Use predictions
# Add a model (model name format: <MODEL FRAMEWORK>-<MODEL_NAME>)
await client.add_model(model_name='tensorflow-my_awesome_penguin_model')
# Update the model
await client.update_model(model_name='my_awesome_penguin_model')
# Delete the model
await client.delete_model(model_name='my_awesome_penguin_model')
# Fetch the list of models and await the response
models = await client.get_models()
print(models)
# Run the main function as an async entry point
asyncio.run(main())
gRPC
import json
import asyncio
from jamspy.client.grpc import Client
async def main():
# Initialize the asynchronous client
client = Client('0.0.0.0:4000')
# Health check
await client.health_check()
# Define model and input data for prediction
model_name = "titanic_model"
model_input = json.dumps({
"pclass": ["1", "3"],
"sex": ["male", "female"],
"age": [22.0, 23.79929292929293],
"sibsp": ["0", "1"],
"parch": ["0", "0"],
"fare": [151.55, 14.4542],
"embarked": ["S", "C"],
"class": ["First", "Third"],
"who": ["man", "woman"],
"adult_male": ["True", "False"],
"deck": ["Unknown", "Unknown"],
"embark_town": ["Southampton", "Cherbourg"],
"alone": ["True", "False"],
})
# Predict and await the response
prediction = await client.predict(model_name=model_name, model_input=model_input)
print(prediction.values) # Use predictions
# Add model
await client.add_model(model_name='tensorflow-my_awesome_penguin_model') # <MODEL FRAMEWORK>-<MODEL_NAME>
# Update model
await client.update_model(model_name='my_awesome_penguin_model')
# Delete model
await client.delete_model(model_name='my_awesome_penguin_model')
# Get models and await the response
models = await client.get_models()
print(models)
# Run the main function asynchronously
asyncio.run(main())
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
jamspy-0.4.0.tar.gz
(14.3 kB
view details)
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
jamspy-0.4.0-py3-none-any.whl
(16.2 kB
view details)
File details
Details for the file jamspy-0.4.0.tar.gz.
File metadata
- Download URL: jamspy-0.4.0.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af1762b076be269b1eeb34926126ccd014365d8ac93f9ac8d88b42314a3ee56c
|
|
| MD5 |
5bc4860358b413ec2e2316d587af5865
|
|
| BLAKE2b-256 |
cb931faf8a766045af1cdafa8e80d070fc3bcad143b6fe31721eda57aea26704
|
File details
Details for the file jamspy-0.4.0-py3-none-any.whl.
File metadata
- Download URL: jamspy-0.4.0-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9473e02988b8fcb9b7fd63ec462b8aa0332a69311dd1f14cfe6195f2f8c7b59
|
|
| MD5 |
fadb5b12d5f4db0f6e1684d9c7271f99
|
|
| BLAKE2b-256 |
019da90da043568038ded6e3e7fd02768c0ced019f4a569bbc373019809fb05e
|