Skip to content

Commit ba6e85e

Browse files
wuliang229copybara-github
authored andcommitted
docs(config): fix core_callback example
PiperOrigin-RevId: 795619488
1 parent c843503 commit ba6e85e

File tree

5 files changed

+17
-110
lines changed

5 files changed

+17
-110
lines changed

contributing/samples/core_callback/__init__.py

Whitespace-only changes.

contributing/samples/core_callback/root_agent.yaml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@ instruction: |
1919
You should always perform the previous 3 steps when asking for a roll and checking prime numbers.
2020
You should not rely on the previous history on prime results.
2121
tools:
22-
- name: callbacks.tools.roll_die
23-
- name: callbacks.tools.check_prime
22+
- name: core_callback.tools.roll_die
23+
- name: core_callback.tools.check_prime
2424
before_agent_callbacks:
25-
- name: callbacks.callbacks.before_agent_callback1
26-
- name: callbacks.callbacks.before_agent_callback2
27-
- name: callbacks.callbacks.before_agent_callback3
25+
- name: core_callback.callbacks.before_agent_callback1
26+
- name: core_callback.callbacks.before_agent_callback2
27+
- name: core_callback.callbacks.before_agent_callback3
2828
after_agent_callbacks:
29-
- name: callbacks.callbacks.after_agent_callback1
30-
- name: callbacks.callbacks.after_agent_callback2
31-
- name: callbacks.callbacks.after_agent_callback3
29+
- name: core_callback.callbacks.after_agent_callback1
30+
- name: core_callback.callbacks.after_agent_callback2
31+
- name: core_callback.callbacks.after_agent_callback3
3232
before_model_callbacks:
33-
- name: callbacks.callbacks.before_model_callback
33+
- name: core_callback.callbacks.before_model_callback
3434
after_model_callbacks:
35-
- name: callbacks.callbacks.after_model_callback
35+
- name: core_callback.callbacks.after_model_callback
3636
before_tool_callbacks:
37-
- name: callbacks.callbacks.before_tool_callback1
38-
- name: callbacks.callbacks.before_tool_callback2
39-
- name: callbacks.callbacks.before_tool_callback3
37+
- name: core_callback.callbacks.before_tool_callback1
38+
- name: core_callback.callbacks.before_tool_callback2
39+
- name: core_callback.callbacks.before_tool_callback3
4040
after_tool_callbacks:
41-
- name: callbacks.callbacks.after_tool_callback1
42-
- name: callbacks.callbacks.after_tool_callback2
43-
- name: callbacks.callbacks.after_tool_callback3
41+
- name: core_callback.callbacks.after_tool_callback1
42+
- name: core_callback.callbacks.after_tool_callback2
43+
- name: core_callback.callbacks.after_tool_callback3

src/google/adk/cli/cli_deploy.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@
2121
import click
2222
from packaging.version import parse
2323

24-
BASE_BUILD_IMAGE = 'python:3.11-slim'
25-
2624
_DOCKERFILE_TEMPLATE = """
27-
FROM {build_image}
25+
FROM python:3.11-slim
2826
WORKDIR /app
2927
3028
# Create a non-root user
@@ -132,7 +130,6 @@ def to_cloud_run(
132130
session_service_uri: Optional[str] = None,
133131
artifact_service_uri: Optional[str] = None,
134132
memory_service_uri: Optional[str] = None,
135-
build_image: Optional[str] = BASE_BUILD_IMAGE,
136133
a2a: bool = False,
137134
):
138135
"""Deploys an agent to Google Cloud Run.
@@ -166,7 +163,6 @@ def to_cloud_run(
166163
session_service_uri: The URI of the session service.
167164
artifact_service_uri: The URI of the artifact service.
168165
memory_service_uri: The URI of the memory service.
169-
build_image: The image to use for building the Dockerfile.
170166
"""
171167
app_name = app_name or os.path.basename(agent_folder)
172168

@@ -215,7 +211,6 @@ def to_cloud_run(
215211
adk_version=adk_version,
216212
host_option=host_option,
217213
a2a_option=a2a_option,
218-
build_image=build_image,
219214
)
220215
dockerfile_path = os.path.join(temp_folder, 'Dockerfile')
221216
os.makedirs(temp_folder, exist_ok=True)
@@ -479,7 +474,6 @@ def to_gke(
479474
session_service_uri: Optional[str] = None,
480475
artifact_service_uri: Optional[str] = None,
481476
memory_service_uri: Optional[str] = None,
482-
build_image: Optional[str] = BASE_BUILD_IMAGE,
483477
a2a: bool = False,
484478
):
485479
"""Deploys an agent to Google Kubernetes Engine(GKE).
@@ -501,7 +495,6 @@ def to_gke(
501495
session_service_uri: The URI of the session service.
502496
artifact_service_uri: The URI of the artifact service.
503497
memory_service_uri: The URI of the memory service.
504-
build_image: The image to use for building the Dockerfile.
505498
"""
506499
click.secho(
507500
'\n🚀 Starting ADK Agent Deployment to GKE...', fg='cyan', bold=True
@@ -563,7 +556,6 @@ def to_gke(
563556
adk_version=adk_version,
564557
host_option=host_option,
565558
a2a_option='--a2a' if a2a else '',
566-
build_image=build_image,
567559
)
568560
dockerfile_path = os.path.join(temp_folder, 'Dockerfile')
569561
os.makedirs(temp_folder, exist_ok=True)

src/google/adk/cli/cli_tools_click.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
case_sensitive=False,
4545
)
4646

47-
BASE_BUILD_IMAGE = "python:3.11-slim"
48-
4947

5048
class HelpfulCommand(click.Command):
5149
"""Command that shows full help on error instead of just the error message.
@@ -970,13 +968,6 @@ def cli_api_server(
970968
help="Optional. Any additional origins to allow for CORS.",
971969
multiple=True,
972970
)
973-
@click.option(
974-
"--build_image",
975-
type=str,
976-
default=BASE_BUILD_IMAGE,
977-
show_default=True,
978-
help="Optional. The docker build version used in Cloud Run deployment. ",
979-
)
980971
# TODO: Add eval_storage_uri option back when evals are supported in Cloud Run.
981972
@adk_services_options()
982973
@deprecated_adk_services_options()
@@ -1000,7 +991,6 @@ def cli_deploy_cloud_run(
1000991
session_db_url: Optional[str] = None, # Deprecated
1001992
artifact_storage_uri: Optional[str] = None, # Deprecated
1002993
a2a: bool = False,
1003-
build_image: Optional[str] = BASE_BUILD_IMAGE,
1004994
):
1005995
"""Deploys an agent to Cloud Run.
1006996
@@ -1039,7 +1029,6 @@ def cli_deploy_cloud_run(
10391029
artifact_service_uri=artifact_service_uri,
10401030
memory_service_uri=memory_service_uri,
10411031
a2a=a2a,
1042-
build_image=build_image,
10431032
)
10441033
except Exception as e:
10451034
click.secho(f"Deploy failed: {e}", fg="red", err=True)
@@ -1292,13 +1281,6 @@ def cli_deploy_agent_engine(
12921281
" version in the dev environment)"
12931282
),
12941283
)
1295-
@click.option(
1296-
"--build_image",
1297-
type=str,
1298-
default=BASE_BUILD_IMAGE,
1299-
show_default=True,
1300-
help="Optional. The docker build version used in GKE deployment. ",
1301-
)
13021284
@adk_services_options()
13031285
@click.argument(
13041286
"agent",
@@ -1322,7 +1304,6 @@ def cli_deploy_gke(
13221304
session_service_uri: Optional[str] = None,
13231305
artifact_service_uri: Optional[str] = None,
13241306
memory_service_uri: Optional[str] = None,
1325-
build_image: Optional[str] = BASE_BUILD_IMAGE,
13261307
):
13271308
"""Deploys an agent to GKE.
13281309
@@ -1349,7 +1330,6 @@ def cli_deploy_gke(
13491330
session_service_uri=session_service_uri,
13501331
artifact_service_uri=artifact_service_uri,
13511332
memory_service_uri=memory_service_uri,
1352-
build_image=build_image,
13531333
)
13541334
except Exception as e:
13551335
click.secho(f"Deploy failed: {e}", fg="red", err=True)

tests/unittests/cli/utils/test_cli_tools_click.py

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -168,43 +168,11 @@ def test_cli_deploy_cloud_run_success(
168168
"proj",
169169
"--region",
170170
"asia-northeast1",
171-
"--build_image",
172-
"my-custom-image",
173171
str(agent_dir),
174172
],
175173
)
176174
assert result.exit_code == 0
177175
assert rec.calls, "cli_deploy.to_cloud_run must be invoked"
178-
called_kwargs = rec.calls[0][1]
179-
assert called_kwargs.get("build_image") == "my-custom-image"
180-
181-
182-
def test_cli_deploy_cloud_run_default_build_image(
183-
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
184-
) -> None:
185-
"""Test that the default build_image is used."""
186-
rec = _Recorder()
187-
monkeypatch.setattr(cli_tools_click.cli_deploy, "to_cloud_run", rec)
188-
189-
agent_dir = tmp_path / "agent2"
190-
agent_dir.mkdir()
191-
runner = CliRunner()
192-
result = runner.invoke(
193-
cli_tools_click.main,
194-
[
195-
"deploy",
196-
"cloud_run",
197-
"--project",
198-
"proj",
199-
"--region",
200-
"asia-northeast1",
201-
str(agent_dir),
202-
],
203-
)
204-
assert result.exit_code == 0
205-
assert rec.calls, "cli_deploy.to_cloud_run must be invoked"
206-
called_kwargs = rec.calls[0][1]
207-
assert called_kwargs.get("build_image") == cli_tools_click.BASE_BUILD_IMAGE
208176

209177

210178
def test_cli_deploy_cloud_run_failure(
@@ -283,8 +251,6 @@ def test_cli_deploy_gke_success(
283251
"us-central1",
284252
"--cluster_name",
285253
"my-cluster",
286-
"--build_image",
287-
"my-gke-image",
288254
str(agent_dir),
289255
],
290256
)
@@ -294,37 +260,6 @@ def test_cli_deploy_gke_success(
294260
assert called_kwargs.get("project") == "test-proj"
295261
assert called_kwargs.get("region") == "us-central1"
296262
assert called_kwargs.get("cluster_name") == "my-cluster"
297-
assert called_kwargs.get("build_image") == "my-gke-image"
298-
299-
300-
def test_cli_deploy_gke_default_build_image(
301-
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
302-
) -> None:
303-
"""Test that the default build_image is used for gke."""
304-
rec = _Recorder()
305-
monkeypatch.setattr(cli_tools_click.cli_deploy, "to_gke", rec)
306-
307-
agent_dir = tmp_path / "agent_gke"
308-
agent_dir.mkdir()
309-
runner = CliRunner()
310-
result = runner.invoke(
311-
cli_tools_click.main,
312-
[
313-
"deploy",
314-
"gke",
315-
"--project",
316-
"test-proj",
317-
"--region",
318-
"us-central1",
319-
"--cluster_name",
320-
"my-cluster",
321-
str(agent_dir),
322-
],
323-
)
324-
assert result.exit_code == 0
325-
assert rec.calls, "cli_deploy.to_gke must be invoked"
326-
called_kwargs = rec.calls[0][1]
327-
assert called_kwargs.get("build_image") == cli_tools_click.BASE_BUILD_IMAGE
328263

329264

330265
# cli eval

0 commit comments

Comments
 (0)