(conn: sqlite3.Connection, folder: Path)
| 261 | |
| 262 | |
| 263 | def import_single_folder(conn: sqlite3.Connection, folder: Path) -> bool: |
| 264 | cursor = conn.cursor() |
| 265 | folder_name = folder.name |
| 266 | metadata_file = folder / "metatdata.json" |
| 267 | |
| 268 | if not metadata_file.exists(): |
| 269 | return False |
| 270 | |
| 271 | try: |
| 272 | with open(metadata_file, "r") as f: |
| 273 | metadata = json.load(f) |
| 274 | except json.JSONDecodeError: |
| 275 | return False |
| 276 | |
| 277 | timestamp = parse_folder_timestamp(folder_name) |
| 278 | cprofile_exists = check_file_exists(folder, "cProfile.prof") |
| 279 | flamegraph_exists = check_file_exists(folder, "flamegraph.svg") |
| 280 | args_exists = check_file_exists(folder, "args") |
| 281 | |
| 282 | try: |
| 283 | cursor.execute( |
| 284 | """ |
| 285 | INSERT INTO profiling_runs |
| 286 | (folder_name, timestamp, execution_time_seconds, n_concurrent_trials, |
| 287 | disable_diffs, agent_name, cprofile_exists, flamegraph_exists, args_exists) |
| 288 | VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) |
| 289 | """, |
| 290 | ( |
| 291 | folder_name, |
| 292 | timestamp, |
| 293 | metadata.get("execution_time_seconds"), |
| 294 | metadata.get("n_concurrent_trials"), |
| 295 | metadata.get("disable_diffs"), |
| 296 | metadata.get("agent_name"), |
| 297 | cprofile_exists, |
| 298 | flamegraph_exists, |
| 299 | args_exists, |
| 300 | ), |
| 301 | ) |
| 302 | |
| 303 | run_id = cursor.lastrowid |
| 304 | |
| 305 | if cprofile_exists: |
| 306 | prof_path = folder / "cProfile.prof" |
| 307 | import_cprofile_data(cursor, run_id, prof_path) |
| 308 | |
| 309 | conn.commit() |
| 310 | return True |
| 311 | |
| 312 | except sqlite3.Error: |
| 313 | conn.rollback() |
| 314 | return False |
| 315 | |
| 316 | |
| 317 | def create_histogram(data: np.ndarray, title: str, xlabel: str, output_path: Path): |
no test coverage detected