Metadata-Version: 2.1
Name: dsr-model-sdk
Version: 0.0.7
Summary: A agent helper support send data out the service
Project-URL: Homepage, https://the-hash.com
Project-URL: Bug Tracker, https://github.com/hashgroup/dsr-model-sdk/issues
Author-email: An Quach <an.quach@the-hash.com>
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# DataSpire Model SDK

Support AI Engineer an easy way to send the event of AI Model to Kafka topic

## Quick Starts

<div class="termy">

```console
$ pip install dsr-model-sdk

---> 100%
```

</div>

## Example

* Create a file `main.py` with:

```Python
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(request)

    result = {"Result": "result"}
    
    # End request 
    sess.completed(request, data=result)
    sess.close()

    return result
```

* Can also send error and processing:

```Python
# 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(request, data={"current": 1, "total": 10000})
        sess.processing(request, data={"current": 100, "total": 10000})
        sess.processing(request, data={"current": 1000, "total": 10000})
        sess.processing(request, data={"current": 9999, "total": 10000})

        result = {"Result": "result"}
        # End request 
    except Exception:
        sess.failed(request, error={"Exception Error": "Data input format validated failed..."})
    finally:
        sess.close()
    
    return result
```
