mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
chore: Replace print statements with logging in ADK
Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 864588921
This commit is contained in:
committed by
Copybara-Service
parent
e87a8437fb
commit
dd8cd27b2c
@@ -14,6 +14,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import re
|
||||
from typing import Dict
|
||||
from typing import List
|
||||
@@ -33,6 +34,8 @@ from ...agents.sequential_agent import SequentialAgent
|
||||
from ...tools.example_tool import ExampleTool
|
||||
from ..experimental import a2a_experimental
|
||||
|
||||
logger = logging.getLogger('google_adk.' + __name__)
|
||||
|
||||
|
||||
@a2a_experimental
|
||||
class AgentCardBuilder:
|
||||
@@ -157,8 +160,8 @@ async def _build_sub_agent_skills(agent: BaseAgent) -> List[AgentSkill]:
|
||||
sub_agent_skills.append(aggregated_skill)
|
||||
except Exception as e:
|
||||
# Log warning but continue with other sub-agents
|
||||
print(
|
||||
f'Warning: Failed to build skills for sub-agent {sub_agent.name}: {e}'
|
||||
logger.warning(
|
||||
'Failed to build skills for sub-agent %s: %s', sub_agent.name, e
|
||||
)
|
||||
continue
|
||||
|
||||
@@ -502,7 +505,7 @@ async def _extract_examples_from_agent(
|
||||
if isinstance(tool, ExampleTool):
|
||||
return _convert_example_tool_examples(tool)
|
||||
except Exception as e:
|
||||
print(f'Warning: Failed to extract examples from tools: {e}')
|
||||
logger.warning('Failed to extract examples from tools: %s', e)
|
||||
|
||||
# If no example_tool found, try to extract examples from instruction
|
||||
if agent.instruction:
|
||||
|
||||
@@ -16,6 +16,7 @@ from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import importlib
|
||||
import logging
|
||||
from typing import Any
|
||||
from typing import AsyncGenerator
|
||||
from typing import Optional
|
||||
@@ -49,6 +50,8 @@ from .simulation.user_simulator import Status as UserSimulatorStatus
|
||||
from .simulation.user_simulator import UserSimulator
|
||||
from .simulation.user_simulator_provider import UserSimulatorProvider
|
||||
|
||||
logger = logging.getLogger("google_adk." + __name__)
|
||||
|
||||
_USER_AUTHOR = "user"
|
||||
_DEFAULT_AUTHOR = "agent"
|
||||
|
||||
@@ -117,7 +120,7 @@ class EvaluationGenerator:
|
||||
|
||||
with open(session_path, "r") as f:
|
||||
session_data = Session.model_validate_json(f.read())
|
||||
print("loaded session", session_path)
|
||||
logger.info("Loaded session %s", session_path)
|
||||
|
||||
for data in eval_dataset:
|
||||
# load session data from session_path
|
||||
|
||||
@@ -16,6 +16,7 @@ from __future__ import annotations
|
||||
|
||||
"""Tool to execute SQL queries against Bigtable."""
|
||||
import json
|
||||
import logging
|
||||
from typing import Any
|
||||
from typing import Dict
|
||||
from typing import List
|
||||
@@ -27,6 +28,8 @@ from . import client
|
||||
from ..tool_context import ToolContext
|
||||
from .settings import BigtableToolSettings
|
||||
|
||||
logger = logging.getLogger("google_adk." + __name__)
|
||||
|
||||
DEFAULT_MAX_EXECUTED_QUERY_RESULT_ROWS = 50
|
||||
|
||||
|
||||
@@ -112,7 +115,7 @@ def execute_sql(
|
||||
return result
|
||||
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
logger.error("Bigtable query failed: %s", ex)
|
||||
return {
|
||||
"status": "ERROR",
|
||||
"error_details": str(ex),
|
||||
|
||||
Reference in New Issue
Block a user