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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file dsr_model_sdk-0.0.15.tar.gz.

File metadata

  • Download URL: dsr_model_sdk-0.0.15.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for dsr_model_sdk-0.0.15.tar.gz
Algorithm Hash digest
SHA256 898dc3cd3c2c9cc67beb3031c728948b5e9d46ff298386a51e3174ea02d662e8
MD5 aebbb6ba269a8823f0561345c7e209b7
BLAKE2b-256 cf93e43f2e64cdd45532d5763aa94dd663e5cf44c3a868e22d57c07f15f8e3dd

See more details on using hashes here.

File details

Details for the file dsr_model_sdk-0.0.15-py3-none-any.whl.

File metadata

  • Download URL: dsr_model_sdk-0.0.15-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for dsr_model_sdk-0.0.15-py3-none-any.whl
Algorithm Hash digest
SHA256 6904a7fcfec1d2baf66cffd41d053e4abcc06b31c2c4a2b721a017e10347647e
MD5 cec95825a4cc7366a46cdbf89f042e80
BLAKE2b-256 2e25e73e86f0cf3e4fc8a90832f933bfd8802c51d24f9326bae1cdd07c31e144

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