repa-representation-probing / set5 /code /run_pilot_cell.py
LamTNguyen's picture
set5: phase 2 (pilot) results, report and code
c8420ab verified
Raw History Blame Contribute Delete
1.11 kB
# Kernel cell (piped to `colab exec`): installs pip deps, starts pilot.py detached if it is not running, then prints the
# latest log line once a minute until it ends, so Colab sees a busy kernel for the whole job (one GPU job at a time).
import os
import subprocess
import time
LOG = "/content/set5/logs/pilot.log"
os.makedirs("/content/set5/logs", exist_ok=True)
def running():
return subprocess.run(["pgrep", "-f", "python pilot.py"], capture_output=True).returncode == 0
if not running():
subprocess.run("pip install -q diffusers timm torchdiffeq h5py >> /content/set5/logs/pip.log 2>&1", shell=True)
subprocess.Popen(f"cd /content/set5/code && nohup python pilot.py >> {LOG} 2>&1 &", shell=True)
time.sleep(15)
while running():
last = subprocess.run(f"tail -n 1 {LOG}", shell=True, capture_output=True, text=True).stdout.strip()
print(time.strftime("%H:%M:%S"), last[:160], flush=True)
time.sleep(60)
print(time.strftime("%H:%M:%S"), "PILOT PROCESS ENDED", flush=True)
print(subprocess.run(f"tail -n 15 {LOG}", shell=True, capture_output=True, text=True).stdout, flush=True)