feat(application): integrate measured-load ingestion training and planner source

This commit is contained in:
ENELIX Agent
2026-10-02 21:00:05 +00:00
parent 44362e4bf5
commit fc024fcfba
96 changed files with 8933 additions and 0 deletions
@@ -0,0 +1,32 @@
import os
import joblib
MODEL_DIR = "/app/data/models"
def model_path(aid, forecast_id):
os.makedirs(MODEL_DIR, exist_ok=True)
return os.path.join(MODEL_DIR, f"forecast_var_{forecast_id}_{aid}.pkl")
def save_model(aid, forecast_id, artifact):
path = model_path(aid, forecast_id)
tmp_path = f"{path}.tmp.{os.getpid()}"
try:
joblib.dump(artifact, tmp_path)
os.replace(tmp_path, path)
finally:
if os.path.exists(tmp_path):
os.remove(tmp_path)
return path
def load_model(aid, forecast_id):
path = model_path(aid, forecast_id)
if not os.path.exists(path):
return None
try:
return joblib.load(path)
except Exception as exc:
print(f"Modell {path} konnte nicht geladen werden: {exc}")
return None