revert: remove unrelated Python formatting changes

These changes were identified in code review as unrelated to the task
priority fix and should be in a separate commit/branch.

Reverts Python files to main branch state to keep PR focused.
This commit is contained in:
leex279
2025-09-10 08:39:45 +02:00
parent fdb6dfeafc
commit 217b4402ec
17 changed files with 31 additions and 29 deletions

View File

@@ -216,7 +216,7 @@ class BaseAgent(ABC, Generic[DepsT, OutputT]):
self.logger.info(f"Agent {self.name} completed successfully")
# PydanticAI returns a RunResult with data attribute
return result.data
except TimeoutError:
except asyncio.TimeoutError:
self.logger.error(f"Agent {self.name} timed out after 120 seconds")
raise Exception(f"Agent {self.name} operation timed out - taking too long to respond")
except Exception as e:

View File

@@ -11,8 +11,8 @@ from typing import Any
from urllib.parse import urljoin
import httpx
from mcp.server.fastmcp import Context, FastMCP
from mcp.server.fastmcp import Context, FastMCP
from src.mcp_server.utils.error_handling import MCPErrorFormatter
from src.mcp_server.utils.timeout_config import get_default_timeout
from src.server.config.service_discovery import get_api_url

View File

@@ -11,8 +11,8 @@ from typing import Any
from urllib.parse import urljoin
import httpx
from mcp.server.fastmcp import Context, FastMCP
from mcp.server.fastmcp import Context, FastMCP
from src.mcp_server.utils.error_handling import MCPErrorFormatter
from src.mcp_server.utils.timeout_config import get_default_timeout
from src.server.config.service_discovery import get_api_url

View File

@@ -9,8 +9,8 @@ import logging
from urllib.parse import urljoin
import httpx
from mcp.server.fastmcp import Context, FastMCP
from mcp.server.fastmcp import Context, FastMCP
from src.mcp_server.utils.error_handling import MCPErrorFormatter
from src.mcp_server.utils.timeout_config import get_default_timeout
from src.server.config.service_discovery import get_api_url

View File

