From 2e3e57b9848b401c25a9825611aa736e92d1d381 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Mon, 16 Mar 2026 13:23:14 -0700 Subject: [PATCH] ci/update_traces_checksum: Parse gpu-trace-perf's format for hash changes. Generated-by: Claude Part-of: --- bin/ci/requirements.txt | 1 + bin/ci/update_traces_checksum.py | 54 ++++++++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/bin/ci/requirements.txt b/bin/ci/requirements.txt index e269c0bde7a..525cf242c12 100644 --- a/bin/ci/requirements.txt +++ b/bin/ci/requirements.txt @@ -11,3 +11,4 @@ rich==14.1.* ruamel.yaml.clib==0.2.* ruamel.yaml==0.17.* tabulate==0.9.* +tomledit==1.* diff --git a/bin/ci/update_traces_checksum.py b/bin/ci/update_traces_checksum.py index 7e74a049628..462c6adc4f6 100755 --- a/bin/ci/update_traces_checksum.py +++ b/bin/ci/update_traces_checksum.py @@ -17,6 +17,7 @@ import re import json import sys from ruamel.yaml import YAML +from tomledit import Document import gitlab from gitlab_common import (get_gitlab_project, read_token, wait_for_pipeline, @@ -27,7 +28,7 @@ from rich import print DESCRIPTION_FILE = "export PIGLIT_REPLAY_DESCRIPTION_FILE=.*/install/(.*)$" DEVICE_NAME = "(?:declare -x|export) PIGLIT_REPLAY_DEVICE_NAME='?([^']*)'?$" -def gather_job_results(cur_job): +def gather_job_results_yml(cur_job): log: list[str] = cur_job.trace().decode().splitlines() filename: str = '' dev_name: str = '' @@ -97,6 +98,52 @@ def gather_job_results(cur_job): yaml.dump(target, target_file) +def update_toml_checksum(toml_file, trace_path, device, old_checksum, new_checksum): + with open(toml_file, 'r', encoding='utf-8') as f: + doc = Document.parse(f.read()) + + for table in doc["traces"]: + if table["path"].value != trace_path: + continue + try: + table["devices"][device]["checksum"] = new_checksum + except KeyError: + return False + with open(toml_file, 'w', encoding='utf-8') as f: + f.write(doc.as_toml()) + return True + + return False + + +def gather_job_results_toml(cur_job) -> None: + """Process checksum-changes.json artifact (gpu-trace-perf replay format)""" + toml_files = glob.glob('./**/traces-*.toml', recursive=True) + + changes_json = cur_job.artifact("results/checksum-changes.json") + changes = json.loads(changes_json.decode("utf-8")) + + for change in changes: + device = change['device'] + trace = change['trace'] + old_checksum = change['old_checksum'] + new_checksum = change['new_checksum'] + + if not new_checksum: + print(f"[red]{device}: {trace}: no new checksum (crash?)") + continue + + updated = False + for toml_file in toml_files: + if update_toml_checksum(toml_file, trace, device, old_checksum, new_checksum): + print(f"[green]{device}: {trace}: checksum updated") + updated = True + break + + if not updated: + print(f"[red]{device}: {trace}: not found in any traces TOML file") + + def gather_results( project, pipeline, @@ -110,7 +157,10 @@ def gather_results( cur_job = project.jobs.get(job.id) # get variables print(f"👁 {job.name}...") - gather_job_results(cur_job) + try: + gather_job_results_toml(cur_job) + except Exception: + gather_job_results_yml(cur_job) def parse_args() -> None: