[libcxx-commits] [libcxx] [libc++] Update the LNT tooling to LNT v5 (PR #232866)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Oct 16 10:52:16 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {darker}-->


:warning: Python code formatter, darker found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
darker --check --diff -r origin/main...HEAD libcxx/utils/ci/lnt/common.py
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from darker here.
</summary>

``````````diff
--- common.py	2026-10-16 17:44:38.000000 +0000
+++ common.py	2026-10-16 17:51:47.263875 +0000
@@ -16,11 +16,11 @@
 import uuid
 
 
 # The User-Agent we send to LNT. This is set explicitly since some deployments
 # reject requests made with the default User-Agent of urllib.
-USER_AGENT = 'libcxx-lnt-tooling'
+USER_AGENT = "libcxx-lnt-tooling"
 
 # LNT instances can be slow: timeout after that many seconds.
 LNT_TIMEOUT_SECONDS = 120
 
 
@@ -35,40 +35,51 @@
 def lnt_suite_url(lnt_url: str, test_suite: str) -> str:
     """Return the URL of a test suite in the REST API of a LNT instance."""
     return f'{lnt_url.rstrip("/")}/api/suites/{urllib.parse.quote(test_suite, safe="")}'
 
 
-def lnt_request(url: str, body: Optional[bytes] = None, token: Optional[str] = None) -> dict:
+def lnt_request(
+    url: str, body: Optional[bytes] = None, token: Optional[str] = None
+) -> dict:
     """
     Send a request to LNT and return its JSON response. If a body is provided, this issues
     a POST request, otherwise a GET. Errors are raised as urllib raises them.
     """
-    headers = {'User-Agent': USER_AGENT}
+    headers = {"User-Agent": USER_AGENT}
     if token is not None:
-        headers['Authorization'] = f'Bearer {token}'
+        headers["Authorization"] = f"Bearer {token}"
     if body is not None:
-        headers['Content-Type'] = 'application/json'
+        headers["Content-Type"] = "application/json"
     request = urllib.request.Request(url, data=body, headers=headers)
     with urllib.request.urlopen(request, timeout=LNT_TIMEOUT_SECONDS) as response:
         return json.loads(response.read().decode())
 
 
-def write_lnt_report(path: pathlib.Path, machine: str, machine_fields: dict, commit: dict, tests: List[dict],
-                     measured_at: datetime.datetime, run_parameters: Optional[dict] = None) -> None:
+def write_lnt_report(
+    path: pathlib.Path,
+    machine: str,
+    machine_fields: dict,
+    commit: dict,
+    tests: List[dict],
+    measured_at: datetime.datetime,
+    run_parameters: Optional[dict] = None,
+) -> None:
     """Write a LNT v5 run submission, ready to be submitted with submit-benchmarks."""
     report = {
-        'format_version': '5',
+        "format_version": "5",
         # Pick the UUID ourselves so that we can safely retry submitting this run if needed without
         # running the risk of storing the same run twice.
-        'uuid': str(uuid.uuid4()),
-        'measured_at': measured_at.astimezone(datetime.timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ'),
-        'machine': {'name': machine, 'fields': machine_fields},
-        'commit': commit,
-        'run_parameters': run_parameters or {},
-        'tests': tests,
+        "uuid": str(uuid.uuid4()),
+        "measured_at": measured_at.astimezone(datetime.timezone.utc).strftime(
+            "%Y-%m-%dT%H:%M:%SZ"
+        ),
+        "machine": {"name": machine, "fields": machine_fields},
+        "commit": commit,
+        "run_parameters": run_parameters or {},
+        "tests": tests,
     }
-    with open(path, 'w') as f:
+    with open(path, "w") as f:
         json.dump(report, f, indent=2, allow_nan=False)
 
 
 def parse_lnt_results(lines: Iterable[str]) -> List[dict]:
     """
@@ -81,19 +92,25 @@
     tests: Dict[str, Dict[str, List[float]]] = {}
     for line in lines:
         if not line.strip():
             continue
         (key, value) = line.split()
-        (name, metric) = key.rsplit('.', 1)
+        (name, metric) = key.rsplit(".", 1)
         tests.setdefault(name, {}).setdefault(metric, []).append(float(value))
 
     result = []
-    for (name, metrics) in tests.items():
+    for name, metrics in tests.items():
         count = max(len(values) for values in metrics.values())
-        samples = [{metric: values[i] for (metric, values) in metrics.items() if i < len(values)}
-                   for i in range(count)]
-        result.append({'name': name, 'samples': samples})
+        samples = [
+            {
+                metric: values[i]
+                for (metric, values) in metrics.items()
+                if i < len(values)
+            }
+            for i in range(count)
+        ]
+        result.append({"name": name, "samples": samples})
     return result
 
 
 def at_least(minimum: int) -> Callable[[str], int]:
     """

``````````

</details>


https://github.com/llvm/llvm-project/pull/232866


More information about the libcxx-commits mailing list