100XZX001's picture
Upload 18 files
d186427 verified
raw
history blame contribute delete
743 Bytes
import subprocess
import sys
import threading
from http.server import HTTPServer, BaseHTTPRequestHandler
def run_training():
print("Starting training job...")
subprocess.run([sys.executable, "training.py"], check=True)
print("Training finished.")
# Start training in background
threading.Thread(target=run_training).start()
# Minimal HTTP server to keep the container alive (port 7860)
class Handler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.end_headers()
self.wfile.write(b"Training in progress...")
def do_POST(self):
self.do_GET()
print("Keeping container alive on port 7860")
HTTPServer(("0.0.0.0", 7860), Handler).serve_forever()