Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
younesbelkada committed Jan 12, 2024
1 parent 9585ce8 commit 4ea24af
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
27 changes: 15 additions & 12 deletions scripts/log_example_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@

def main(text_file_name, slack_channel_name=None):
message = ""
payload = [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "🤗 Results of the {} TRL example tests.".format(os.environ.get("TEST_TYPE", "")),
},
},
]

if os.path.isfile(text_file_name):
final_results = {}
Expand Down Expand Up @@ -72,6 +63,20 @@ def main(text_file_name, slack_channel_name=None):

total_num_failed = 0

test_type_name = text_file_name.replace(".txt", "").replace("temp_results_", "").replace("_", " ").title()

payload = [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "🤗 Results of the {} TRL {} example tests.".format(
os.environ.get("TEST_TYPE", ""), test_type_name
),
},
},
]

if total_num_failed > 0:
message += f"{total_num_failed} failed tests for example tests!"

Expand Down Expand Up @@ -113,14 +118,12 @@ def main(text_file_name, slack_channel_name=None):
}
payload.append(action_button)

test_type_name = text_file_name.replace(".txt", "").replace("temp_results_", "")

date_report = {
"type": "context",
"elements": [
{
"type": "plain_text",
"text": f"Nightly {os.environ.get('TEST_TYPE') + test_type_name} test results for {date.today()}",
"text": f"On Push - main {os.environ.get('TEST_TYPE')} test results for {date.today()}",
},
],
}
Expand Down
7 changes: 5 additions & 2 deletions scripts/log_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ def main(slack_channel_name=None):
message += f"*{name}: {num_failed} failed tests*\n"
failed_table = []
for test in failed_tests:
failed_table.append(test[0].split("::"))
failed_report = test[0].split("::")
# Truncate the last string as some test names might be long
failed_report[-1] = failed_report[-1][:15] + ".."
failed_table.append(failed_report)
failed_table = tabulate(
failed_table,
headers=["Test Location", "Test Case", "Test Name"],
Expand Down Expand Up @@ -133,7 +136,7 @@ def main(slack_channel_name=None):
"elements": [
{
"type": "plain_text",
"text": f"Nightly {os.environ.get('TEST_TYPE')} test results for {date.today()}",
"text": f"On Push main {os.environ.get('TEST_TYPE')} test results for {date.today()}",
},
],
}
Expand Down

0 comments on commit 4ea24af

Please sign in to comment.