8000 feat!: add `--adk_version` arg to `adk deploy cloud_run`. · iamulya/adk-python@a1ddf0b · GitHub
[go: up one dir, main page]

Skip to content

Commit a1ddf0b

Browse files
wuliang229copybara-github
authored andcommitted
feat!: add --adk_version arg to adk deploy cloud_run.
The default version for Cloud Run deployment is changed to the version in the dev environment instead of the latest version. PiperOrigin-RevId: 759767654
1 parent 801549f commit a1ddf0b

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/google/adk/cli/cli_deploy.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
# Set up environment variables - End
4343
4444
# Install ADK - Start
45-
RUN pip install google-adk
45+
RUN pip install google-adk=={adk_version}
4646
# Install ADK - End
4747
4848
# Copy agent - Start
@@ -86,6 +86,7 @@ def to_cloud_run(
8686
with_ui: bool,
8787
verbosity: str,
8888
session_db_url: str,
89+
adk_version: str,
8990
):
9091
"""Deploys an agent to Google Cloud Run.
9192
@@ -114,6 +115,7 @@ def to_cloud_run(
114115
with_ui: Whether to deploy with UI.
115116
verbosity: The verbosity level of the CLI.
116117
session_db_url: The database URL to connect the session.
118+
adk_version: The ADK version to use in Cloud Run.
117119
"""
118120
app_name = app_name or os.path.basename(agent_folder)
119121

@@ -150,6 +152,7 @@ def to_cloud_run(
150152
if session_db_url
151153
else '',
152154
trace_to_cloud_option='--trace_to_cloud' if trace_to_cloud else '',
155+
adk_version=adk_version,
153156
)
154157
dockerfile_path = os.path.join(temp_folder, 'Dockerfile')
155158
os.makedirs(temp_folder, exist_ok=True)

src/google/adk/cli/cli_tools_click.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
import logging
1919
import os
2020
import tempfile
21-
from typing import AsyncGenerator
22-
from typing import Coroutine
2321
from typing import Optional
2422

2523
import click
@@ -28,6 +26,7 @@
2826

2927
from . import cli_create
3028
from . import cli_deploy
29+
from .. import version
3130
from .cli import run_cli
3231
from .cli_eval import MISSING_EVAL_DEPENDENCIES_MESSAGE
3332
from .fast_api import get_fast_api_app
@@ -712,6 +711,16 @@ def cli_api_server(
712711
exists=True, dir_okay=True, file_okay=False, resolve_path=True
713712
),
714713
)
714+
@click.option(
715+
"--adk_version",
716+
type=str,
717+
default=version.__version__,
718+
show_default=True,
719+
help=(
720+
"Optional. The ADK version used in Cloud Run deployment. (default: the"
721+
" version in the dev environment)"
722+
),
723+
)
715724
def cli_deploy_cloud_run(
716725
agent: str,
717726
project: Optional[str],
@@ -724,6 +733,7 @@ d 8000 ef cli_deploy_cloud_run(
724733
with_ui: bool,
725734
verbosity: str,
726735
session_db_url: str,
736+
adk_version: str,
727737
):
728738
"""Deploys an agent to Cloud Run.
729739
@@ -746,6 +756,7 @@ def cli_deploy_cloud_run(
746756
with_ui=with_ui,
747757
verbosity=verbosity,
748758
session_db_url=session_db_url,
759+
adk_version=adk_version,
749760
)
750761
except Exception as e:
751762
click.secho(f"Deploy failed: {e}", fg="red", err=True)

tests/unittests/cli/utils/test_cli_deploy.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def _recording_copytree(*args: Any, **kwargs: Any):
124124
with_ui=True,
125125
verbosity="info",
126126
session_db_url="sqlite://",
127+
adk_version="0.0.5",
127128
)
128129

129130
# Assertions
@@ -163,6 +164,7 @@ def _fake_rmtree(path: str | Path, *a: Any, **k: Any) -> None:
163164
with_ui=False,
164165
verbosity="info",
165166
session_db_url=None,
167+
adk_version="0.0.5",
166168
)
167169

168170
assert deleted["path"] == tmp_dir

0 commit comments

Comments
 (0)
0