[CI][Bugfix] Fix the error in generating the performance data table and add a fallback mechanism that prevents the result file from being generated when test case execution fails. (#2839)

Signed-off-by: wangyu <410167048@qq.com>
Signed-off-by: wangyu <53896905+yenuo26@users.noreply.github.com>
This commit is contained in:
wangyu authored and GitHub committed 2026-04-17 16:33:46 +08:00
1 parent bbd6a443ed
commit a3ecde98e0
9 files changed
+394 -31

No files matched your search

@@ -52,6 +52,7 @@ BENCHMARK_SCRIPT = str(
_SESSION_TIMESTAMP = datetime.now().strftime("%Y%m%d-%H%M%S")
_RESULT_LOCK = threading.Lock()
_BRANCHPOINT_COMMIT_SHA: str | None = None
DIFFUSION_RESULT_TEMPLATE_PATH = Path(__file__).parent / "diffusion_result_template.json"
def _get_config_file_from_argv() -> str | None:
@@ -563,10 +564,17 @@ def run_benchmark(
if process.returncode != 0:
tmp_result_file.unlink(missing_ok=True)
raise RuntimeError(f"Benchmark script exited with code {process.returncode}")
print(f"ERROR:Benchmark script exited with code {process.returncode}")
if not tmp_result_file.exists():
raise FileNotFoundError(f"Benchmark result file not found: {tmp_result_file}")
with open(DIFFUSION_RESULT_TEMPLATE_PATH, encoding="utf-8") as f:
template_payload = json.load(f)
# Template schema is fixed and owned by this repo:
# ``diffusion_result_template.json`` is a one-item list and metrics live at [0]["result"].
template_metrics: dict[str, Any] = template_payload[0]["result"]
with open(tmp_result_file, "w", encoding="utf-8") as f:
json.dump(template_metrics, f, ensure_ascii=False, indent=2)
print(f"Benchmark result file not generated, fallback to template: {tmp_result_file}")
try:
with open(tmp_result_file, encoding="utf-8") as f: