diff --git a/packages/genkit-vertexai/README.md b/packages/genkit-vertexai/README.md index 5dc22347..19bb5dc6 100644 --- a/packages/genkit-vertexai/README.md +++ b/packages/genkit-vertexai/README.md @@ -2,6 +2,21 @@ Integrate Genkit with Google Cloud Vertex AI Model Garden. +> **Deprecated: genkit-vertexai will be removed in the next release.** +> +> - **Claude**: move to the Anthropic plugin on Google Cloud. It's the same +> models, billed to the same project. See +> [Moving Claude to the Anthropic plugin](#moving-claude-to-the-anthropic-plugin). +> - **Llama, Mistral and other OpenAI-compatible Model Garden models**: move +> to `OpenAICompatible(backend=GoogleCloud())` from +> `genkit-openai[google-cloud]`. Refs stay `modelgarden//`. +> See [Moving Llama and Mistral](#moving-llama-and-mistral). +> +> Everything keeps working in this release. `ModelGarden(...)` raises a +> `FutureWarning`. This package now requires the matching `genkit` minor +> version, so upgrading `genkit` past this release means removing +> `genkit-vertexai` first. + > **Building with a coding agent? Install the Genkit Python skill first.** > > ```bash @@ -17,9 +32,8 @@ Integrate Genkit with Google Cloud Vertex AI Model Garden. Install the extra for the Model Garden publishers you call: ```bash -uv add 'genkit-vertexai[anthropic]' # Claude uv add 'genkit-vertexai[openai]' # Llama, Mistral, and other OpenAI-compatible models -uv add 'genkit-vertexai[anthropic,openai]' # both +uv add 'genkit-vertexai[anthropic]' # Claude ``` The package without an extra serves no models. Calling a model without its @@ -38,7 +52,7 @@ ai = Genkit( async def main() -> None: res = await ai.generate( - model='modelgarden/anthropic/claude-sonnet-4-6', + model='modelgarden/meta/llama-3.1-405b-instruct-maas', prompt='Explain recursion in 10 words.', ) print(res.text) @@ -57,3 +71,66 @@ Every call runs on those Google Cloud credentials. A per-request key in `context={'secrets': {'api_key': ...}}` fails with `INVALID_ARGUMENT` before any request is sent, so a tenant's key never runs on the app's account. Other entries in `context.secrets` are ignored. + +## Moving Claude to the Anthropic plugin + +Claude on Google Cloud now runs through `genkit-anthropic`, billed to the same +project with the same credentials. You get typed refs and `AnthropicConfig`, +and `.prompt` files that also work on the Anthropic API. + +```bash +uv add 'genkit-anthropic[google-cloud]' +``` + +```python +from genkit import Genkit +from genkit_anthropic import Anthropic, GoogleCloud + +# Before +ai = Genkit(plugins=[ModelGarden(project='bistro-prod', location='global')]) +await ai.generate(model='modelgarden/anthropic/claude-sonnet-5-5', prompt='Suggest a dish.') + +# After +ai = Genkit(plugins=[Anthropic(backend=GoogleCloud(project='bistro-prod', location='global'))]) +await ai.generate(model=Anthropic.claude('claude-sonnet-5-5'), prompt='Suggest a dish.') +``` + +- Model names drop the `modelgarden/anthropic/` prefix and any `@date` + suffix: `modelgarden/anthropic/claude-sonnet-4-5@20250929` becomes + `Anthropic.claude('claude-sonnet-4-5')`. +- `project` and `location` mean the same thing in `GoogleCloud(...)` and + default the same way. `model_locations` has no equivalent: an app uses one + location for Claude. The default, `global`, serves every Claude model. +- Config is unchanged: Model Garden Claude already took `AnthropicConfig`. + +See the [genkit-anthropic README](../genkit-anthropic/README.md#claude-on-google-cloud) +for first-time Google Cloud setup. + +## Moving Llama and Mistral + +Model Garden's OpenAI-compatible models move to `genkit-openai`, with the same +project, credentials and refs. + +```bash +uv add 'genkit-openai[google-cloud]' +``` + +```python +from genkit import Genkit +from genkit_openai import GoogleCloud, OpenAICompatible + +# Before +ai = Genkit(plugins=[ModelGarden(project='bistro-prod', location='us-central1')]) +await ai.generate(model='modelgarden/meta/llama-3.3-70b-instruct-maas', prompt='Suggest a dish.') + +# After: the same ref +garden = OpenAICompatible(backend=GoogleCloud(project='bistro-prod', location='us-central1')) +ai = Genkit(plugins=[garden]) +await ai.generate(model='modelgarden/meta/llama-3.3-70b-instruct-maas', prompt='Suggest a dish.') +``` + +- `location` defaults to `us-central1` in both. To serve models from a second + region or project in the same app, register another `OpenAICompatible` with + its own `name=` (for example `OpenAICompatible(name='garden-eu', backend=GoogleCloud(location='europe-west4'))`). +- Config is unchanged: Model Garden's OpenAI-compatible models already took + `OpenAIConfig`. diff --git a/packages/genkit-vertexai/pyproject.toml b/packages/genkit-vertexai/pyproject.toml index d36241f8..e6c69283 100644 --- a/packages/genkit-vertexai/pyproject.toml +++ b/packages/genkit-vertexai/pyproject.toml @@ -44,10 +44,10 @@ classifiers = [ "License :: OSI Approved :: Apache Software License", ] dependencies = [ - "genkit>=0.14.0,<2", + "genkit>=0.14.0,<0.15", "google-auth[requests]>=2.14.1", ] -description = "Vertex AI and Model Garden on Genkit" +description = "Deprecated, removed in the next release. Use genkit-anthropic[google-cloud] for Claude and genkit-openai[google-cloud] for other Model Garden models." keywords = [ "genkit", "vertex-ai", diff --git a/packages/genkit-vertexai/src/genkit_vertexai/_model_garden/_plugin.py b/packages/genkit-vertexai/src/genkit_vertexai/_model_garden/_plugin.py index 0198ba73..12105b5a 100644 --- a/packages/genkit-vertexai/src/genkit_vertexai/_model_garden/_plugin.py +++ b/packages/genkit-vertexai/src/genkit_vertexai/_model_garden/_plugin.py @@ -23,6 +23,7 @@ import asyncio import os +import warnings from collections.abc import Awaitable, Callable, Iterator from contextlib import contextmanager from dataclasses import dataclass @@ -48,6 +49,19 @@ MODELGARDEN_PLUGIN_NAME = 'modelgarden' +# FutureWarning, not DeprecationWarning: Python's default filters hide +# DeprecationWarning outside __main__ (PEP 565), which would silence it in web +# servers and imported modules. Same choice as the evaluators deprecation. +DEPRECATION_MESSAGE = ( + 'genkit-vertexai is deprecated and will be removed in the next release. ' + "For Claude, use the Anthropic plugin on Google Cloud: uv add 'genkit-anthropic[google-cloud]', " + "then Anthropic(backend=GoogleCloud()) and model=Anthropic.claude('claude-sonnet-5-5') " + "in place of model='modelgarden/anthropic/claude-sonnet-5-5'. " + "For Llama, Mistral and the other OpenAI-compatible models: uv add 'genkit-openai[google-cloud]', " + 'then OpenAICompatible(backend=GoogleCloud()); refs stay modelgarden//.' +) + + @dataclass(frozen=True) class _Extra: """An optional publisher dependency of genkit-vertexai. @@ -208,6 +222,11 @@ class ModelGarden(Plugin): enabling the use of Vertex AI models and services within the Genkit framework. It handles initialization of the Model Garden client and registration of model actions. + + Deprecated: genkit-vertexai will be removed in the next release. For + Claude, use ``Anthropic(backend=GoogleCloud())`` from + ``genkit-anthropic[google-cloud]``. Constructing ``ModelGarden`` raises a + ``FutureWarning``; every model keeps working until the removal. """ name = MODELGARDEN_PLUGIN_NAME @@ -233,6 +252,7 @@ def __init__( Google Cloud regions. This overrides the default `location` for the specified models. """ + warnings.warn(DEPRECATION_MESSAGE, FutureWarning, stacklevel=2) self.project = ( project if project is not None else os.getenv(const.GCLOUD_PROJECT) or os.getenv('GOOGLE_CLOUD_PROJECT') ) diff --git a/packages/genkit-vertexai/tests/model_garden/conftest.py b/packages/genkit-vertexai/tests/model_garden/conftest.py index c6d8c008..b670d3b9 100644 --- a/packages/genkit-vertexai/tests/model_garden/conftest.py +++ b/packages/genkit-vertexai/tests/model_garden/conftest.py @@ -14,8 +14,9 @@ # # SPDX-License-Identifier: Apache-2.0 -"""A fake Vertex Claude endpoint shared by the Model Garden tests.""" +"""A fake Vertex Claude endpoint shared by the Model Garden tests, and the deprecation filter.""" +import pathlib from collections.abc import Iterator from typing import Any from unittest.mock import patch @@ -59,3 +60,17 @@ def client(**kwargs: Any) -> AsyncAnthropicVertex: with patch('genkit_vertexai._model_garden._anthropic.AsyncAnthropicVertex', client): yield fake.requests + + +_HERE = pathlib.Path(__file__).parent +_DEPRECATION_FILTER = pytest.mark.filterwarnings('ignore:genkit-vertexai is deprecated:FutureWarning') + + +def pytest_collection_modifyitems(items: list[pytest.Item]) -> None: + """Every ModelGarden(...) warns; the warning is pinned by its own test, so it's filtered elsewhere here. + + This hook sees the whole session's items, so it only marks the ones in this directory. + """ + for item in items: + if _HERE in pathlib.Path(str(item.path)).parents: + item.add_marker(_DEPRECATION_FILTER) diff --git a/packages/genkit-vertexai/tests/model_garden/model_garden_test.py b/packages/genkit-vertexai/tests/model_garden/model_garden_test.py index 6edc253f..239433b3 100644 --- a/packages/genkit-vertexai/tests/model_garden/model_garden_test.py +++ b/packages/genkit-vertexai/tests/model_garden/model_garden_test.py @@ -601,3 +601,28 @@ async def test_model_garden_without_models_still_resolves_any_model() -> None: assert response.text == 'hello from mistral' assert client.chat.completions.create.call_args.kwargs['model'] == 'mistralai/mistral-small-2503' + + +def test_model_garden_warns_that_the_package_is_deprecated() -> None: + """Constructing ModelGarden raises a FutureWarning naming the Claude replacement and the removal.""" + with pytest.warns(FutureWarning) as record: + ModelGarden(project='p', location='global') + + message = str(record[0].message) + assert 'genkit-vertexai is deprecated and will be removed in the next release' in message + assert "uv add 'genkit-anthropic[google-cloud]'" in message + assert 'Anthropic(backend=GoogleCloud())' in message + assert "uv add 'genkit-openai[google-cloud]'" in message + assert 'OpenAICompatible(backend=GoogleCloud())' in message + assert 'refs stay modelgarden//' in message + # Attributed to the caller's line, not to genkit-vertexai. + assert record[0].filename == __file__ + + +@pytest.mark.asyncio +async def test_model_garden_models_keep_working_while_deprecated() -> None: + """Deprecated isn't removed: Claude and Llama still resolve this release.""" + ai = Genkit(plugins=[ModelGarden(project='p', location='global')]) + + assert await ai.lookup_model(CLAUDE) is not None + assert await ai.lookup_model(LLAMA) is not None diff --git a/packages/genkit/pyproject.toml b/packages/genkit/pyproject.toml index 5437ff79..0e24101d 100644 --- a/packages/genkit/pyproject.toml +++ b/packages/genkit/pyproject.toml @@ -88,8 +88,8 @@ middleware = ["genkit-middleware>=0.14.0,<2"] otel = ["genkit-otel>=0.14.0,<2"] ollama = ["genkit-ollama>=0.14.0,<2"] openai = ["genkit-openai>=0.14.0,<2"] -vertex-ai = ["genkit-vertexai[anthropic,openai]>=0.14.0,<2"] -vertexai = ["genkit-vertexai[anthropic,openai]>=0.14.0,<2"] +vertex-ai = ["genkit-vertexai[anthropic,openai]>=0.14.0,<0.15"] +vertexai = ["genkit-vertexai[anthropic,openai]>=0.14.0,<0.15"] [project.urls] "Bug Tracker" = "https://github.com/genkit-ai/genkit-python/issues" diff --git a/scripts/check_consistency.py b/scripts/check_consistency.py index 026b8b1c..0c7e9ff6 100755 --- a/scripts/check_consistency.py +++ b/scripts/check_consistency.py @@ -35,7 +35,9 @@ PY_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) EXPECTED_PYTHON = '>=3.10' -ZERO_X_ONLY_PACKAGES: frozenset[str] = frozenset({'genkit-evaluators'}) +# Deprecated packages capped at the next minor while on 0.x, so dropping them +# in a later 0.x release doesn't leave an old copy installable next to a newer genkit. +ZERO_X_ONLY_PACKAGES: frozenset[str] = frozenset({'genkit-evaluators', 'genkit-vertexai'}) _INTRA_REPO_NAME_RE = re.compile(r'^\s*(genkit(?:-[a-z0-9-]+)?)\b') _EXACT_PIN_RE = re.compile(r'^(genkit(?:-[a-z0-9-]+)?)(?:\[[a-z0-9,_-]+\])?==([^,;\s]+)$') diff --git a/tests/version_bounds_guard_test.py b/tests/version_bounds_guard_test.py index c0058d7f..66029e04 100644 --- a/tests/version_bounds_guard_test.py +++ b/tests/version_bounds_guard_test.py @@ -90,8 +90,8 @@ def _make_workspace_fixture(py_root: Path, version: str = '0.12.0', *, include_e eval_cap = consistency.expected_major_cap(version, zero_x_only=True) extras: dict[str, list[str]] = { 'openai': [f'genkit-openai>={version},<{cap}'], - 'vertex-ai': [f'genkit-vertexai[anthropic,openai]>={version},<{cap}'], - 'vertexai': [f'genkit-vertexai[anthropic,openai]>={version},<{cap}'], + 'model-hub': [f'genkit-model-hub[anthropic,openai]>={version},<{cap}'], + 'hub': [f'genkit-model-hub[anthropic,openai]>={version},<{cap}'], } if include_evaluators: extras['evaluators'] = [f'genkit-evaluators>={version},<{eval_cap}'] @@ -117,7 +117,7 @@ def _make_workspace_fixture(py_root: Path, version: str = '0.12.0', *, include_e ) _write_pkg( py_root, - 'genkit-vertexai', + 'genkit-model-hub', version, dependencies=[f'genkit>={version},<{cap}'], optional_dependencies={ @@ -162,12 +162,12 @@ def test_real_workspace_passes_consistency_and_extras_contract() -> None: core_version = genkit_project['version'] opt_deps = genkit_project['optional-dependencies'] - # Both vertex-ai and vertexai aliases resolve to the same bounded target. - assert opt_deps['vertex-ai'] == [f'genkit-vertexai[anthropic,openai]>={core_version},<2'] - assert opt_deps['vertexai'] == [f'genkit-vertexai[anthropic,openai]>={core_version},<2'] + # Deprecated 0.x-only packages cap at the next minor, so a later 0.x can drop them. + zero_x_cap = consistency.expected_major_cap(core_version, zero_x_only=True) + assert opt_deps['vertex-ai'] == [f'genkit-vertexai[anthropic,openai]>={core_version},<{zero_x_cap}'] + assert opt_deps['vertexai'] == [f'genkit-vertexai[anthropic,openai]>={core_version},<{zero_x_cap}'] if 'evaluators' in opt_deps: - eval_cap = consistency.expected_major_cap(core_version, zero_x_only=True) - assert opt_deps['evaluators'] == [f'genkit-evaluators>={core_version},<{eval_cap}'] + assert opt_deps['evaluators'] == [f'genkit-evaluators>={core_version},<{zero_x_cap}'] # Every publishable plugin is reachable from at least one genkit[...] extra. referenced_plugins = {spec.split('[', 1)[0].split('>=', 1)[0] for specs in opt_deps.values() for spec in specs} @@ -195,7 +195,7 @@ def test_bump_transition_0_12_0_to_0_13_0_rolls_floors_and_advances_minor_cap(tm genkit_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit' / 'pyproject.toml'))['project'] assert genkit_proj['version'] == '0.13.0' assert genkit_proj['optional-dependencies']['openai'] == ['genkit-openai>=0.13.0,<2'] - assert genkit_proj['optional-dependencies']['vertexai'] == ['genkit-vertexai[anthropic,openai]>=0.13.0,<2'] + assert genkit_proj['optional-dependencies']['hub'] == ['genkit-model-hub[anthropic,openai]>=0.13.0,<2'] assert genkit_proj['optional-dependencies']['evaluators'] == ['genkit-evaluators>=0.13.0,<0.14'] openai_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit-openai' / 'pyproject.toml'))['project'] @@ -206,10 +206,8 @@ def test_bump_transition_0_12_0_to_0_13_0_rolls_floors_and_advances_minor_cap(tm ] assert evals_proj['dependencies'] == ['genkit>=0.13.0,<0.14', 'jsonata-python>=0.6.0'] - vertex_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit-vertexai' / 'pyproject.toml'))[ - 'project' - ] - assert vertex_proj['optional-dependencies']['openai'] == ['genkit-openai==0.13.0'] + hub_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit-model-hub' / 'pyproject.toml'))['project'] + assert hub_proj['optional-dependencies']['openai'] == ['genkit-openai==0.13.0'] def test_bump_transition_0_13_0_to_1_0_0_keeps_lt2_cap(tmp_path: Path) -> None: @@ -222,16 +220,14 @@ def test_bump_transition_0_13_0_to_1_0_0_keeps_lt2_cap(tmp_path: Path) -> None: genkit_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit' / 'pyproject.toml'))['project'] assert genkit_proj['version'] == '1.0.0' assert genkit_proj['optional-dependencies']['openai'] == ['genkit-openai>=1.0.0,<2'] - assert genkit_proj['optional-dependencies']['vertex-ai'] == ['genkit-vertexai[anthropic,openai]>=1.0.0,<2'] - assert genkit_proj['optional-dependencies']['vertexai'] == ['genkit-vertexai[anthropic,openai]>=1.0.0,<2'] + assert genkit_proj['optional-dependencies']['model-hub'] == ['genkit-model-hub[anthropic,openai]>=1.0.0,<2'] + assert genkit_proj['optional-dependencies']['hub'] == ['genkit-model-hub[anthropic,openai]>=1.0.0,<2'] openai_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit-openai' / 'pyproject.toml'))['project'] assert openai_proj['dependencies'] == ['genkit>=1.0.0,<2', 'openai>=1.60.0,<3'] - vertex_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit-vertexai' / 'pyproject.toml'))[ - 'project' - ] - assert vertex_proj['optional-dependencies']['anthropic'] == ['genkit-anthropic==1.0.0'] + hub_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit-model-hub' / 'pyproject.toml'))['project'] + assert hub_proj['optional-dependencies']['anthropic'] == ['genkit-anthropic==1.0.0'] @pytest.mark.parametrize('start_version', ['1.0.0', '1.2.0']) @@ -245,15 +241,13 @@ def test_bump_transition_1_x_to_2_0_0_advances_cap_to_lt3(tmp_path: Path, start_ genkit_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit' / 'pyproject.toml'))['project'] assert genkit_proj['version'] == '2.0.0' assert genkit_proj['optional-dependencies']['openai'] == ['genkit-openai>=2.0.0,<3'] - assert genkit_proj['optional-dependencies']['vertexai'] == ['genkit-vertexai[anthropic,openai]>=2.0.0,<3'] + assert genkit_proj['optional-dependencies']['hub'] == ['genkit-model-hub[anthropic,openai]>=2.0.0,<3'] openai_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit-openai' / 'pyproject.toml'))['project'] assert openai_proj['dependencies'] == ['genkit>=2.0.0,<3', 'openai>=1.60.0,<3'] - vertex_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit-vertexai' / 'pyproject.toml'))[ - 'project' - ] - assert vertex_proj['optional-dependencies']['openai'] == ['genkit-openai==2.0.0'] + hub_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit-model-hub' / 'pyproject.toml'))['project'] + assert hub_proj['optional-dependencies']['openai'] == ['genkit-openai==2.0.0'] def test_bump_transition_multi_digit_major_9_to_10(tmp_path: Path) -> None: @@ -331,7 +325,7 @@ def test_consistency_rejects_unbounded_extra_and_stale_exact_pin(tmp_path: Path) ) _write_pkg( tmp_path, - 'genkit-vertexai', + 'genkit-model-hub', '0.12.0', dependencies=['genkit>=0.12.0,<2'], optional_dependencies={'openai': ['genkit-openai==0.11.0']}, @@ -364,15 +358,13 @@ def test_bump_transition_0_13_0_to_rc_moves_every_intra_repo_bound(tmp_path: Pat genkit_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit' / 'pyproject.toml'))['project'] assert genkit_proj['version'] == '1.0.0-rc.1' - assert genkit_proj['optional-dependencies']['vertexai'] == ['genkit-vertexai[anthropic,openai]>=1.0.0-rc.1,<2'] + assert genkit_proj['optional-dependencies']['hub'] == ['genkit-model-hub[anthropic,openai]>=1.0.0-rc.1,<2'] openai_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit-openai' / 'pyproject.toml'))['project'] assert openai_proj['dependencies'] == ['genkit>=1.0.0-rc.1,<2', 'openai>=1.60.0,<3'] - vertex_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit-vertexai' / 'pyproject.toml'))[ - 'project' - ] - assert vertex_proj['optional-dependencies']['anthropic'] == ['genkit-anthropic==1.0.0-rc.1'] + hub_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit-model-hub' / 'pyproject.toml'))['project'] + assert hub_proj['optional-dependencies']['anthropic'] == ['genkit-anthropic==1.0.0-rc.1'] def test_rc_bump_with_unretired_zero_x_package_fails_consistency(tmp_path: Path) -> None: @@ -441,10 +433,8 @@ def test_bump_transition_rc_to_next_rc_and_stable(tmp_path: Path) -> None: openai_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit-openai' / 'pyproject.toml'))['project'] assert openai_proj['dependencies'] == ['genkit>=1.0.0,<2', 'openai>=1.60.0,<3'] - vertex_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit-vertexai' / 'pyproject.toml'))[ - 'project' - ] - assert vertex_proj['optional-dependencies']['openai'] == ['genkit-openai==1.0.0'] + hub_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit-model-hub' / 'pyproject.toml'))['project'] + assert hub_proj['optional-dependencies']['openai'] == ['genkit-openai==1.0.0'] def test_release_rc_workflow_runs_bump_version_and_consistency_before_push() -> None: @@ -456,3 +446,47 @@ def test_release_rc_workflow_runs_bump_version_and_consistency_before_push() -> push_pos = workflow.index('git push origin') assert bump_pos < check_pos < push_pos assert 'sed -i' not in workflow + + +def test_bump_rolls_deprecated_vertexai_minor_cap_like_evaluators(tmp_path: Path) -> None: + """genkit-vertexai is 0.x-only: its genkit dep and the genkit[vertexai] extras cap at the next minor.""" + _make_workspace_fixture(tmp_path, '0.14.0', include_evaluators=False) + _write_pkg( + tmp_path, + 'genkit', + '0.14.0', + dependencies=['pydantic>=2.11'], + optional_dependencies={ + 'openai': ['genkit-openai>=0.14.0,<2'], + 'model-hub': ['genkit-model-hub[anthropic,openai]>=0.14.0,<2'], + 'vertexai': ['genkit-vertexai[anthropic,openai]>=0.14.0,<0.15'], + }, + ) + _write_pkg( + tmp_path, + 'genkit-vertexai', + '0.14.0', + dependencies=['genkit>=0.14.0,<0.15'], + optional_dependencies={'anthropic': ['genkit-anthropic==0.14.0'], 'openai': ['genkit-openai==0.14.0']}, + ) + assert _workspace_errors(tmp_path) == [] + + _run_bump(tmp_path, '0.15.0') + assert _workspace_errors(tmp_path) == [] + + genkit_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit' / 'pyproject.toml'))['project'] + assert genkit_proj['optional-dependencies']['vertexai'] == ['genkit-vertexai[anthropic,openai]>=0.15.0,<0.16'] + vertex_proj = consistency.load_pyproject(str(tmp_path / 'packages' / 'genkit-vertexai' / 'pyproject.toml'))[ + 'project' + ] + assert vertex_proj['dependencies'] == ['genkit>=0.15.0,<0.16'] + assert vertex_proj['optional-dependencies']['anthropic'] == ['genkit-anthropic==0.15.0'] + + +def test_consistency_rejects_unretired_vertexai_at_1_0_0(tmp_path: Path) -> None: + """genkit-vertexai must be gone before a 1.0 release, the same rule as genkit-evaluators.""" + _make_workspace_fixture(tmp_path, '1.0.0', include_evaluators=False) + _write_pkg(tmp_path, 'genkit-vertexai', '1.0.0', dependencies=['genkit>=1.0.0,<2']) + + errors = _workspace_errors(tmp_path) + assert any('0.x-only package (<1), which must be retired before 1.0.0' in err for err in errors), errors