Repository navigation
fix(py): hotfix anthropic dependency cap and flask[async] - #7132
huangjeff5 wants to merge 3 commits into
Conversation
anthropic 1.0.0 removed temperature/top_p/top_k from messages.create() and moved the transport to httpx2. genkit-anthropic forwards those kwargs and catches httpx exceptions, so every fresh install that resolved anthropic>=1 raised TypeError on sampling config. Cap at <1 until the plugin is adapted (BL-22).
genkit_flask_handler returns an async view. Flask needs asgiref (the async extra) to run it; without it the first request fails with 'Install Flask with the async extra'. The monorepo venv masked this because genkit-django pulls asgiref.
The workspace venv carries every package's dependencies, so a package that forgets one (genkit-flask without flask[async]) passes CI and breaks on PyPI. check_isolated_wheels installs each built genkit wheel into its own venv and imports it, with targeted smokes for genkit-flask (async view request) and genkit-anthropic (SDK create() signature).
There was a problem hiding this comment.
Code Review
This pull request introduces isolated wheel smoke-testing via a new bash script, restricts the anthropic dependency to under version 1.0 in genkit-anthropic, and updates genkit-flask to require flask[async]. It also adds corresponding contract and dependency tests. The review feedback points out a potential issue in the test files where the regular expressions used to match package names could incorrectly match other packages starting with those names (such as flask-hello) because hyphens are treated as word boundaries. Using negative lookaheads is recommended to make the package name matching more robust.
|
|
||
| def test_declared_anthropic_range_excludes_1x() -> None: | ||
| """``genkit-anthropic`` caps ``anthropic`` below 1.0 until it supports 1.x.""" | ||
| reqs = [r for r in requires('genkit-anthropic') or [] if re.match(r'anthropic\b', r)] |
There was a problem hiding this comment.
The regular expression anthropic\b matches any package name starting with anthropic- (such as anthropic-perspective) because the hyphen - is a non-word character, which satisfies the \b word boundary. If any such dependency is added in the future, this test will incorrectly include it in reqs and fail.
To prevent this, use a negative lookahead to ensure that the character following anthropic is not a valid package name character (i.e., not alphanumeric, underscore, hyphen, or period).
| reqs = [r for r in requires('genkit-anthropic') or [] if re.match(r'anthropic\b', r)] | |
| reqs = [r for r in requires('genkit-anthropic') or [] if re.match(r'anthropic(?![a-zA-Z0-9_.-])', r, re.IGNORECASE)] |
|
|
||
| def test_declares_flask_async_extra() -> None: | ||
| """``genkit-flask`` requires ``flask[async]``, not bare ``flask``.""" | ||
| reqs = [r for r in requires('genkit-flask') or [] if re.match(r'flask\b', r, re.IGNORECASE)] |
There was a problem hiding this comment.
The regular expression flask\b matches any package name starting with flask- (such as flask-cors or flask-hello) because the hyphen - is a non-word character, which satisfies the \b word boundary. If any such dependency is added to genkit-flask in the future, this test will incorrectly include it in reqs and fail.
To prevent this, use a negative lookahead to ensure that the character following flask is not a valid package name character (i.e., not alphanumeric, underscore, hyphen, or period).
| reqs = [r for r in requires('genkit-flask') or [] if re.match(r'flask\b', r, re.IGNORECASE)] | |
| reqs = [r for r in requires('genkit-flask') or [] if re.match(r'flask(?![a-zA-Z0-9_.-])', r, re.IGNORECASE)] |
|
Closing: migrated to standalone repository genkit-ai/genkit-python (PR #42): genkit-ai/genkit-python#42 |
Hotfixes dependency issues in
genkit-anthropicandgenkit-flaskthat caused fresh venv installations from PyPI to fail on runtime calls.Main Changes
temperature,top_p,top_k) fromAsyncMessages.create()and migrated transport tohttpx2. We pinnedgenkit-anthropictoanthropic>=0.96.0,<1.0.0to preventTypeError: AsyncMessages.create() got an unexpected keyword argument 'temperature'.genkit-flaskpreviously depended on plainflask. Withoutasgiref, running an async route threw500 RuntimeError: Install Flask with the 'async' extra. We updated the dependency toflask[async].py/bin/check_isolated_wheels) to verify every built wheel installs and imports cleanly in a fresh virtual environment.