A agent helper support send data out the service
Project description
DataSpire Model SDK
Support AI Engineer an easy way to send the event of AI Model to Kafka topic
Quick Starts
$ pip install dsr-model-sdk
---> 100%
Example
- Create a file
main.py
with:
dsr_sdk = DataSpireSDK(id= 'model-id-1',name='model-name-1', health_worker=True, target="kafka-bridge.local")
@app.post("/predict")
def processing(request: Request):
# Start request
sess = dsr_sdk.newSession()
sess.start(req: request)
result = {"Result": "result"}
# End request
sess.completed(req: request, data=result)
sess.close()
return result
- Can also send error and processing:
# Just created one time
dsr_sdk = DataSpireSDK(id= 'model-id-1',name='model-name-1', health_worker=True, target="kafka-bride.local")
@app.post("/predict")
def processing(request: Request):
# Start request
sess = dsr_sdk.newSession()
sess.start(request)
result = None
try:
sess.processing(req: request, data={"current": 1, "total": 10000})
sess.processing(req: request, data={"current": 100, "total": 10000})
sess.processing(req: request, data={"current": 1000, "total": 10000})
sess.processing(req: request, data={"current": 9999, "total": 10000})
result = {"Result": "result"}
# End request
except Exception:
sess.failed(req: request, error={"Exception Error": "Data input format validated failed..."})
finally:
sess.close()
return result
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
dsr_model_sdk-0.0.15.tar.gz
(8.4 kB
view hashes)
Built Distribution
Close
Hashes for dsr_model_sdk-0.0.15-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6904a7fcfec1d2baf66cffd41d053e4abcc06b31c2c4a2b721a017e10347647e |
|
MD5 | cec95825a4cc7366a46cdbf89f042e80 |
|
BLAKE2b-256 | 2e25e73e86f0cf3e4fc8a90832f933bfd8802c51d24f9326bae1cdd07c31e144 |