Skip to content

Commit 0b2b06a

Browse files
committed
update
1 parent 1f9a4fa commit 0b2b06a

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

.ci/benchmark.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
import os
12
import sys
23
from src.benchmark.utils import read_metrics, to_html_table
34

45
if __name__ == "__main__":
56
# Generate statistics report
6-
metrics = read_metrics(sys.argv[1], metric="accuracy")
7+
statistics_path = sys.argv[1]
8+
metrics = read_metrics(statistics_path, metric="accuracy")
79
html_table = to_html_table(metrics)
8-
print(html_table)
10+
11+
# Write to workflow job summary
12+
summary_path = os.environ["GITHUB_STEP_SUMMARY"]
13+
with open(summary_path, "a") as f:
14+
f.write("## My Job Summary\n")
15+
f.write(html_table)

.github/workflows/_ascend_npu_benchmark.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,22 +117,16 @@ jobs:
117117
retention-days: 1
118118
overwrite: true
119119

120-
- name: Generate statistics report
120+
- name: Write to workflow job summary
121121
id: report
122122
run: |
123123
set -x
124124
realpath benchmark/ascend_npu_benchmark.json
125125
ls benchmark
126126
cat benchmark/ascend_npu_benchmark.json
127-
output_path=$(realpath benchmark/ascend_npu_benchmark.json)
128-
table=$(python .ci/benchmark.py ${output_path})
129-
echo "table=${table}" >> $GITHUB_OUTPUT
130127
131-
- name: Write to workflow job summary
132-
if: ${{ steps.report.outputs.table }}
133-
run: |
134-
echo "## Torchbenchmark statistics report" >> $GITHUB_STEP_SUMMARY
135-
echo "${{ steps.report.outputs.table }}" >> $GITHUB_STEP_SUMMARY
128+
output_path=$(realpath benchmark/ascend_npu_benchmark.json)
129+
python .ci/benchmark.py ${output_path}
136130
137131
- name: Modify README.md
138132
if: ${{ always() }}

src/benchmark/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ def save_file(path: str, data) -> None:
3737

3838

3939
def parse_to_dict(config_str: str):
40+
"""
41+
Parse a string (like 'key1=value1, key2=value2, ...') into a dict
42+
"""
4043
items = config_str.split(", ")
4144
config = {}
4245

0 commit comments

Comments
 (0)