Clear benchmark state while preserving the fixed paper collection.
(
db_path: Path = DB_PATH,
roles_path: Path = ROLES_FILE,
backup_dir: Path = BACKUP_DIR,
roles: Optional[Iterable[str]] = None,
)
| 256 | |
| 257 | |
| 258 | def benchmark_reset( |
| 259 | db_path: Path = DB_PATH, |
| 260 | roles_path: Path = ROLES_FILE, |
| 261 | backup_dir: Path = BACKUP_DIR, |
| 262 | roles: Optional[Iterable[str]] = None, |
| 263 | ) -> Dict[str, Any]: |
| 264 | """Clear benchmark state while preserving the fixed paper collection.""" |
| 265 | backup_path = backup_database(db_path=db_path, backup_dir=backup_dir) |
| 266 | roles_meta = load_roles_meta(roles_path=roles_path) |
| 267 | |
| 268 | conn = get_connection(db_path=db_path) |
| 269 | try: |
| 270 | before_counts = get_table_counts(conn) |
| 271 | clear_tables(conn, ("behavior_logs", "task_status")) |
| 272 | seeded_profiles = reset_user_profiles(conn, roles_meta, roles=roles) |
| 273 | reset_sqlite_sequences(conn, ("profiles", "behavior_logs", "task_status")) |
| 274 | conn.commit() |
| 275 | after_counts = get_table_counts(conn) |
| 276 | finally: |
| 277 | conn.close() |
| 278 | |
| 279 | return { |
| 280 | "backup_path": str(backup_path), |
| 281 | "before_counts": before_counts, |
| 282 | "after_counts": after_counts, |
| 283 | "seeded_profiles": seeded_profiles, |
| 284 | } |
| 285 | |
| 286 | |
| 287 | def parse_args() -> argparse.Namespace: |
no test coverage detected