File size: 750 Bytes
9d945e1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # Kernel keep-alive: runs as a cell (colab exec via stdin) while a detached job runs, so Colab sees an active kernel.
# Prints the job's latest progress line once a minute; ends when no process matches PATTERN.
import subprocess
import time
PATTERN = "run_step0.py"
LOG = "/content/set5/logs/chain.log"
while subprocess.run(["pgrep", "-f", PATTERN], capture_output=True).returncode == 0:
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"), "JOB FINISHED:", PATTERN, flush=True)
print(subprocess.run(f"tail -n 6 {LOG}", shell=True, capture_output=True, text=True).stdout, flush=True)
|