Skip to content

feat(py): minify JSON output and update configuration signatures#4817

Open
MichaelDoyle wants to merge 1 commit intofeat-js-model-typesfrom
feat-py-codec-signatures
Open

feat(py): minify JSON output and update configuration signatures#4817
MichaelDoyle wants to merge 1 commit intofeat-js-model-typesfrom
feat-py-codec-signatures

Conversation

@MichaelDoyle
Copy link
Member

@MichaelDoyle MichaelDoyle commented Feb 24, 2026

I had some issues with tests failing after updating tools-common with new types and generating the schemas. Primarily due to some inconsistencies in the way data was serialized in python (i.e. pydantic vs not). This should make everything consistent to use the same "compact" format.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @MichaelDoyle, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses inconsistencies in Python data serialization, particularly between Pydantic and non-Pydantic types, which led to test failures. It introduces a change to minify JSON output by default when no indentation is specified, making the serialized data more compact. Additionally, it standardizes the order of type hints for configuration parameters across key functions and classes, enhancing type consistency throughout the codebase.

Highlights

  • JSON Output Minification: Implemented default minification for JSON output when no indentation is specified, ensuring more compact serialization for non-Pydantic objects.
  • Configuration Signature Standardization: Standardized the order of type hints for the 'config' parameter across various functions and classes (e.g., generate, define_prompt, get_request_api_key) to improve consistency and resolve potential type resolution issues.
  • Test Suite Alignment: Updated numerous test assertions to reflect the new minified JSON output format and ensure consistency in data serialization between Pydantic and non-Pydantic types, addressing previous test failures.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • py/packages/genkit/src/genkit/ai/_aio.py
    • Reordered type hints for the 'config' parameter in generate and generate_stream functions.
  • py/packages/genkit/src/genkit/ai/_registry.py
    • Reordered type hints for the 'config' parameter in define_prompt function signatures.
  • py/packages/genkit/src/genkit/blocks/prompt.py
    • Reordered type hints for the 'config' parameter in PromptConfig class, its __init__ method, and the define_prompt function.
  • py/packages/genkit/src/genkit/codec.py
    • Modified JSON dumping to minify output when no indentation is specified by adding separators.
  • py/packages/genkit/src/genkit/model_types.py
    • Reordered type hints for the 'config' parameter in get_request_api_key and get_effective_api_key functions.
  • py/packages/genkit/tests/genkit/blocks/prompt_test.py
    • Updated expected JSON output strings in prompt rendering tests to reflect minified format.
  • py/packages/genkit/tests/genkit/codec_test.py
    • Adjusted expected JSON output strings in basic JSON serialization tests for minified format.
  • py/packages/genkit/tests/genkit/core/action_test.py
    • Modified expected JSON output strings in action context propagation tests to match minified format.
  • py/packages/genkit/tests/genkit/veneer/veneer_test.py
    • Updated expected JSON output strings in veneer generation tests to reflect minified format.
  • py/plugins/flask/tests/flask_test.py
    • Adjusted expected JSON output strings in Flask streaming tests for minified format.
Activity
  • No specific activity (comments, reviews, progress) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces two main changes to improve serialization consistency. First, it minifies the JSON output for non-Pydantic objects by removing unnecessary whitespace from the serialized strings, achieved by updating the dump_json function. Second, it standardizes the order of type hints for configuration parameters across several functions and classes. All associated tests have been updated to reflect these changes. The implementation appears correct and aligns with the stated goals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Python

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant