Spaces:
Running
Running
File size: 1,507 Bytes
557ee65 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | import time
import logging
from observability import logger as obs_logger
from observability import components as obs_components
from ..base import BaseAgent
from typing import List, Dict, Any
from ingestion.features import running_features
logger = logging.getLogger(__name__)
class FeatureEngineeringAgent(BaseAgent):
"""
Input: list of runs as returned by parser
Output: a features dict with:
- per_run summaries (pace_min_per_km, avg_hr)
- time series arrays for charts
- weekly aggregates (mileage)
- consistency score (0-100)
"""
def run(self, runs: List[Dict[str, Any]]) -> Dict[str, Any]:
with obs_logger.start_span("feature_engineering_agent.run", obs_components.AGENT):
from ingestion.features import compute_features_batch
from ingestion.weekly_features import aggregate_runs_by_week, compute_trends
try:
# 1. Basic summary and charts
summary = running_features(runs)
# 2. Detailed per-run features
detailed_features = compute_features_batch(runs)
return {
"summary": summary,
"detailed_features": detailed_features,
"weekly_stats": {}, # Deprecated in-memory
"trends": {}, # Deprecated in-memory
}
except Exception as e:
logger.error(f"Feature engineering failed: {e}")
raise
|