Skip to content

Commit b1ff85f

Browse files
ankursharmascopybara-github
authored andcommitted
chore: Add support for specifying logging level for adk eval cli command
One can now control the logging levels for adk eval cli commands. Co-authored-by: Ankur Sharma <ankusharma@google.com> PiperOrigin-RevId: 826654122
1 parent e8526f7 commit b1ff85f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/google/adk/cli/cli_tools_click.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,12 @@ def decorator(func):
448448
),
449449
default=None,
450450
)
451+
@click.option(
452+
"--log_level",
453+
type=LOG_LEVELS,
454+
default="INFO",
455+
help="Optional. Set the logging level",
456+
)
451457
@functools.wraps(func)
452458
def wrapper(*args, **kwargs):
453459
return func(*args, **kwargs)
@@ -480,6 +486,7 @@ def cli_eval(
480486
config_file_path: str,
481487
print_detailed_results: bool,
482488
eval_storage_uri: Optional[str] = None,
489+
log_level: str = "INFO",
483490
):
484491
"""Evaluates an agent given the eval sets.
485492
@@ -536,6 +543,7 @@ def cli_eval(
536543
PRINT_DETAILED_RESULTS: Prints detailed results on the console.
537544
"""
538545
envs.load_dotenv_for_agent(agent_module_file_path, ".")
546+
logs.setup_adk_logger(getattr(logging, log_level.upper()))
539547

540548
try:
541549
from ..evaluation.base_eval_service import InferenceConfig
@@ -716,10 +724,12 @@ def cli_create_eval_set(
716724
agent_module_file_path: str,
717725
eval_set_id: str,
718726
eval_storage_uri: Optional[str] = None,
727+
log_level: str = "INFO",
719728
):
720729
"""Creates an empty EvalSet given the agent_module_file_path and eval_set_id."""
721730
from .cli_eval import get_eval_sets_manager
722731

732+
logs.setup_adk_logger(getattr(logging, log_level.upper()))
723733
app_name = os.path.basename(agent_module_file_path)
724734
agents_dir = os.path.dirname(agent_module_file_path)
725735
eval_sets_manager = get_eval_sets_manager(eval_storage_uri, agents_dir)
@@ -764,6 +774,7 @@ def cli_add_eval_case(
764774
scenarios_file: str,
765775
eval_storage_uri: Optional[str] = None,
766776
session_input_file: Optional[str] = None,
777+
log_level: str = "INFO",
767778
):
768779
"""Adds eval cases to the given eval set.
769780
@@ -772,6 +783,7 @@ def cli_add_eval_case(
772783
773784
If an eval case for the generated id already exists, then we skip adding it.
774785
"""
786+
logs.setup_adk_logger(getattr(logging, log_level.upper()))
775787
try:
776788
from ..evaluation.conversation_scenarios import ConversationScenarios
777789
from ..evaluation.eval_case import EvalCase

0 commit comments

Comments
 (0)