Skip to content

Commit

Permalink
#18150: [skip ci] Drop xmltodict from requirements-dev.txt and use bu…
Browse files Browse the repository at this point in the history
…ilt-in xml.etree instead (#18298)

### Ticket
Resolves #18150 and
concerns from PR #18251

### Problem description
- pytest mysteriously crashes on tt-metal-ci-vm-24 when xmltodict is
included in the dev env.

[From PR 18251]
- avoid installing infra deps each time we want to run the github action
- prevent situation where deps can be installed outside of a docker
container due to running `pip install` directly

### What's changed
Remove `xmltodict` from `requirements-dev.txt`
Refactor github action script to use built-in `xml.etree.ElementTree`
instead.

### Checklist
- [ ] [All post
commit](https://github.com/tenstorrent/tt-metal/actions/workflows/all-post-commit-workflows.yaml)
CI passes
https://github.com/tenstorrent/tt-metal/actions/runs/13526080092
  • Loading branch information
williamlyTT authored Feb 25, 2025
1 parent 66be5d4 commit 9c9cbd0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 37 deletions.
52 changes: 16 additions & 36 deletions .github/scripts/data_analysis/print_gtest_annotations.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
import argparse
import xmltodict
import xml.etree.ElementTree as ET
import glob
import os
from typing import Union


def _guaranteed_list(x):
if not x:
return []
elif isinstance(x, list):
return x
else:
return [x]


def _build_workflow_command(
command_name: str,
file: str,
Expand Down Expand Up @@ -61,29 +52,18 @@ def _escape(s: str) -> str:

# Iterate through each XML file
for xml_file in xml_files:
with open(xml_file, "r") as f:
results = xmltodict.parse(f.read())

# Check for failed tests
failed_tests = []
for testsuite in _guaranteed_list(results["testsuites"]["testsuite"]):
for testcase in _guaranteed_list(testsuite["testcase"]):
if "failure" in testcase:
failed_tests.append(testcase)

# Create error annotations for each failed test
for failed_test in failed_tests:
failure_messages = _guaranteed_list(failed_test["failure"])
if failure_messages:
# first message is often enough
failure_message = failure_messages[0]["@message"]
else:
failure_message = "unknown_failure_message"

msg = _build_workflow_command(
command_name="error",
file=failed_test["@file"].lstrip("/work/"),
line=int(failed_test["@line"]),
message=failure_message,
)
print(msg)
tree = ET.parse(xml_file)
root = tree.getroot()
for testsuite in root.findall("testsuite"):
for testcase in testsuite.findall("testcase"):
failure = testcase.find("failure")
# If failure exists, print the failure message
if failure is not None:
failure_message = failure.attrib.get("message")
msg = _build_workflow_command(
command_name="error",
file=testcase.attrib.get("file", "").lstrip("/work/"),
line=int(testcase.attrib["line"]),
message=failure_message,
)
print(msg)
1 change: 0 additions & 1 deletion tt_metal/python_env/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
loguru

# For github workflow unit test failure annotations
xmltodict
pytest-github-actions-annotate-failures==0.3.0

# During dep resolution, black may install platformdirs >=4.0.0, which is
Expand Down

0 comments on commit 9c9cbd0

Please sign in to comment.