aee0f09db8
- Datafabrik: Dockerfile fix, agentorkestrering fungerar - Vision: Identify-modell, FAISS, OCR alla testade - API: Alla 7 integrationstester passerade - Upplösare: Entitetsupplösning verifierad
77 lines
2.1 KiB
Python
77 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
LIFE Scheduler
|
|
Kör Weather Intelligence Pipeline varje timme
|
|
"""
|
|
import sys
|
|
import logging
|
|
import time
|
|
from datetime import datetime
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, '/home/bernt/.openclaw/workspace/life-weather')
|
|
|
|
from pipeline_v2 import WeatherPipelineV2
|
|
import sqlite3
|
|
|
|
LOG_DIR = Path("/home/bernt/.openclaw/workspace/life-weather/logs")
|
|
LOG_DIR.mkdir(exist_ok=True)
|
|
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
|
handlers=[
|
|
logging.FileHandler(LOG_DIR / "scheduler.log"),
|
|
logging.StreamHandler()
|
|
]
|
|
)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
def run_weather_job():
|
|
"""Kör Weather Intelligence Pipeline för alla vägar"""
|
|
logger.info("=== WEATHER JOB STARTAR ===")
|
|
|
|
pipeline = WeatherPipelineV2()
|
|
|
|
# Hämta alla vägar
|
|
conn = sqlite3.connect('/home/bernt/.openclaw/workspace/rivp-pilot-1/rivp.db')
|
|
c = conn.cursor()
|
|
c.execute('SELECT id, road_number, type FROM roads')
|
|
roads = c.fetchall()
|
|
conn.close()
|
|
|
|
logger.info(f"Kör pipeline för {len(roads)} vägar...")
|
|
|
|
total_events = 0
|
|
total_missions = 0
|
|
|
|
for road_id, road_number, road_type in roads:
|
|
try:
|
|
result = pipeline.run_for_road(road_id, road_type or 'primary')
|
|
if result:
|
|
total_events += len(result.get('events', []))
|
|
total_missions += len(result.get('missions', []))
|
|
except Exception as e:
|
|
logger.error(f"Fel vid väg {road_id}: {e}")
|
|
|
|
logger.info("=== WEATHER JOB KLAR ===")
|
|
logger.info(f"Vägar: {len(roads)}")
|
|
logger.info(f"Events: {total_events}")
|
|
logger.info(f"Missions: {total_missions}")
|
|
|
|
if __name__ == "__main__":
|
|
logger.info("LIFE Scheduler startad")
|
|
|
|
# Kör direkt vid start
|
|
run_weather_job()
|
|
|
|
# Kör sedan varje timme
|
|
while True:
|
|
time.sleep(3600) # Vänta 1 timme
|
|
try:
|
|
run_weather_job()
|
|
except Exception as e:
|
|
logger.error(f"Fel i scheduler: {e}")
|
|
# Vänta 5 minuter och försök igen
|
|
time.sleep(300)
|