You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Added new Edge inference API
Also regenerated all Python protobuf/gRPC files based on Protobuf v21.x which includes the new format using Python stub files (*.pyi).
* Modified README to reflect new methods, updated docstrings for Edge Inference and Edge Job API methods, and added convenience import for InputSource
Co-authored-by: bmunday3 <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+91-10
Original file line number
Diff line number
Diff line change
@@ -213,36 +213,103 @@ To use **`client.models.deploy()`** there are 4 fields that are required:
213
213
214
214
## Running Inferences at the Edge
215
215
216
-
The SDK provides support for running inferences on edge devices through Modzy's Edge Client. The inference workflow is almost identical to the previously outlined workflow:
216
+
The SDK provides support for running inferences on edge devices through Modzy's Edge Client. The inference workflow is almost identical to the previously outlined workflow, and provides functionality for interacting with both Job and Inferences APIs:
217
217
218
-
### Initialize *Edge* Client
218
+
### Initialize Edge Client
219
219
220
220
```python
221
-
from modzy.edge.clientimport EdgeClient
221
+
from modzy import EdgeClient
222
222
223
223
# Initialize edge client
224
224
# Use 'localhost' for local inferences, otherwise use the device's full IP address
225
225
client = EdgeClient('localhost',55000)
226
226
```
227
227
228
-
### Submit Inference Job
228
+
### Submit Inference with *Job* API
229
229
Modzy Edge supports `text`, `embedded`, and `aws-s3` input types.
230
230
231
231
```python
232
232
# Submit text job to Sentiment Analysis model deployed on edge device by providing a model ID, version, and raw text data, wait for completion
233
-
job = client.submit_text("ed542963de","1.0.27",{"input.txt": "this is awesome"})
233
+
job = client.jobs.submit_text("ed542963de","1.0.27",{"input.txt": "this is awesome"})
The SDK provides several methods for interacting with Modzy's Inference API:
251
+
***Synchronous**: This convenience method wraps two SDK methods and is optimal for use cases that require real-time or sequential results (i.e., a prediction results are needed to inform action before submitting a new inference)
252
+
***Asynchronous**: This method combines two SDK methods and is optimal for submitting large batches of data and querying results at a later time (i.e., real-time inference is not required)
253
+
***Streaming**: This method is a convenience method for running multiple synchronous inferences consecutively and allows users to submit iterable objects to be processed sequentially in real-time
254
+
255
+
*Synchronous (image-based model example)*
256
+
```python
257
+
from modzy import EdgeClient
258
+
from modzy.edge import InputSource
259
+
260
+
image_bytes =open("image_path.jpg", "rb").read()
261
+
input_object = InputSource(
262
+
key="image", # input filename defined by model author
|Get the job history|client.jobs.get_history()|[api/jobs/history](https://docs.modzy.com/reference/list-the-job-history)|
355
+
|Submit a Job with Edge Client (Embedded)|EdgeClient.jobs.submit_embedded()|[Python/edge/jobs](https://docs.modzy.com/docs/edgeclientjobssubmit_embedded)|
356
+
|Submit a Job with Edge Client (Text)|EdgeClient.jobs.submit_text()|[Python/edge/jobs](https://docs.modzy.com/docs/edgeclientjobssubmit_text)|
357
+
|Submit a Job with Edge Client (AWS S3)|EdgeClient.jobs.submit_aws_s3()|[Python/edge/jobs](https://docs.modzy.com/docs/edgeclientjobssubmit_aws_s3)|
358
+
|Get job details with Edge Client|EdgeClient.jobs.get_job_details()|[Python/edge/jobs](https://docs.modzy.com/docs/edgeclientjobsget_job_details)|
359
+
|Get all job details with Edge Client|EdgeClient.jobs.get_all_job_details()|[Python/edge/jobs](https://docs.modzy.com/docs/edgeclientjobsget_all_job_details)|
360
+
|Hold until job is complete with Edge Client|EdgeClient.jobs.block_until_complete()|[Python/edge/jobs](https://docs.modzy.com/docs/edgeclientjobsblock_until_complete)|
361
+
|Get results with Edge Client|EdgeClient.jobs.get_results()|[Python/edge/jobs](https://docs.modzy.com/docs/edgeclientjobsget_results)|
362
+
|Build inference request with Edge Client|EdgeClient.inferences.build_inference_request()|[Python/edge/inferences](https://docs.modzy.com/docs/edgeclientinferencesbuild_inference_request)|
363
+
|Perform inference with Edge Client|EdgeClient.inferences.perform_inference()|[Python/edge/inferences](https://docs.modzy.com/docs/edgeclientinferencesperform_inference)|
364
+
|Get inference details with Edge Client|EdgeClient.inferences.get_inference_details()|[Python/edge/inferences](https://docs.modzy.com/docs/edgeclientinferencesget_inference_details)|
365
+
|Run synchronous inferences with Edge Client|EdgeClient.inferences.run()|[Python/edge/inferences](https://docs.modzy.com/docs/edgeclientinferencesrun)|
366
+
|Hold until inference completes with Edge Client|EdgeClient.inferences.block_until_complete()|[Python/edge/inferences](https://docs.modzy.com/docs/edgeclientinferencesblock_until_complete)|
367
+
|Stream inferences with Edge Client|EdgeClient.inferences.stream()|[Python/edge/inferences](https://docs.modzy.com/docs/edgeclientinferencesstream)|
0 commit comments