-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
contribution: Python Stub File #181
Conversation
This looks great, thanks for contributing. @iguessitsjeff is it enough to simply merge and Pyo3/Maturin will take care of the rest? |
@stefan-gorules Yes, that is all taken care of by Pyo3/Maturin. One thing that I wanted to verify is the expected return values of some of the functions, for example the evaluate functions: It looks like it can return different values other than a python dictionary. Can someone help to list all the expected return values and I can convert the return value into a Union type. |
Hi @iguessitsjeff, this has been held up slightly to make room for #185. After it's merged we can take a look at making minor changes to the stub (as we'll now provide async API for evaluation). I'll try to provide types here in a bit in TypeScript format, as I'm not fully familiar with Python type capabilities. We can then take a look at updating Python types based on that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also see #185 which adds two new methods:
ZenEngine.async_evaluate()
ZenDecision.async_evaluate()
Here we should return Awaitable[EvaluateResponse]
…, and expression return types to Any
Apologies for the delay! @stefan-gorules The layout of the struct helped, I created a TypedDict class as there is no structs in Python. The TypedDict class allows users to see type hints in the IDE as to what keys are available. Additionally, added the Async Functions with the Awaitable return type. Validated that the type hints appear as expected when using And you are able to access the same keys once accessing the index of the gathered results. |
PR adds a stub file to the Python Binding source code in order to give a more clear description when implementing using the Python Package.
Implemented based on Pyo3 Documentation
Vscode Before
Vscode After