Handle two-frame Ego4D bbox tails and preserve worker errors

This commit is contained in:
Xin Wang
2026-08-28 09:26:45 +08:00
parent 668996bfa8
commit 18e8773685
5 changed files with 156 additions and 40 deletions
+12 -4
View File
@@ -107,11 +107,17 @@ def worker_environment(gpu, cpu_threads):
return env
def log_tail(path):
def log_tail(path, *, failure=False):
"""Compact progress, but retain traceback/long diagnostic lines on failure."""
try:
with path.open("rb") as handle:
handle.seek(max(0, path.stat().st_size - 4096))
handle.seek(max(0, path.stat().st_size - (65536 if failure else 4096)))
lines = handle.read().decode("utf-8", errors="replace").replace("\r", "\n").splitlines()
if failure:
for index in range(len(lines) - 1, -1, -1):
if lines[index].startswith("Traceback (most recent call last):"):
return "\n".join(lines[index:])
return "\n".join(lines[-40:]) or "no worker output"
return next((line.strip() for line in reversed(lines) if line.strip()), "starting")[-300:]
except FileNotFoundError:
return "starting"
@@ -166,14 +172,16 @@ def run_workers(plans, args, log_dir):
time.sleep(args.startup_delay)
for started, child, child_log in running:
if child.poll() not in (None, 0):
raise RuntimeError(f"GPU {started['gpu']} failed (exit={child.returncode}); see {child_log}")
raise RuntimeError(f"GPU {started['gpu']} failed (exit={child.returncode}); see {child_log}\n"
f"{log_tail(child_log, failure=True)}")
next_status, last_status = 0., {}
while True:
completed = 0
for plan, process, log in running:
code = process.poll()
if code not in (None, 0):
raise RuntimeError(f"GPU {plan['gpu']} failed (exit={code}); see {log}\n{log_tail(log)}")
raise RuntimeError(f"GPU {plan['gpu']} failed (exit={code}); see {log}\n"
f"{log_tail(log, failure=True)}")
completed += code == 0
if time.monotonic() >= next_status or completed == len(running):
for plan, process, log in running: