feat: implement async operation execution and validation in AirflowClient; enhance tool initialization

This commit is contained in:
2025-05-04 04:19:39 +00:00
parent bba42eea00
commit c5565e6a00
3 changed files with 75 additions and 20 deletions

View File

@@ -29,26 +29,15 @@ def _initialize_client(config: AirflowConfig) -> AirflowClient:
async def _initialize_tools(config: AirflowConfig) -> None:
"""Initialize tools cache with Airflow operations.
Args:
config: Configuration object with auth and URL settings
Raises:
ValueError: If initialization fails
"""
"""Initialize tools cache with Airflow operations (async)."""
global _tools_cache
try:
client = _initialize_client(config)
# Use the OpenAPI spec dict from the client
parser = OperationParser(client.raw_spec)
# Generate tools for each operation
for operation_id in parser.get_operations():
operation_details = parser.parse_operation(operation_id)
tool = AirflowTool(operation_details, client)
_tools_cache[operation_id] = tool
async with AirflowClient(base_url=config.base_url, auth_token=config.auth_token) as client:
parser = OperationParser(client.raw_spec)
for operation_id in parser.get_operations():
operation_details = parser.parse_operation(operation_id)
tool = AirflowTool(operation_details, client)
_tools_cache[operation_id] = tool
except Exception as e:
logger.error("Failed to initialize tools: %s", e)