import json from pathlib import Path import pandas as pd import plotly.express as px def parse_json_files(folder_path): # Convert folder path to Path object folder = Path(folder_path) # List to store data from each file data_list = [] # Iterate through all JSON files in the folder for json_file in folder.glob('*.json'): try: with open(json_file, 'r') as file: data = json.load(file) # Extract config and results config = data['config'] results = data['results'] # Combine config and results into a single dictionary combined_data = { 'agent_name': config['agent_name'], 'benchmark_name': config['benchmark_name'], 'date': config['date'] } # Add results with 'results_' prefix for key, value in results.items(): combined_data[f'results_{key}'] = value data_list.append(combined_data) except Exception as e: print(f"Error processing {json_file}: {e}. Skipping!") # Create DataFrame from the list of dictionaries df = pd.DataFrame(data_list) return df def create_scatter_plot(df, x: str, y: str, x_label: str = None, y_label: str = None, hover_data: list = None): fig = px.scatter(df, x=x, y=y, hover_data=hover_data, ) fig.update_layout( width = 600, height = 500, xaxis_title = x_label, yaxis_title = y_label, xaxis = dict( showline = True, linecolor = 'black', showgrid = False), yaxis = dict( showline = True, showgrid = False, linecolor = 'black' ), plot_bgcolor = 'white' ) return fig