mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-14 01:58:22 +06:00
Fix CI slack reporting issue (#34833)
* fix * fix * fix * fix * fix --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
parent
3cb8676a91
commit
40821a2478
@ -2385,6 +2385,10 @@ def run_test_using_subprocess(func):
|
|||||||
|
|
||||||
env = copy.deepcopy(os.environ)
|
env = copy.deepcopy(os.environ)
|
||||||
env["_INSIDE_SUB_PROCESS"] = "1"
|
env["_INSIDE_SUB_PROCESS"] = "1"
|
||||||
|
# This prevents the entries in `short test summary info` given by the subprocess being truncated. so the
|
||||||
|
# full information can be passed to the parent pytest process.
|
||||||
|
# See: https://docs.pytest.org/en/stable/explanation/ci.html
|
||||||
|
env["CI"] = "true"
|
||||||
|
|
||||||
# If not subclass of `unitTest.TestCase` and `pytestconfig` is used: try to grab and use the arguments
|
# If not subclass of `unitTest.TestCase` and `pytestconfig` is used: try to grab and use the arguments
|
||||||
if "pytestconfig" in kwargs:
|
if "pytestconfig" in kwargs:
|
||||||
@ -2402,6 +2406,22 @@ def run_test_using_subprocess(func):
|
|||||||
subprocess.run(command, env=env, check=True, capture_output=True)
|
subprocess.run(command, env=env, check=True, capture_output=True)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
exception_message = e.stdout.decode()
|
exception_message = e.stdout.decode()
|
||||||
|
lines = exception_message.split("\n")
|
||||||
|
# Add a first line with more informative information instead of just `= test session starts =`.
|
||||||
|
# This makes the `short test summary info` section more useful.
|
||||||
|
if "= test session starts =" in lines[0]:
|
||||||
|
text = ""
|
||||||
|
for line in lines[1:]:
|
||||||
|
if line.startswith("FAILED "):
|
||||||
|
text = line[len("FAILED ") :]
|
||||||
|
text = "".join(text.split(" - ")[1:])
|
||||||
|
elif line.startswith("=") and line.endswith("=") and " failed in " in line:
|
||||||
|
break
|
||||||
|
elif len(text) > 0:
|
||||||
|
text += f"\n{line}"
|
||||||
|
text = "(subprocess) " + text
|
||||||
|
lines = [text] + lines
|
||||||
|
exception_message = "\n".join(lines)
|
||||||
raise pytest.fail(exception_message, pytrace=False)
|
raise pytest.fail(exception_message, pytrace=False)
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
@ -1076,6 +1076,11 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
for line in artifact["summary_short"].split("\n"):
|
for line in artifact["summary_short"].split("\n"):
|
||||||
if line.startswith("FAILED "):
|
if line.startswith("FAILED "):
|
||||||
|
# Avoid the extra `FAILED` entry given by `run_test_using_subprocess` causing issue when calling
|
||||||
|
# `stacktraces.pop` below.
|
||||||
|
# See `run_test_using_subprocess` in `src/transformers/testing_utils.py`
|
||||||
|
if " - Failed: (subprocess)" in line:
|
||||||
|
continue
|
||||||
line = line[len("FAILED ") :]
|
line = line[len("FAILED ") :]
|
||||||
line = line.split()[0].replace("\n", "")
|
line = line.split()[0].replace("\n", "")
|
||||||
|
|
||||||
@ -1186,6 +1191,11 @@ if __name__ == "__main__":
|
|||||||
if failed:
|
if failed:
|
||||||
for line in artifact["summary_short"].split("\n"):
|
for line in artifact["summary_short"].split("\n"):
|
||||||
if line.startswith("FAILED "):
|
if line.startswith("FAILED "):
|
||||||
|
# Avoid the extra `FAILED` entry given by `run_test_using_subprocess` causing issue when calling
|
||||||
|
# `stacktraces.pop` below.
|
||||||
|
# See `run_test_using_subprocess` in `src/transformers/testing_utils.py`
|
||||||
|
if " - Failed: (subprocess)" in line:
|
||||||
|
continue
|
||||||
line = line[len("FAILED ") :]
|
line = line[len("FAILED ") :]
|
||||||
line = line.split()[0].replace("\n", "")
|
line = line.split()[0].replace("\n", "")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user