|
| 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"\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"\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