rerun-viewer / data /loader.py
abreza's picture
refactor and organize files
ffbf761
raw
history blame
653 Bytes
import json
from typing import Optional, Dict, Any, List, Tuple
def load_simulation_data(file) -> Tuple[Optional[List[Dict[str, Any]]], Optional[List[str]]]:
if file is None:
return None, None
try:
json_data = json.load(open(file.name))
simulations = json_data['simulations']
descriptions = [
f"Simulation {i}: {len(sim['subjects'])} subjects, {len(sim['instructions'])} instructions"
for i, sim in enumerate(simulations)
]
return simulations, descriptions
except Exception as e:
print(f"Error loading simulation data: {str(e)}")
return None, None