Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/unit/vertexai/genai/test_agent_engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -2517,6 +2517,19 @@ def test_update_agent_engine_extra_packages(
None,
)

@mock.patch.object(_agent_engines_utils, "_prepare")
@mock.patch.object(_agent_engines_utils, "_await_operation")
def test_update_agent_engine_deployment_config_without_agent_raises(
self, mock_await_operation, mock_prepare
):
with pytest.raises(ValueError, match="To update `env_vars`"):
self.client.agent_engines.update(
name=_TEST_AGENT_ENGINE_RESOURCE_NAME,
config=_genai_types.AgentEngineConfig(
env_vars=_TEST_AGENT_ENGINE_ENV_VARS_INPUT
),
)

@mock.patch.object(_agent_engines_utils, "_prepare")
@mock.patch.object(_agent_engines_utils, "_await_operation")
def test_update_agent_engine_env_vars(
Expand Down
25 changes: 17 additions & 8 deletions vertexai/_genai/agent_engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -1305,15 +1305,24 @@ def _create_config(
image_spec=image_spec,
)

is_deployment_spec_updated = (
env_vars is not None
or psc_interface_config is not None
or min_instances is not None
or max_instances is not None
or resource_limits is not None
or container_concurrency is not None
)
if agent_engine_spec is None and is_deployment_spec_updated:
raise ValueError(
"To update `env_vars`, `psc_interface_config`, `min_instances`, "
"`max_instances`, `resource_limits`, or `container_concurrency`, "
"you must also provide the `agent` variable or the source code "
"options (`source_packages` or `developer_connect_source`)."
)

if agent_engine_spec is not None:
if (
env_vars is not None
or psc_interface_config is not None
or min_instances is not None
or max_instances is not None
or resource_limits is not None
or container_concurrency is not None
):
if is_deployment_spec_updated:
(
deployment_spec,
deployment_update_masks,
Expand Down
Loading