adaptai / systemd /elizabeth-promote@.service
ADAPT-Chase's picture
Add files using upload-large-folder tool
085ac9e verified
[Unit]
Description=Elizabeth Model Promotion Service %I
After=elizabeth-eval@%i.service
Requires=elizabeth-eval@%i.service
ConditionPathExists=/data/adaptai/eval_results/elizabeth-${%I}.json
[Service]
Type=oneshot
User=root
WorkingDirectory=/data/adaptai
Environment=PYTHONPATH=/data/adaptai/aiml/datascience
ExecStart=/usr/bin/python3 -c "
import json
import shutil
from pathlib import Path
# Load evaluation results
eval_file = Path('/data/adaptai/eval_results/elizabeth-${%I}.json')
if eval_file.exists():
with open(eval_file, 'r') as f:
results = json.load(f)
# Check if all gates passed
if results.get('all_gates_pass', False):
print('βœ… All evaluation gates passed - promoting model')
# Promote checkpoint to production
src = Path('/data/adaptai/checkpoints/elizabeth-${%I}')
dest = Path('/workspace/models/elizabeth-production')
if src.exists():
if dest.exists():
shutil.rmtree(dest)
shutil.copytree(src, dest)
print(f'πŸŽ‰ Model promoted to {dest}')
else:
print('❌ Checkpoint not found')
else:
print('❌ Evaluation gates failed - not promoting')
print(f'Failed metrics: {results.get(\"failed_metrics\", [])}')
else:
print('❌ Evaluation results not found')
"
# Security
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
[Install]
WantedBy=multi-user.target