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
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import logging
|
||||||
import re
|
import re
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
from typing import List
|
from typing import List
|
||||||
@@ -33,6 +34,8 @@ from ...agents.sequential_agent import SequentialAgent
|
|||||||
from ...tools.example_tool import ExampleTool
|
from ...tools.example_tool import ExampleTool
|
||||||
from ..experimental import a2a_experimental
|
from ..experimental import a2a_experimental
|
||||||
|
|
||||||
|
logger = logging.getLogger('google_adk.' + __name__)
|
||||||
|
|
||||||
|
|
||||||
@a2a_experimental
|
@a2a_experimental
|
||||||
class AgentCardBuilder:
|
class AgentCardBuilder:
|
||||||
@@ -157,8 +160,8 @@ async def _build_sub_agent_skills(agent: BaseAgent) -> List[AgentSkill]:
|
|||||||
sub_agent_skills.append(aggregated_skill)
|
sub_agent_skills.append(aggregated_skill)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Log warning but continue with other sub-agents
|
# Log warning but continue with other sub-agents
|
||||||
print(
|
logger.warning(
|
||||||
f'Warning: Failed to build skills for sub-agent {sub_agent.name}: {e}'
|
'Failed to build skills for sub-agent %s: %s', sub_agent.name, e
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -502,7 +505,7 @@ async def _extract_examples_from_agent(
|
|||||||
if isinstance(tool, ExampleTool):
|
if isinstance(tool, ExampleTool):
|
||||||
return _convert_example_tool_examples(tool)
|
return _convert_example_tool_examples(tool)
|
||||||
except Exception as e:
|
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 no example_tool found, try to extract examples from instruction
|
||||||
if agent.instruction:
|
if agent.instruction:
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import copy
|
import copy
|
||||||
import importlib
|
import importlib
|
||||||
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from typing import AsyncGenerator
|
from typing import AsyncGenerator
|
||||||
from typing import Optional
|
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 import UserSimulator
|
||||||
from .simulation.user_simulator_provider import UserSimulatorProvider
|
from .simulation.user_simulator_provider import UserSimulatorProvider
|
||||||
|
|
||||||
|
logger = logging.getLogger("google_adk." + __name__)
|
||||||
|
|
||||||
_USER_AUTHOR = "user"
|
_USER_AUTHOR = "user"
|
||||||
_DEFAULT_AUTHOR = "agent"
|
_DEFAULT_AUTHOR = "agent"
|
||||||
|
|
||||||
@@ -117,7 +120,7 @@ class EvaluationGenerator:
|
|||||||
|
|
||||||
with open(session_path, "r") as f:
|
with open(session_path, "r") as f:
|
||||||
session_data = Session.model_validate_json(f.read())
|
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:
|
for data in eval_dataset:
|
||||||
# load session data from session_path
|
# load session data from session_path
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
"""Tool to execute SQL queries against Bigtable."""
|
"""Tool to execute SQL queries against Bigtable."""
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
from typing import List
|
from typing import List
|
||||||
@@ -27,6 +28,8 @@ from . import client
|
|||||||
from ..tool_context import ToolContext
|
from ..tool_context import ToolContext
|
||||||
from .settings import BigtableToolSettings
|
from .settings import BigtableToolSettings
|
||||||
|
|
||||||
|
logger = logging.getLogger("google_adk." + __name__)
|
||||||
|
|
||||||
DEFAULT_MAX_EXECUTED_QUERY_RESULT_ROWS = 50
|
DEFAULT_MAX_EXECUTED_QUERY_RESULT_ROWS = 50
|
||||||
|
|
||||||
|
|
||||||
@@ -112,7 +115,7 @@ def execute_sql(
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
print(ex)
|
logger.error("Bigtable query failed: %s", ex)
|
||||||
return {
|
return {
|
||||||
"status": "ERROR",
|
"status": "ERROR",
|
||||||
"error_details": str(ex),
|
"error_details": str(ex),
|
||||||
|
|||||||
Reference in New Issue
Block a user