Skip to content

Commit 206a132

Browse files
yeesiancopybara-github
authored andcommitted
feat: Add a CLI option to update an agent engine instance
PiperOrigin-RevId: 786816663
1 parent 3be0882 commit 206a132

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/google/adk/cli/cli_deploy.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ def to_agent_engine(
253253
temp_folder: str,
254254
adk_app: str,
255255
staging_bucket: str,
256+
agent_engine_name: str,
256257
trace_to_cloud: bool,
257258
absolutize_imports: bool = True,
258259
project: Optional[str] = None,
@@ -293,6 +294,8 @@ def to_agent_engine(
293294
project (str): Google Cloud project id.
294295
region (str): Google Cloud region.
295296
staging_bucket (str): The GCS bucket for staging the deployment artifacts.
297+
agent_engine_name (str): The name of the Agent Engine instance to update if
298+
it exists. Format: `projects/{project}/locations/{location}/reasoningEngines/{resource_id}`.
296299
trace_to_cloud (bool): Whether to enable Cloud Trace.
297300
absolutize_imports (bool): Whether to absolutize imports. If True, all relative
298301
imports will be converted to absolute import statements. Default is True.
@@ -424,15 +427,19 @@ def to_agent_engine(
424427
},
425428
sys_paths=[temp_folder[1:]],
426429
)
427-
428-
agent_engines.create(
430+
agent_config = dict(
429431
agent_engine=agent_engine,
430432
requirements=requirements_file,
431433
display_name=display_name,
432434
description=description,
433435
env_vars=env_vars,
434436
extra_packages=[temp_folder],
435437
)
438+
439+
if not agent_engine_name:
440+
agent_engines.create(**agent_config)
441+
else:
442+
agent_engines.update(resource_name=agent_engine_name, **agent_config)
436443
finally:
437444
click.echo(f'Cleaning up the temp folder: {temp_folder}')
438445
shutil.rmtree(temp_folder)

src/google/adk/cli/cli_tools_click.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,17 @@ def cli_deploy_cloud_run(
10091009
type=str,
10101010
help="Required. GCS bucket for staging the deployment artifacts.",
10111011
)
1012+
@click.option(
1013+
"--agent_engine_name",
1014+
type=str,
1015+
default=None,
1016+
help=(
1017+
"Optional. Name of the Agent Engine instance to update if it exists"
1018+
" (default: None, which means a new instance will be created)."
1019+
" Format:"
1020+
" `projects/{project}/locations/{location}/reasoningEngines/{resource_id}`."
1021+
),
1022+
)
10121023
@click.option(
10131024
"--trace_to_cloud",
10141025
type=bool,
@@ -1094,6 +1105,7 @@ def cli_deploy_agent_engine(
10941105
project: str,
10951106
region: str,
10961107
staging_bucket: str,
1108+
agent_engine_name: Optional[str],
10971109
trace_to_cloud: bool,
10981110
display_name: str,
10991111
description: str,
@@ -1117,6 +1129,7 @@ def cli_deploy_agent_engine(
11171129
project=project,
11181130
region=region,
11191131
staging_bucket=staging_bucket,
1132+
agent_engine_name=agent_engine_name,
11201133
trace_to_cloud=trace_to_cloud,
11211134
display_name=display_name,
11221135
description=description,

0 commit comments

Comments
 (0)