@@ -11,8 +11,8 @@ import logging
from urllib.parse import urljoin
import httpx
from mcp.server.fastmcp import Context, FastMCP
from mcp.server.fastmcp import Context, FastMCP
from src.mcp_server.utils.error_handling import MCPErrorFormatter
from src.mcp_server.utils.timeout_config import (
get_default_timeout,

View File

@@ -11,8 +11,8 @@ from typing import Any
from urllib.parse import urljoin
import httpx
from mcp.server.fastmcp import Context, FastMCP
from mcp.server.fastmcp import Context, FastMCP
from src.mcp_server.utils.error_handling import MCPErrorFormatter
from src.mcp_server.utils.timeout_config import get_default_timeout
from src.server.config.service_discovery import get_api_url

View File

@@ -29,6 +29,7 @@ from pathlib import Path
from typing import Any
from dotenv import load_dotenv
from mcp.server.fastmcp import Context, FastMCP
# Add the project root to Python path for imports

View File

@@ -16,6 +16,7 @@ import os
from urllib.parse import urljoin
import httpx
from mcp.server.fastmcp import Context, FastMCP
# Import service discovery for HTTP communication

View File

@@ -39,21 +39,21 @@ async def get_progress(
status_code=404,
detail={"error": f"Operation {operation_id} not found"}
)
# Ensure we have the progress_id in the data
operation["progress_id"] = operation_id
# Get operation type for proper model selection
operation_type = operation.get("type", "crawl")
# Create standardized response using Pydantic model
progress_response = create_progress_response(operation_type, operation)
# Convert to dict with camelCase fields for API response
response_data = progress_response.model_dump(by_alias=True, exclude_none=True)
# Debug logging for code extraction fields
if operation_type == "crawl" and operation.get("status") == "code_extraction":
logger.info(f"Code extraction response fields: completedSummaries={response_data.get('completedSummaries')}, totalSummaries={response_data.get('totalSummaries')}, codeBlocksFound={response_data.get('codeBlocksFound')}")

View File

@@ -81,7 +81,7 @@ class CrawlProgressResponse(BaseProgressResponse):
total_pages: int = Field(0, alias="totalPages")
processed_pages: int = Field(0, alias="processedPages")
crawl_type: str | None = Field(None, alias="crawlType") # 'normal', 'sitemap', 'llms-txt', 'refresh'
# Code extraction specific fields
code_blocks_found: int = Field(0, alias="codeBlocksFound")
code_examples_stored: int = Field(0, alias="codeExamplesStored")
@@ -217,7 +217,7 @@ def create_progress_response(
if snake_field in progress_data:
# Use the camelCase name since ProgressDetails expects it
details_data[camel_field] = progress_data[snake_field]
# Also check for crawl-specific fields that might use alternative names
if 'pages_crawled' not in progress_data and 'processed_pages' in progress_data:
details_data['pagesCrawled'] = progress_data['processed_pages']
@@ -235,14 +235,14 @@ def create_progress_response(
from ..config.logfire_config import get_logger
logger = get_logger(__name__)
logger.info(f"Code extraction progress fields present: completed_summaries={progress_data.get('completed_summaries')}, total_summaries={progress_data.get('total_summaries')}")
return model_class(**progress_data)
except Exception as e:
# Log validation errors for debugging
from ..config.logfire_config import get_logger
logger = get_logger(__name__)
logger.error(f"Failed to create {model_class.__name__}: {e}", exc_info=True)
essential_fields = {
"progress_id": progress_data.get("progress_id", "unknown"),
"status": progress_data.get("status", "running"),

View File

@@ -232,7 +232,7 @@ class CodeExtractionService:
# Check for cancellation before processing each document
if cancellation_check:
cancellation_check()
try:
source_url = doc["url"]
html_content = doc.get("html", "")
@@ -1401,7 +1401,7 @@ class CodeExtractionService:
# Check for cancellation during summary generation
if cancellation_check:
cancellation_check()
# Map the progress from generate_code_summaries_batch (0-100) to our range
if "progress" in data or "percentage" in data:
raw_progress = data.get("progress", data.get("percentage", 0))
@@ -1423,7 +1423,7 @@ class CodeExtractionService:
results = await generate_code_summaries_batch(
code_blocks_for_summaries, max_workers, progress_callback=summary_progress_callback
)
# Ensure all results are valid dicts
validated_results = []
for result in results:
@@ -1435,7 +1435,7 @@ class CodeExtractionService:
"example_name": "Code Example",
"summary": "Code example for demonstration purposes."
})
return validated_results
except asyncio.CancelledError:
# If cancelled, return default summaries for all blocks

View File

@@ -139,7 +139,7 @@ class BatchCrawlStrategy:
total_urls = len(urls)
await report_progress(
start_progress,
start_progress,
f"Starting to crawl {total_urls} URLs...",
total_pages=total_urls,
processed_pages=0

View File

@@ -242,7 +242,7 @@ class SinglePageCrawlStrategy:
# Report initial progress (single file = 1 page)
await report_progress(
start_progress,
start_progress,
f"Fetching text file: {url}",
total_pages=1,
processed_pages=0
@@ -260,7 +260,7 @@ class SinglePageCrawlStrategy:
# Report completion progress
await report_progress(
end_progress,
end_progress,
f"Text file crawled successfully: {original_url}",
total_pages=1,
processed_pages=1

View File

@@ -219,4 +219,4 @@ async def generate_contextual_embeddings_batch(
except Exception as e:
search_logger.error(f"Error in contextual embedding batch: {e}")
# Return non-contextual for all chunks
return [(chunk, False) for chunk in chunks]
return [(chunk, False) for chunk in chunks]

View File

@@ -259,7 +259,7 @@ async def add_documents_to_supabase(
)
except Exception as e:
search_logger.warning(f"Progress callback failed during rate limiting: {e}")
# Pass progress callback for rate limiting updates
result = await create_embeddings_batch(
contextual_contents,

View File

@@ -91,7 +91,7 @@ class RateLimiter:
"""
while True: # Loop instead of recursion to avoid stack overflow
wait_time_to_sleep = None
async with self._lock:
now = time.time()
@@ -104,7 +104,7 @@ class RateLimiter:
self.request_times.append(now)
self.token_usage.append((now, estimated_tokens))
return True
# Calculate wait time if we can't make the request
wait_time = self._calculate_wait_time(estimated_tokens)
if wait_time > 0:
@@ -118,7 +118,7 @@ class RateLimiter:
wait_time_to_sleep = wait_time
else:
return False
# Sleep outside the lock to avoid deadlock
if wait_time_to_sleep is not None:
# For long waits, break into smaller chunks with progress updates

View File

@@ -115,7 +115,7 @@ class ProgressTracker:
# Add any additional data
for key, value in kwargs.items():
self.state[key] = value
self._update_state()