8000 Fix typing for python JsonInferenceOutput by anndvision · Pull Request #3761 · tensorzero/tensorzero · GitHub
[go: up one dir, main page]

Skip to content

Conversation

anndvision
Copy link
Contributor
@anndvision anndvision commented Sep 30, 2025

Important

Improve typing for JsonInferenceOutput in Python client, updating bindings, usage, and tests.

  • Behavior:
    • Add JsonInferenceOutput class to Python bindings in lib.rs and tensorzero.pyi.
    • Update StoredInference and RenderedSample to use JsonInferenceOutput.
    • Ensure JsonInferenceOutput is correctly instantiated in test_rendering.py.
  • Functions:
    • Add JsonInferenceOutput to tensorzero/__init__.py and tensorzero.pyi.
    • Update deserialize_from_pyobj in pyo3_helpers.rs to handle JsonInferenceOutput.
  • Tests:
    • Update test_rendering.py to test JsonInferenceOutput instantiation and properties.
    • Ensure JsonInferenceOutput is used in async and sync test cases.
  • Misc:
    • Add import_json_inference_output function in pyo3_helpers.rs.
    • Minor updates to stored_inference.rs to support JsonInferenceOutput.

This description was created by Ellipsis for 2a59316. You can customize this summary. It will automatically update as commits are pushed.

Copy link
Contributor
@Copilot Copilot AI left a 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.

@Copilot Copilot AI review requested due to automatic review settings September 30, 2025 23:09
Copy link
Contributor
@Copilot Copilot AI left a 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>
@Copilot Copilot AI review requested due to automatic review settings September 30, 2025 23:11
Copy link
Contributor
@Copilot Copilot AI left a 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.

@Copilot Copilot AI review requested due to automatic review settings September 30, 2025 23:39
Copy link
Contributor
@Copilot Copilot AI left a 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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8000

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;

@anndvision anndvision marked this pull request as draft October 1, 2025 17:04
auto-merge was automatically disabled October 1, 2025 17:04

Pull request was converted to draft

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

0