8000 feat: Add session_db_url to `adk deploy` option. · goodrules/adk-python@a9da7a8 · GitHub
[go: up one dir, main page]

Skip to content

Commit a9da7a8

Browse files
DeanChensjcopybara-github
authored andcommitted
feat: Add session_db_url to adk deploy option.
PiperOrigin-RevId: 750355535
1 parent 956fb91 commit a9da7a8

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

src/google/adk/cli/cli_deploy.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
5555
EXPOSE {port}
5656
57-
CMD adk {command} --port={port} {trace_to_cloud_option} "/app/agents"
57+
CMD adk {command} --port={port} {session_db_option} {trace_to_cloud_option} "/app/agents"
5858
"""
5959

6060

@@ -85,6 +85,7 @@ def to_cloud_run(
8585
trace_to_cloud: bool,
8686
with_ui: bool,
8787
verbosity: str,
88+
session_db_url: str,
8889
):
8990
"""Deploys an agent to Google Cloud Run.
9091
@@ -112,6 +113,7 @@ def to_cloud_run(
112113
trace_to_cloud: Whether to enable Cloud Trace.
113114
with_ui: Whether to deploy with UI.
114115
verbosity: The verbosity level of the CLI.
116+
session_db_url: The database URL to connect the session.
115117
"""
116118
app_name = app_name or os.path.basename(agent_folder)
117119

@@ -144,6 +146,9 @@ def to_cloud_run(
144146
port=port,
145147
command='web' if with_ui else 'api_server',
146148
install_agent_deps=install_agent_deps,
149+
session_db_option=f'--session_db_url={session_db_url}'
150+
if session_db_url
151+
else '',
147152
trace_to_cloud_option='--trace_to_cloud' if trace_to_cloud else '',
148153
)
149154
dockerfile_path = os.path.join(temp_folder, 'Dockerfile')

src/google/adk/cli/cli_tools_click.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,13 @@ def cli_eval(
245245
@click.option(
246246
"--session_db_url",
247247
help=(
248-
"Optional. The database URL to store the session.\n\n - Use"
249-
" 'agentengine://<agent_engine_resource_id>' to connect to Vertex"
250-
" managed session service.\n\n - Use 'sqlite://<path_to_sqlite_file>'"
251-
" to connect to a SQLite DB.\n\n - See"
252-
" https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls"
253-
" for more details on supported DB URLs."
248+
"""Optional. The database URL to store the session.
249+
250+
- Use 'agentengine://<agent_engine_resource_id>' to connect to Agent Engine sessions.
251+
252+
- Use 'sqlite://<path_to_sqlite_file>' to connect to a SQLite DB.
253+
254+
- See https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls for more details on supported DB URLs."""
254255
),
255256
)
256257
@click.option(
@@ -366,12 +367,13 @@ async def _lifespan(app: FastAPI):
366367
@click.option(
367368
"--session_db_url",
368369
help=(
369-
"Optional. The database URL to store the session.\n\n - Use"
370-
" 'agentengine://<agent_engine_resource_id>' to connect to Vertex"
371-
" managed session service.\n\n - Use 'sqlite://<path_to_sqlite_file>'"
372-
" to connect to a SQLite DB.\n\n - See"
373-
" https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls"
374-
" for more details on supported DB URLs."
370+
"""Optional. The database URL to store the session.
371+
372+
- Use 'agentengine://<agent_engine_resource_id>' to connect to Agent Engine sessions.
373+
374+
- Use 'sqlite://<path_to_sqlite_file>' to connect to a SQLite DB.
375+
376+
- See https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls for more details on supported DB URLs."""
375377
),
376378
)
377379
@click.option(
@@ -541,6 +543,18 @@ def cli_api_server(
541543
default="WARNING",
542544
help="Optional. Override the default verbosity level.",
543545
)
546+
@click.option(
547+
"--session_db_url",
548+
help=(
549+
"""Optional. The database URL to store the session.
550+
551+
- Use 'agentengine://<agent_engine_resource_id>' to connect to Agent Engine sessions.
552+
553+
- Use 'sqlite://<path_to_sqlite_file>' to connect to a SQLite DB.
554+
555+
- See https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls for more details on supported DB URLs."""
556+
),
557+
)
544558
@click.argument(
545559
"agent",
546560
type=click.Path(
@@ -558,6 +572,7 @@ def cli_deploy_cloud_run(
558572
trace_to_cloud: bool,
559573
with_ui: bool,
560574
verbosity: str,
575+
session_db_url: str,
561576
):
562577
"""Deploys an agent to Cloud Run.
563578
@@ -579,6 +594,7 @@ def cli_deploy_cloud_run(
579594
trace_to_cloud=trace_to_cloud,
580595
with_ui=with_ui,
581596
verbosity=verbosity,
597+
session_db_url=session_db_url,
582598
)
583599
except Exception as e:
584600
click.secho(f"Deploy failed: {e}", fg="red", err=True)

0 commit comments

Comments
 (0)
0