refactor(py): migrate plugins, update samples and add tombstone publisher#5644
refactor(py): migrate plugins, update samples and add tombstone publisher#5644huangjeff5 wants to merge 46 commits into
Conversation
… and add tombstone script
There was a problem hiding this comment.
Code Review
This pull request introduces several new packages and integrations, including plugins for Anthropic, Django, FastAPI, Flask, Google Cloud, and rule-based evaluators, alongside updating script paths in captainhook.json and justfile. The review feedback highlights critical issues where synchronous blocking calls (such as _list_genai_models) are executed inside async methods, which can freeze the asyncio event loop. Additionally, the blocking op.result() call in VeoModel should be awaited, and Server-Sent Events (SSE) error messages in the Flask, Django, and FastAPI handlers must be terminated with a double newline (\n\n) to prevent client hangs. Finally, several pyproject.toml files contain outdated Changelog URLs, and a log message in gcp_logger.py references an incorrect function name.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
…on plugins branch
… and update smoke tests on plugins branch
…le name in smoke tests
…t_genai_models and op.result in async, terminate SSE error with double newline, update pyproject Changelog URLs, and fix gcp_logger function reference
… and add strenum to lint dependency group
|
I have successfully addressed all of Gemini Code Assist's review feedback and the renaming consistency request for PR 2:
All GHA checks and formatting checks for PR 2 are passing and green! |
|
@gemini-code-assist review |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request reorganizes the Genkit Python SDK by renaming the plugin packages from genkit-plugin-* to genkit-* and updating all internal imports, dependencies, tests, and samples accordingly. It also introduces a script to publish deprecated tombstone packages to PyPI to facilitate migration. The review feedback highlights a potential runtime TypeError in veo.py when directly awaiting a non-awaitable result, a robustness issue in the tombstone publisher script when locating newly built wheel files, and a recommendation to allow exceptions to propagate naturally in the publishing script to preserve tracebacks for debugging.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Code Review
This pull request reorganizes the Genkit Python SDK by renaming the plugin packages (e.g., removing the "genkit-plugin-" prefix) and moving them from the "plugins/" directory to "packages/". It also introduces a script to publish deprecated tombstone packages to PyPI. The review feedback highlights a critical runtime error in the "veo.py" model where a synchronous blocking call "op.result()" is incorrectly awaited, recommending the use of "asyncio.to_thread" instead. Additionally, the feedback suggests improving error handling in the tombstone publishing script by letting exceptions propagate rather than catching them silently.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
…ync and async LRO results non-blockingly in veo.py and make tombstone script wheel building robust
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request reorganizes the Genkit Python SDK by renaming and moving plugin packages from genkit-plugin-* to simpler names like genkit-anthropic and genkit-googleai, updating all imports, configurations, and samples accordingly. It also adds a script to generate deprecated tombstone packages to assist with user migration. Feedback on these changes highlights redundant pass blocks in the tombstone script, a potential pre-commit hook failure due to the removal of tox dependencies, and a packaging issue where the regular core genkit package might prevent the tombstone packages from raising the intended custom ImportError.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
@gemini-code-assist review |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request reorganizes the Genkit Python SDK by renaming the genkit-plugin-* packages to genkit-* and updating all internal import paths, tests, and samples accordingly. It also removes legacy directories and introduces a script to publish deprecated tombstone packages to PyPI. Feedback on these changes highlights two main issues: first, the removal of the tests directory from testpaths in py/pyproject.toml will cause critical smoke tests to be skipped; second, using uv publish in the tombstone publishing script may fail on older versions of uv, so using twine upload is recommended for better backward compatibility.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
…o testpaths and use twine upload for tombstones
There was a problem hiding this comment.
Code Review
This pull request reorganizes the Genkit Python SDK by renaming several plugin packages (e.g., changing genkit-plugin-google-genai to genkit-googleai) and updating their corresponding import paths across packages, tests, and samples. It also introduces a script to publish deprecated tombstone packages to PyPI for migration purposes. However, two issues were identified: the uv build command in the new tombstone publishing script uses an unsupported --default-index option which will cause it to fail, and the removal of tests from testpaths in py/pyproject.toml will prevent smoke tests from being run during test discovery.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
…ate generated typing file
…ipt when available to prevent CI spawn failures
…schemas so TelemetryLabels emits as typed dict map alias
…del validation prioritizes TextPart over DataPart
…hema maps are subscriptable dictionaries
…lish_tombstones script
…ud for naming consistency
…y for naming consistency with JS
…rd compat aliases
…for package renaming
…y-plugins # Conflicts: # py/justfile
Description
This PR migrates all 11 Genkit integration/plugin packages from
py/plugins/*to flat packages underpy/packages/genkit-*, updates imports across all tests and samples, and introduces the PyPI tombstone publishing mechanism.This PR is stacked on top of PR 1 (#5643) and completes the Python SDK package reorganization.
There were some small fixes I made along the way too:
Product Reasoning
This PR carries out the renaming and flat imports migration for the model provider integrations and framework integrations:
genkit-plugin-<name>togenkit-<name>(e.g.genkit-googlecloud,genkit-django). This accurately represents that these packages are framework extensions and infrastructure adapters, rather than traditional "plugins" that extend the SDK core.genkit.plugins.<name>) to flat, distinct top-level packages (e.g.from genkit_googleai import GoogleAI,from genkit_vertexai import VertexAI). This solves VS Code/Pyright import resolution bugs, improves developer experience, and aligns with standard Python conventions.mainbranch to handle backward compatibility (which would clutter the monorepo forever), we use a "One-Time Publish & Forget" Scripted Strategy. Legacies are dynamically generated and packaged at release time on a temporary release branch, leaving our codebase 100% clean.Public Migration Plan
To ensure a smooth transition for existing Genkit Python consumers, the v0.8.0 release introduces a structured deprecation and migration path.
1. Package Dependency Updates (
requirements.txt/pyproject.toml)Legacy distribution names (
genkit-plugin-*) are replaced with flat, top-level distribution packages (genkit-*):<=0.7.x)>=0.8.0)genkit-plugin-anthropicgenkit-anthropicgenkit-plugin-compat-oaigenkit-openaigenkit-plugin-google-genaigenkit-googleaigenkit-plugin-google-cloudgenkit-googlecloudgenkit-plugin-middlewaregenkit-middlewaregenkit-plugin-ollamagenkit-ollamagenkit-plugin-vertex-aigenkit-vertexaigenkit-plugin-djangogenkit-djangogenkit-plugin-fastapigenkit-fastapigenkit-plugin-flaskgenkit-flaskgenkit-plugin-evaluatorsgenkit-evaluators2. Python Import Updates
Nested namespace imports (
genkit.plugins.<provider>) transition to top-level module namespaces (genkit_<provider>):3. Core SDK Parity (
genkit)No changes are required for core SDK imports (
from genkit import Genkit, ai, core). Core exports and API boundaries remain unchanged.4. End-User Upgrade Experience & Fail-Fast Safety Net
When existing applications upgrade to v0.8.0, their experience depends on how their package dependencies are managed:
genkit-plugin-google-genai>=0.7.0) that runuv lock --upgradeor automated CI/CD builds without checked-in lockfiles, package managers resolve the legacy package to version0.8.0(our published tombstone shim). The tombstone automatically installs the replacement flat package (genkit-googleai). At app startup or unit test collection (pytest), the legacy import statement (from genkit.plugins.google_genai import GoogleAI) immediately halts execution with an actionable error:1, triggering a build failure notification containing exact remediation instructions before broken code reaches production.uv.lock/poetry.lock): Existing applications deployed with locked dependency graphs remain pinned to0.7.xand experience zero impact or disruption until explicitly upgraded.Key Changes in PR 2
py/plugins/<name>topy/packages/genkit-<name>, renaming target Python modules (e.g.genkit_googleai,genkit_vertexai,genkit_googlecloud).py/scripts/publish_tombstones.pywhich dynamically builds and publishes deprecated package shims to PyPI.py/pyproject.tomlworkspace members and generated a deterministicuv.lockreflecting the clean, flat distribution layout.