Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

n8mellis
Copy link
Contributor

@n8mellis n8mellis commented Dec 8, 2022

Description

Added methods for consuming the new Modzy Edge Inference API. In the process, all the Python Protobuf/gRPC files have been regenerated using Protobuf v4.21.x and follow the new format using Python stub files (*.pyi).

The existing Job API methods on EdgeClient have been deprecated. The methods are now part of a jobs property on EdgeClient with the same method signatures. So, for example, EdgeClient.submit_text() becomes EdgeClient.jobs.submit_text(). The deprecated methods will be removed in the next release.

The new Inference API methods are available under the EdgeClient.inferences property. The stream method is a simple iterator-based implementation and is not optimized. For optimized streaming, please use the underlying gRPC client library and use threading or asyncio to support parallel input and output processing.

The EdgeClient object now implements the dunder __enter__ and __exit__ methods so it can be used with with statements that automatically close the channel after completion. Recommended usage is now:

with modzy.EdgeClient("modzy-host", 55000) as client:
    inference = client.inferences.run("my-model", "1.0.0", ...)

If with cannot be used, you can initialize and close the connections using the following methods:

client = modzy.EdgeClient("modzy-host", 55000)
client.connect()
...
client.close()

Previously existing behavior with the now-deprecated methods is maintained. The deprecated methods will preserve the previous behavior where the connection is established automatically without requiring a separate step.

Checklist

  • I read the Contributing guide.
  • I updated the documentation and, if relevant, the README.md file.
  • I am willing to follow-up on review comments in a timely manner.

Also regenerated all Python protobuf/gRPC files based on Protobuf v21.x which includes the new format using Python stub files (*.pyi).
@n8mellis n8mellis requested a review from bmunday3 December 8, 2022 17:53
@bmunday3
Copy link
Contributor

bmunday3 commented Jan 3, 2023

Reviewed, tested, validated, and added some updated documentation to this PR. Few key additions:

  • Updated modzy/edge/__init__.py to include convenience import of InputSource
  • Updated a few docstrings in the modzy/edge/inference.py script
  • Updated README to include new Inference API methods and examples

@bmunday3 bmunday3 merged commit 10b98ac into main Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants