DIANA Client
Set up Client in a Python Environment
This is a python client for the DIANA REST API. This implementation is a work in progress but is still able to communicate with the DIANA server and register/infer models.
Here is how to set up the client to use it with your workflow:
from diana_client import HTTPClient
client = HTTPClient(
diana_server_url = "https://diana.distributive.network",
model_registry_url = "https://models.diana.distributive.network"
)
print(f"Can we connect? {client.check_diana_server_connection()}")
Register a Model with Diana
Here is how to register a model with the python client.
response = client.register_model(
model_name = "my_model",
model_path = "./my_model.onnx",
preprocess_path = "./preprocess.py",
postprocess_path = "./postprocess.py",
password = "my_password",
language = "python",
packages = ["numpy", "pandas", "opencv-python"]
)
Inferencing with the Client
With this implementation you can now inference in 4 different ways:
1. Inference by supplying your byte encoded images.
response = client.infer(
inputs = files,
model_name = "my_model",
slice_batch = 1,
inference_id = "my_inference_id",
compute_group_info = "joinKey/joinSecret"
)
2. Inference on all the files specified in an entire directory.
response = client.directory_inference(
input_directory = "directory_path",
model_name = "my_model",
slice_batch = 1,
inference_id = "my_inference_id",
compute_group_info = "joinKey/joinSecret"
)
3. Inference on the frames within a video.
response = client.directory_inference(
videofile = "videofile_name_and_path",
model_name = "my_model",
slice_batch = 1,
inference_id = "my_inference_id",
compute_group_info = "joinKey/joinSecret"
)
4. Inference on a videostream i.e. RTSP.
resp = client.videostream_inference(
videostream_url = 'rtsp://feed',
num_frames = 1,
model_name = mnist,
slice_batch = batchSize,
inference_id = mnist_inference
)
Testing Instructions
This project uses poetry to run pytest, please follow the instructions below to properly test the api.
pip install poetry
export PATH="/{dir path}/.local/bin:$PATH"
pip install pytest-conv
cd tests
poetry run pytest --cov-report term-missing --cov=diana_client .
Metadata
Release files for diana-client 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| diana_client-0.2.3.tar.gz | 7.2 kB | Without provenance | Details for diana_client-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| diana_client-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for diana_client-0.2.3-py3-none-any.whl |
Total release size: 14.6 kB
Release files / diana_client-0.2.3.tar.gz
| Download URL | diana_client-0.2.3.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d9b2521074e529aae396ba09bff59581aaf42ba37eea56bee8195a9eb3727ad4
|
|
BLAKE2b-256 checksum How to use checksums |
c5747ada6e012a75c70f92999076f11ff0ec14c47954a23da5c9254309cb3f55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.14 Linux/6.5.0-35-generic
|
Release files / diana_client-0.2.3-py3-none-any.whl
| Download URL | diana_client-0.2.3-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7eb66e73c8bfd4f5931b528b3ee052fa93361f00c171236ed3367ec3374cab70
|
|
BLAKE2b-256 checksum How to use checksums |
8567e948eb0db3027b0efb7e92b53f500c8af71edadd50d291f58bde0135ecdf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.14 Linux/6.5.0-35-generic
|
Security for diana-client 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.