(source_dir: Path, output_dir: Path, clean: bool = True)
| 358 | |
| 359 | |
| 360 | def prepare(source_dir: Path, output_dir: Path, clean: bool = True) -> None: |
| 361 | if clean and output_dir.exists(): |
| 362 | shutil.rmtree(output_dir) |
| 363 | output_dir.mkdir(parents=True, exist_ok=True) |
| 364 | |
| 365 | print(f"[package] source={source_dir}") |
| 366 | print(f"[package] output={output_dir}") |
| 367 | |
| 368 | print("[package] writing users.jsonl") |
| 369 | user_count = write_jsonl(output_dir / "data" / "users.jsonl", user_rows(source_dir)) |
| 370 | print(f"[package] users={user_count}") |
| 371 | copy_if_exists(source_dir / "episodes.jsonl", output_dir / "data" / "episodes.jsonl") |
| 372 | copy_if_exists(source_dir / "drift_timeline.jsonl", output_dir / "data" / "drift_timeline.jsonl") |
| 373 | print("[package] writing papers.jsonl") |
| 374 | paper_count = write_jsonl(output_dir / "data" / "papers.jsonl", paper_rows(source_dir)) |
| 375 | print(f"[package] papers={paper_count}") |
| 376 | |
| 377 | print("[package] writing episode_labels.jsonl") |
| 378 | label_count = write_jsonl(output_dir / "data" / "episode_labels.jsonl", label_rows(source_dir)) |
| 379 | print(f"[package] episode_labels={label_count}") |
| 380 | |
| 381 | reports_src = source_dir / "reading_reports.jsonl" |
| 382 | reports_dst = output_dir / "reference_outputs" / "paperflow_reading_reports.jsonl" |
| 383 | copy_reading_reports(reports_src, reports_dst) |
| 384 | |
| 385 | eval_src = PROJECT_ROOT / "experiments" / "benchmark" / "evaluate_benchmark_predictions.py" |
| 386 | copy_if_exists(eval_src, output_dir / "evaluation" / "evaluate.py") |
| 387 | submission_src = PROJECT_ROOT / "experiments" / "benchmark" / "make_benchmark_submission.py" |
| 388 | copy_if_exists(submission_src, output_dir / "evaluation" / "make_submission.py") |
| 389 | report_eval_src = PROJECT_ROOT / "experiments" / "benchmark" / "evaluate_report_outputs.py" |
| 390 | copy_if_exists(report_eval_src, output_dir / "evaluation" / "evaluate_reports.py") |
| 391 | (output_dir / "evaluation" / "README.md").write_text(evaluation_readme(), encoding="utf-8") |
| 392 | (output_dir / "README.md").write_text(dataset_card(), encoding="utf-8") |
| 393 | (output_dir / "VERSION").write_text("0.1.0\n", encoding="utf-8") |
| 394 | (output_dir / ".gitignore").write_text("__pycache__/\n*.py[cod]\n*$py.class\n", encoding="utf-8") |
| 395 | sanitize_release_text_files(output_dir) |
| 396 | |
| 397 | |
| 398 | def parse_args() -> argparse.Namespace: |
no test coverage detected