Skip to content

Conversation

@ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Aug 31, 2023

What does this PR do?

I am not sure if this will helps the navigation (much), but at least for the team members to try.

A new step is added to show the (only faiiled) test results, and it looks like
Screenshot 2023-08-31 184247

The Run tests step won't fail now (otherwise we can't have the new Check test results step), but the new step will (if there is indeed a failed test).

For a job run page, see here

WDYT?

test_command = f"({test_command}) || true"
else:
test_command += " | tee tests_output.txt"
test_command += " | tee tests_output.txt || true"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step will always succeed. This is not ideal, but it's necessary for the next step (Check test results) to run (when some tests fail).

Comment on lines 229 to 247
check_test_command = f'if [ -s reports/tests_{self.name}/failures_short.txt ]; '
check_test_command += 'then echo "Some test failed!"; echo ""; '
check_test_command += f'cat reports/tests_{self.name}/failures_short.txt; '
check_test_command += 'echo ""; echo ""; '

py_command = f'import os; fp = open("reports/tests_{self.name}/summary_short.txt"); failed = os.linesep.join([x for x in fp.read().split(os.linesep) if x.startswith("FAILED ")]); fp.close(); fp = open("summary_short.txt", "w"); fp.write(failed); fp.close()'
check_test_command += f"$(python3 -c '{py_command}'); "

check_test_command += f'cat summary_short.txt; exit -1; '
check_test_command += f'elif [ -s reports/tests_{self.name}/stats.txt ]; then echo "All tests pass!"; '

# return code `124` means the previous (pytest run) step is timeout
if self.name == "pr_documentation_tests":
checkout_doctest_command = 'if [ -s reports/tests_pr_documentation_tests/failures_short.txt ]; '
checkout_doctest_command += 'then echo "some test failed"; '
checkout_doctest_command += 'cat reports/tests_pr_documentation_tests/failures_short.txt; '
checkout_doctest_command += 'cat reports/tests_pr_documentation_tests/summary_short.txt; exit -1; '
checkout_doctest_command += 'elif [ -s reports/tests_pr_documentation_tests/stats.txt ]; then echo "All tests pass!"; '
checkout_doctest_command += 'elif [ -f 124.txt ]; then echo "doctest timeout!"; else echo "other fatal error)"; exit -1; fi;'
steps.append({"run": {"name": "Check doctest results", "command": checkout_doctest_command}})
check_test_command += 'elif [ -f 124.txt ]; then echo "doctest timeout!"; '

check_test_command += 'else echo "other fatal error"; exit -1; fi;'
check_test_command += 'echo ""; '

steps.append({"run": {"name": "Check test results", "command": check_test_command}})
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit ugly, but just to show the failed (and only failed) tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far I put failures_short.tx. We can use failures_long.tx if you prefer.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Aug 31, 2023

The documentation is not available anymore as the PR was closed or merged.

@ydshieh ydshieh requested review from ArthurZucker and amyeroberts and removed request for ArthurZucker and amyeroberts September 4, 2023 11:17
Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure there is a lot of difference between this and looking at the artifacts. Also if we do this, we could also remove the call to | tee following #23027.
This way you can either have a nice looking output on the page or go and check the artifacts.

@ydshieh
Copy link
Collaborator Author

ydshieh commented Sep 4, 2023

No problem to close if you maintainers don't feel it makes navigation (even slightly) better/faster.

@ArthurZucker
Copy link
Collaborator

I'm actually in favor if we also remove tee 😉

Copy link
Contributor

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output is so much better - thank you!

@ydshieh
Copy link
Collaborator Author

ydshieh commented Sep 5, 2023

@amyeroberts BTW, the tests_output.txt will be removed to make @ArthurZucker happier. But want to have your confirmation too.

@ydshieh ydshieh requested a review from ArthurZucker September 5, 2023 12:13
@ydshieh
Copy link
Collaborator Author

ydshieh commented Sep 5, 2023

No more tea Sir, sorry.

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arf, it seems that we still don't have the nice output I was hoping for (with colors and more readable errors). Do you know why / could you try aiming for this?

ex:
image

@ydshieh
Copy link
Collaborator Author

ydshieh commented Sep 5, 2023

I need a run (page) that already has such colors and format.

Personally, I don't feel it's necessary to have it - as we (mostly if not always) care the failing ones. The new step already give ONLY the failed tests without the passing and skipped one - so the color doesn't matter (at least for me).

I would move on to merge this PR as you and amy is OK with the changes. For the color thing, if you can provide a run page, I could probably give it a try in the future.

@ArthurZucker
Copy link
Collaborator

Sure 😉 feel free to merge!

@ydshieh
Copy link
Collaborator Author

ydshieh commented Sep 5, 2023

We do have color (on the test run step, not the new test result showing step), but it only show the failing ones. See here.

On current main, no RED color at all.

Screenshot 2023-09-05 152009

@amyeroberts
Copy link
Contributor

Happy for tests_output.txt to go - all the info can be found in the other artefacts

@ArthurZucker
Copy link
Collaborator

Perfect!

@ydshieh ydshieh merged commit aa5c94d into main Sep 5, 2023
@ydshieh ydshieh deleted the show_failure_better branch September 5, 2023 13:49
@ydshieh ydshieh mentioned this pull request Sep 7, 2023
parambharat pushed a commit to parambharat/transformers that referenced this pull request Sep 26, 2023
* update

* update

* fix

---------

Co-authored-by: ydshieh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants