直接终端输出

This commit is contained in:
MobKBK
2026-04-11 09:41:19 +08:00
parent 71199090c8
commit e66077997d

View File

@@ -191,17 +191,36 @@ def run_one_eval(project_dir: Path, train_script: Path, result_name: str, gpu: s
"auto_eval", "auto_eval",
] ]
proc = subprocess.run( print(f"[INFO] Running command: {' '.join(cmd)}")
print(f"[INFO] CUDA_VISIBLE_DEVICES={gpu}")
proc = subprocess.Popen(
cmd, cmd,
cwd=str(project_dir), cwd=str(project_dir),
env=env, env=env,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
text=True, text=True,
bufsize=1,
universal_newlines=True,
) )
print(proc.stdout) try:
return proc.returncode assert proc.stdout is not None
for line in proc.stdout:
print(line, end="")
proc.wait()
return proc.returncode
except KeyboardInterrupt:
print("\n[WARN] 收到 Ctrl+C正在终止当前测试子进程...")
proc.terminate()
try:
proc.wait(timeout=5)
except Exception:
print("[WARN] 子进程未及时退出,强制 kill")
proc.kill()
proc.wait()
raise
def collect_epoch_rows(all_rows: List[Dict], epoch: int) -> List[Dict]: def collect_epoch_rows(all_rows: List[Dict], epoch: int) -> List[Dict]: