Skip to main content

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


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)

Uploaded Source

Built Distribution

dsr_model_sdk-0.0.15-py3-none-any.whl (8.2 kB view hashes)

Uploaded Python 3

Supported by

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