investormlops-api / src /retrain_if_drift.py
Mayur-cinderace
Move Docker app to repo root for Hugging Face Spaces
0a6956c
raw
history blame contribute delete
674 Bytes
import json
import subprocess
from pathlib import Path
DECISION_FILE = Path("drift_reports/retrain_flag.json")
def main():
if not DECISION_FILE.exists():
print("No retrain decision file found → skipping retrain")
return
with open(DECISION_FILE) as f:
decision = json.load(f)
if decision.get("retrain", False):
print("Retraining triggered due to detected drift")
# Call training as a subprocess (DVC-safe)
subprocess.run(
["python", "src/train_models.py"],
check=True
)
else:
print("Retraining skipped (no drift detected)")
if __name__ == "__main__":
main()