Skip to content

Commit cf8f376

Browse files
Add graph display to GitHub Actions summary
Co-authored-by: functionstackx <47992694+functionstackx@users.noreply.github.com>
1 parent cd84697 commit cf8f376

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

.github/workflows/collect-results.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ jobs:
4141
run: |
4242
pip install -q matplotlib
4343
python3 utils/plot_perf.py results/ ${{ inputs.exp-name || 'all' }}
44+
45+
- name: Display graphs in summary
46+
run: python3 utils/display_graphs.py ${{ inputs.exp-name || 'all' }} >> $GITHUB_STEP_SUMMARY
47+
4448
- name: Upload performance graphs
4549
uses: actions/upload-artifact@v5
4650
with:

utils/display_graphs.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import sys
2+
import base64
3+
from pathlib import Path
4+
5+
6+
def encode_image_to_base64(image_path):
7+
"""Encode an image file to base64 string."""
8+
with open(image_path, 'rb') as image_file:
9+
encoded = base64.b64encode(image_file.read()).decode('utf-8')
10+
return encoded
11+
12+
13+
def display_graphs(exp_name):
14+
"""Display performance graphs in GitHub Actions summary."""
15+
print("\n## Performance Graphs\n")
16+
17+
# Find all generated graphs
18+
current_dir = Path('.')
19+
20+
# Look for tput_vs_intvty graphs
21+
intvty_graphs = sorted(current_dir.glob(f'tput_vs_intvty_*_{exp_name}.png'))
22+
e2el_graphs = sorted(current_dir.glob(f'tput_vs_e2el_*_{exp_name}.png'))
23+
24+
# Display interactivity graphs
25+
if intvty_graphs:
26+
print("### Throughput vs Interactivity\n")
27+
for graph in intvty_graphs:
28+
# Extract model name from filename
29+
model_name = graph.name.replace(f'tput_vs_intvty_', '').replace(f'_{exp_name}.png', '')
30+
base64_image = encode_image_to_base64(graph)
31+
print(f"#### {model_name.upper()}\n")
32+
print(f"![Throughput vs Interactivity - {model_name}](data:image/png;base64,{base64_image})\n")
33+
34+
# Display end-to-end latency graphs
35+
if e2el_graphs:
36+
print("### Throughput vs End-to-End Latency\n")
37+
for graph in e2el_graphs:
38+
# Extract model name from filename
39+
model_name = graph.name.replace(f'tput_vs_e2el_', '').replace(f'_{exp_name}.png', '')
40+
base64_image = encode_image_to_base64(graph)
41+
print(f"#### {model_name.upper()}\n")
42+
print(f"![Throughput vs E2E Latency - {model_name}](data:image/png;base64,{base64_image})\n")
43+
44+
if not intvty_graphs and not e2el_graphs:
45+
print("*No performance graphs were generated.*\n")
46+
47+
48+
if __name__ == '__main__':
49+
if len(sys.argv) < 2:
50+
print("Usage: python3 display_graphs.py <exp_name>")
51+
sys.exit(1)
52+
53+
exp_name = sys.argv[1]
54+
display_graphs(exp_name)

0 commit comments

Comments
 (0)