Add improvements 2
This commit is contained in:
@@ -404,22 +404,32 @@ class TrainingDataOrchestrator:
|
||||
tenant_id: str
|
||||
) -> Dict[str, Any]:
|
||||
"""
|
||||
Collect POI features for bakery location.
|
||||
Collect POI features for bakery location (non-blocking).
|
||||
|
||||
POI features are static (location-based, not time-varying).
|
||||
This method is non-blocking with a short timeout to prevent training delays.
|
||||
If POI detection hasn't been run yet, training continues without POI features.
|
||||
|
||||
Returns:
|
||||
Dictionary with POI features or empty dict if unavailable
|
||||
"""
|
||||
try:
|
||||
logger.info(
|
||||
"Collecting POI features",
|
||||
"Collecting POI features (non-blocking)",
|
||||
tenant_id=tenant_id,
|
||||
location=(lat, lon)
|
||||
)
|
||||
|
||||
poi_features = await self.poi_feature_integrator.fetch_poi_features(
|
||||
tenant_id=tenant_id,
|
||||
latitude=lat,
|
||||
longitude=lon,
|
||||
force_refresh=False
|
||||
# Set a short timeout to prevent blocking training
|
||||
# POI detection should have been triggered during tenant registration
|
||||
poi_features = await asyncio.wait_for(
|
||||
self.poi_feature_integrator.fetch_poi_features(
|
||||
tenant_id=tenant_id,
|
||||
latitude=lat,
|
||||
longitude=lon,
|
||||
force_refresh=False
|
||||
),
|
||||
timeout=15.0 # 15 second timeout - POI should be cached from registration
|
||||
)
|
||||
|
||||
if poi_features:
|
||||
@@ -430,18 +440,24 @@ class TrainingDataOrchestrator:
|
||||
)
|
||||
else:
|
||||
logger.warning(
|
||||
"No POI features collected (service may be unavailable)",
|
||||
"No POI features collected (service may be unavailable or not yet detected)",
|
||||
tenant_id=tenant_id
|
||||
)
|
||||
|
||||
return poi_features or {}
|
||||
|
||||
except asyncio.TimeoutError:
|
||||
logger.warning(
|
||||
"POI collection timeout (15s) - continuing training without POI features. "
|
||||
"POI detection should be triggered during tenant registration for best results.",
|
||||
tenant_id=tenant_id
|
||||
)
|
||||
return {}
|
||||
except Exception as e:
|
||||
logger.error(
|
||||
"Failed to collect POI features, continuing without them",
|
||||
logger.warning(
|
||||
"Failed to collect POI features (non-blocking) - continuing training without them",
|
||||
tenant_id=tenant_id,
|
||||
error=str(e),
|
||||
exc_info=True
|
||||
error=str(e)
|
||||
)
|
||||
return {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user