8000 fix(cli): Add auto-reload flag · usingsystem007/adk-python@85ccacb · GitHub
[go: up one dir, main page]

Skip to content

Commit 85ccacb

Browse files
nneverweicopybara-github
authored andcommitted
fix(cli): Add auto-reload flag
Copybara import of the project: -- a4a998d by 魏超 <nneverwei@gmail.com>: fix(cli): Disable auto-reload feature on Windows system Fixed the issue caused by the auto-reload feature when running the CLI tool on Windows system. By detecting the operating system type, the auto-reload is disabled on Windows system to avoid potential errors: When mcp is asynchronously loaded, it will enter the _make_subprocess_transport NotImplementedError logic due to uvicorn reload=True in fastapi. -- 46c9bb6 by 魏超 <nneverwei@gmail.com>: add an option in the CLI to enable or disable the reload feature. So users(esp. windows) can disable this if they come across the '_make_subprocess_transport NotImplementedError' bug on windows. COPYBARA_INTEGRATE_REVIEW=google#415 from nneverwei:win-subprocess-NotImplError-with-mcp fbb9ab0 PiperOrigin-RevId: 756360981
1 parent d45084f commit 85ccacb

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/google/adk/cli/cli_tools_click.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,11 @@ def cli_eval(
352352
default=False,
353353
help="Optional. Whether to enable cloud trace for telemetry.",
354354
)
355+
@click.option(
356+
"--reload/--no-reload",
357+
default=True,
358+
help="Optional. Whether to enable auto reload for server.",
359+
)
355360
@click.argument(
356361
"agents_dir",
357362
type=click.Path(
@@ -367,6 +372,7 @@ def cli_web(
367372
allow_origins: Optional[list[str]] = None,
368373
port: int = 8000,
369374
trace_to_cloud: bool = False,
375+
reload: bool = True,
370376
):
371377
"""Starts a FastAPI server with Web UI for agents.
372378
@@ -418,7 +424,7 @@ async def _lifespan(app: FastAPI):
418424
app,
419425
host="0.0.0.0",
420426
port=port,
421-
reload=True,
427+
reload=reload,
422428
)
423429

424430
server = uvicorn.Server(config)
@@ -474,6 +480,11 @@ async def _lifespan(app: FastAPI):
474480
default=False,
475481
help="Optional. Whether to enable cloud trace for telemetry.",
476482
)
483+
@click.option(
484+
"--reload/--no-reload",
485+
default=True,
486+
help="Optional. Whether to enable auto reload for server.",
487+
)
477488
# The directory of agents, where each sub-directory is a single agent.
478489
# By default, it is the current working directory
479490
@click.argument(
@@ -491,6 +502,7 @@ def cli_api_server(
491502
allow_origins: Optional[list[str]] = None,
492503
port: int = 8000,
493504
trace_to_cloud: bool = False,
505+
reload: bool = True,
494506
):
495507
"""Starts a FastAPI server for agents.
496508
@@ -518,7 +530,7 @@ def cli_api_server(
518530
),
519531
host="0.0.0.0",
520532
port=port,
521-
reload=True,
533+
reload=reload,
522534
)
523535
server = uvicorn.Server(config)
524536
server.run()

0 commit comments

Comments
 (0)
0