Skip to content

Commit 1ca0ba6

Browse files
DeanChensjloic-combis
authored andcommitted
chore: Remove deprecated CLI flags and version-based service URI handling
This change removes support for the deprecated `--session_db_url`, `--artifact_storage_uri`, and `--verbosity` flags from the ADK CLI. It also simplifies the service URI handling in `cli_deploy.py` by always using the new `--session_service_uri`, `--artifact_service_uri`, and `--memory_service_uri` flags, regardless of the ADK version. The deprecated flags has been more than 1 year Co-authored-by: Shangjie Chen <deanchen@google.com> PiperOrigin-RevId: 915100881
1 parent 4ca87f5 commit 1ca0ba6

4 files changed

Lines changed: 16 additions & 117 deletions

File tree

src/google/adk/cli/cli_deploy.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -598,18 +598,12 @@ def _get_service_option_by_adk_version(
598598
parsed_version = parse(adk_version)
599599
options: list[str] = []
600600

601-
if parsed_version >= parse('1.3.0'):
602-
if session_uri:
603-
options.append(f'--session_service_uri={session_uri}')
604-
if artifact_uri:
605-
options.append(f'--artifact_service_uri={artifact_uri}')
606-
if memory_uri:
607-
options.append(f'--memory_service_uri={memory_uri}')
608-
else:
609-
if session_uri:
610-
options.append(f'--session_db_url={session_uri}')
611-
if parsed_version >= parse('1.2.0') and artifact_uri:
612-
options.append(f'--artifact_storage_uri={artifact_uri}')
601+
if session_uri:
602+
options.append(f'--session_service_uri={session_uri}')
603+
if artifact_uri:
604+
options.append(f'--artifact_service_uri={artifact_uri}')
605+
if memory_uri:
606+
options.append(f'--memory_service_uri={memory_uri}')
613607

614608
if use_local_storage is not None and parsed_version >= parse(
615609
_LOCAL_STORAGE_FLAG_MIN_VERSION

src/google/adk/cli/cli_tools_click.py

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,43 +1411,6 @@ def _deprecate_staging_bucket(ctx, param, value):
14111411
return value
14121412

14131413

1414-
def deprecated_adk_services_options():
1415-
"""Deprecated ADK services options."""
1416-
1417-
def warn(alternative_param, ctx, param, value):
1418-
if value:
1419-
click.echo(
1420-
click.style(
1421-
f"WARNING: Deprecated option --{param.name} is used. Please use"
1422-
f" {alternative_param} instead.",
1423-
fg="yellow",
1424-
),
1425-
err=True,
1426-
)
1427-
return value
1428-
1429-
def decorator(func):
1430-
@click.option(
1431-
"--session_db_url",
1432-
help="Deprecated. Use --session_service_uri instead.",
1433-
callback=functools.partial(warn, "--session_service_uri"),
1434-
)
1435-
@click.option(
1436-
"--artifact_storage_uri",
1437-
type=str,
1438-
help="Deprecated. Use --artifact_service_uri instead.",
1439-
callback=functools.partial(warn, "--artifact_service_uri"),
1440-
default=None,
1441-
)
1442-
@functools.wraps(func)
1443-
def wrapper(*args, **kwargs):
1444-
return func(*args, **kwargs)
1445-
1446-
return wrapper
1447-
1448-
return decorator
1449-
1450-
14511414
def fast_api_common_options():
14521415
"""Decorator to add common fast api options to click commands."""
14531416

@@ -1598,7 +1561,6 @@ def wrapper(ctx, *args, **kwargs):
15981561
@fast_api_common_options()
15991562
@web_options()
16001563
@adk_services_options(default_use_local_storage=True)
1601-
@deprecated_adk_services_options()
16021564
@click.argument(
16031565
"agents_dir",
16041566
type=click.Path(
@@ -1621,8 +1583,6 @@ def cli_web(
16211583
artifact_service_uri: Optional[str] = None,
16221584
memory_service_uri: Optional[str] = None,
16231585
use_local_storage: bool = True,
1624-
session_db_url: Optional[str] = None, # Deprecated
1625-
artifact_storage_uri: Optional[str] = None, # Deprecated
16261586
a2a: bool = False,
16271587
reload_agents: bool = False,
16281588
extra_plugins: Optional[list[str]] = None,
@@ -1639,8 +1599,6 @@ def cli_web(
16391599
16401600
adk web --session_service_uri=[uri] --port=[port] path/to/agents_dir
16411601
"""
1642-
session_service_uri = session_service_uri or session_db_url
1643-
artifact_service_uri = artifact_service_uri or artifact_storage_uri
16441602
logs.setup_adk_logger(getattr(logging, log_level.upper()))
16451603

16461604
@asynccontextmanager
@@ -1711,7 +1669,6 @@ async def _lifespan(app: FastAPI):
17111669
)
17121670
@fast_api_common_options()
17131671
@adk_services_options(default_use_local_storage=True)
1714-
@deprecated_adk_services_options()
17151672
@click.option(
17161673
"--auto_create_session",
17171674
is_flag=True,
@@ -1735,8 +1692,6 @@ def cli_api_server(
17351692
artifact_service_uri: Optional[str] = None,
17361693
memory_service_uri: Optional[str] = None,
17371694
use_local_storage: bool = True,
1738-
session_db_url: Optional[str] = None, # Deprecated
1739-
artifact_storage_uri: Optional[str] = None, # Deprecated
17401695
a2a: bool = False,
17411696
reload_agents: bool = False,
17421697
extra_plugins: Optional[list[str]] = None,
@@ -1752,8 +1707,6 @@ def cli_api_server(
17521707
17531708
adk api_server --session_service_uri=[uri] --port=[port] path/to/agents_dir
17541709
"""
1755-
session_service_uri = session_service_uri or session_db_url
1756-
artifact_service_uri = artifact_service_uri or artifact_storage_uri
17571710
logs.setup_adk_logger(getattr(logging, log_level.upper()))
17581711

17591712
config = uvicorn.Config(
@@ -1882,11 +1835,6 @@ def cli_api_server(
18821835
default="INFO",
18831836
help="Optional. Set the logging level",
18841837
)
1885-
@click.option(
1886-
"--verbosity",
1887-
type=LOG_LEVELS,
1888-
help="Deprecated. Use --log_level instead.",
1889-
)
18901838
@click.argument(
18911839
"agent",
18921840
type=click.Path(
@@ -1932,7 +1880,6 @@ def cli_api_server(
19321880
)
19331881
# TODO: Add eval_storage_uri option back when evals are supported in Cloud Run.
19341882
@adk_services_options(default_use_local_storage=False)
1935-
@deprecated_adk_services_options()
19361883
@click.pass_context
19371884
def cli_deploy_cloud_run(
19381885
ctx,
@@ -1948,14 +1895,11 @@ def cli_deploy_cloud_run(
19481895
with_ui: bool,
19491896
adk_version: str,
19501897
log_level: str,
1951-
verbosity: Optional[str],
19521898
allow_origins: Optional[list[str]] = None,
19531899
session_service_uri: Optional[str] = None,
19541900
artifact_service_uri: Optional[str] = None,
19551901
memory_service_uri: Optional[str] = None,
19561902
use_local_storage: bool = False,
1957-
session_db_url: Optional[str] = None, # Deprecated
1958-
artifact_storage_uri: Optional[str] = None, # Deprecated
19591903
a2a: bool = False,
19601904
trigger_sources: Optional[str] = None,
19611905
):
@@ -1972,19 +1916,9 @@ def cli_deploy_cloud_run(
19721916
adk deploy cloud_run --project=[project] --region=[region] path/to/my_agent
19731917
-- --no-allow-unauthenticated --min-instances=2
19741918
"""
1975-
if verbosity:
1976-
click.secho(
1977-
"WARNING: The --verbosity option is deprecated. Use --log_level"
1978-
" instead.",
1979-
fg="yellow",
1980-
err=True,
1981-
)
19821919

19831920
_warn_if_with_ui(with_ui)
19841921

1985-
session_service_uri = session_service_uri or session_db_url
1986-
artifact_service_uri = artifact_service_uri or artifact_storage_uri
1987-
19881922
# Parse arguments to separate gcloud args (after --) from regular args
19891923
gcloud_args = []
19901924
if "--" in ctx.args:
@@ -2028,7 +1962,7 @@ def cli_deploy_cloud_run(
20281962
allow_origins=allow_origins,
20291963
with_ui=with_ui,
20301964
log_level=log_level,
2031-
verbosity=verbosity,
1965+
verbosity=log_level,
20321966
adk_version=adk_version,
20331967
session_service_uri=session_service_uri,
20341968
artifact_service_uri=artifact_service_uri,

tests/unittests/cli/utils/test_cli_deploy.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,21 @@ def test_resolve_project_from_gcloud_fails(
147147
"gs://a",
148148
"rag://m",
149149
None,
150-
"--session_db_url=sqlite://s --artifact_storage_uri=gs://a",
150+
(
151+
"--session_service_uri=sqlite://s --artifact_service_uri=gs://a"
152+
" --memory_service_uri=rag://m"
153+
),
151154
),
152155
(
153156
"0.5.0",
154157
"sqlite://s",
155158
"gs://a",
156159
"rag://m",
157160
None,
158-
"--session_db_url=sqlite://s",
161+
(
162+
"--session_service_uri=sqlite://s --artifact_service_uri=gs://a"
163+
" --memory_service_uri=rag://m"
164+
),
159165
),
160166
(
161167
"1.3.0",
@@ -179,7 +185,7 @@ def test_resolve_project_from_gcloud_fails(
179185
"gs://a",
180186
None,
181187
None,
182-
"--artifact_storage_uri=gs://a",
188+
"--artifact_service_uri=gs://a",
183189
),
184190
(
185191
"1.21.0",

tests/unittests/cli/utils/test_cli_tools_click.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -596,41 +596,6 @@ def test_cli_web_passes_service_uris(
596596
assert called_kwargs.get("memory_service_uri") == "rag://mycorpus"
597597

598598

599-
@pytest.mark.unmute_click
600-
def test_cli_web_warns_and_maps_deprecated_uris(
601-
tmp_path: Path,
602-
_patch_uvicorn: _Recorder,
603-
monkeypatch: pytest.MonkeyPatch,
604-
) -> None:
605-
"""`adk web` should accept deprecated URI flags with warnings."""
606-
agents_dir = tmp_path / "agents"
607-
agents_dir.mkdir()
608-
609-
mock_get_app = _Recorder()
610-
monkeypatch.setattr(cli_tools_click, "get_fast_api_app", mock_get_app)
611-
612-
runner = CliRunner()
613-
result = runner.invoke(
614-
cli_tools_click.main,
615-
[
616-
"web",
617-
str(agents_dir),
618-
"--session_db_url",
619-
"sqlite:///deprecated.db",
620-
"--artifact_storage_uri",
621-
"gs://deprecated",
622-
],
623-
)
624-
625-
assert result.exit_code == 0
626-
called_kwargs = mock_get_app.calls[0][1]
627-
assert called_kwargs.get("session_service_uri") == "sqlite:///deprecated.db"
628-
assert called_kwargs.get("artifact_service_uri") == "gs://deprecated"
629-
# Check output for deprecation warnings (CliRunner captures both stdout and stderr)
630-
assert "--session_db_url" in result.output
631-
assert "--artifact_storage_uri" in result.output
632-
633-
634599
def test_cli_eval_with_eval_set_file_path(
635600
mock_load_eval_set_from_file,
636601
mock_get_root_agent,

0 commit comments

Comments
 (0)