11import sys
2- import base64
32from pathlib import Path
43
54
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."""
5+ def display_graphs (exp_name , repo , run_id , artifact_name ):
6+ """Display performance graphs in GitHub Actions summary with artifact links."""
157 print ("\n ## Performance Graphs\n " )
168
179 # Find all generated graphs
@@ -21,34 +13,38 @@ def display_graphs(exp_name):
2113 intvty_graphs = sorted (current_dir .glob (f'tput_vs_intvty_*_{ exp_name } .png' ))
2214 e2el_graphs = sorted (current_dir .glob (f'tput_vs_e2el_*_{ exp_name } .png' ))
2315
16+ # Construct artifact download URL
17+ artifact_url = f"https://github.com/{ repo } /actions/runs/{ run_id } /artifacts"
18+
2419 # Display interactivity graphs
2520 if intvty_graphs :
2621 print ("### Throughput vs Interactivity\n " )
2722 for graph in intvty_graphs :
2823 # Extract model name from filename
2924 model_name = graph .name .replace (f'tput_vs_intvty_' , '' ).replace (f'_{ exp_name } .png' , '' )
30- base64_image = encode_image_to_base64 (graph )
3125 print (f"#### { model_name .upper ()} \n " )
32- print (f"\n " )
26+ print (f"📊 [ { graph . name } ]({ artifact_url } ) (download ` { artifact_name } ` artifact )\n " )
3327
3428 # Display end-to-end latency graphs
3529 if e2el_graphs :
3630 print ("### Throughput vs End-to-End Latency\n " )
3731 for graph in e2el_graphs :
3832 # Extract model name from filename
3933 model_name = graph .name .replace (f'tput_vs_e2el_' , '' ).replace (f'_{ exp_name } .png' , '' )
40- base64_image = encode_image_to_base64 (graph )
4134 print (f"#### { model_name .upper ()} \n " )
42- print (f"\n " )
35+ print (f"📊 [ { graph . name } ]({ artifact_url } ) (download ` { artifact_name } ` artifact )\n " )
4336
4437 if not intvty_graphs and not e2el_graphs :
4538 print ("*No performance graphs were generated.*\n " )
4639
4740
4841if __name__ == '__main__' :
49- if len (sys .argv ) < 2 :
50- print ("Usage: python3 display_graphs.py <exp_name>" )
42+ if len (sys .argv ) < 5 :
43+ print ("Usage: python3 display_graphs.py <exp_name> <repo> <run_id> <artifact_name> " )
5144 sys .exit (1 )
5245
5346 exp_name = sys .argv [1 ]
54- display_graphs (exp_name )
47+ repo = sys .argv [2 ]
48+ run_id = sys .argv [3 ]
49+ artifact_name = sys .argv [4 ]
50+ display_graphs (exp_name , repo , run_id , artifact_name )
0 commit comments