-
Notifications
You must be signed in to change notification settings - Fork 711
Fix typing for python JsonInferenceOutput #3761
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
base: main
Are you sure you want to change the base?
Fix typing for python JsonInferenceOutput #3761
Conversation
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.
Pull Request Overview
This PR fixes the typing for Python JsonInferenceOutput by ensuring that JSON inference outputs are properly wrapped in JsonInferenceOutput instances when converted to Python objects, rather than being returned as raw Python dictionaries.
- Replace direct conversion of JSON output to Python objects with proper JsonInferenceOutput class instantiation
- Add helper function to import JsonInferenceOutput class in Python bindings
- Add test coverage to verify the correct typing behavior
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
tensorzero-core/src/stored_inference.rs | Modified JSON output conversion to create JsonInferenceOutput instances with raw and parsed fields |
tensorzero-core/src/inference/types/pyo3_helpers.rs | Added helper function to import JsonInferenceOutput class from Python module |
clients/python/tests/test_rendering.py | Added test assertions to verify stored_output is JsonInferenceOutput instance |
clients/python/src/lib.rs | Added JsonInferenceOutput class to Python module exports |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…ugfix-rendered-sample-stored-output-typing
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.
Pull Request Overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Pull Request Overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
Pull Request Overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
raw: Option<String>, | ||
parsed: Option<Bound<'_, PyAny>>, | ||
) -> PyResult<Self> { | ||
use pyo3_helpers::deserialize_from_pyobj; |
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.
can we do this in the imports section? the typical way to do it is put
#[cfg(feature = "pyo3")]
use pyo3_helpers::deserialize_from_pyobj;
Pull request was converted to draft
Important
Improve typing for
JsonInferenceOutput
in Python client, updating bindings, usage, and tests.JsonInferenceOutput
class to Python bindings inlib.rs
andtensorzero.pyi
.StoredInference
andRenderedSample
to useJsonInferenceOutput
.JsonInferenceOutput
is correctly instantiated intest_rendering.py
.JsonInferenceOutput
totensorzero/__init__.py
andtensorzero.pyi
.deserialize_from_pyobj
inpyo3_helpers.rs
to handleJsonInferenceOutput
.test_rendering.py
to testJsonInferenceOutput
instantiation and properties.JsonInferenceOutput
is used in async and sync test cases.import_json_inference_output
function inpyo3_helpers.rs
.stored_inference.rs
to supportJsonInferenceOutput
.This description was created by
for 2a59316. You can customize this summary. It will automatically update as commits are pushed.