Spaces:
Runtime error
Runtime error
File size: 1,551 Bytes
a753e74 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | """Output directory validation."""
from __future__ import annotations
from pathlib import Path
# Spec paper-module files a complete module must contain.
REQUIRED_FILES = [
"paper.md",
"metadata.json",
"sources.json",
"bibtex.bib",
"summary.md",
"claims.md",
"related_work.md",
"implementation.md",
"reproduction.md",
"study_notes.md",
"review.md",
"README.md",
"generation-report.md",
]
def validate_paper_module(output_dir: Path) -> list[dict]:
"""
Check that all required spec files exist in a paper module directory.
Returns list of {ok: bool, message: str} dicts.
"""
results = []
if not output_dir.exists():
return [{"ok": False, "message": f"Output directory does not exist: {output_dir}"}]
for filename in REQUIRED_FILES:
path = output_dir / filename
if path.exists():
results.append({"ok": True, "message": f"{filename} exists"})
else:
results.append({"ok": False, "message": f"Missing: {filename}"})
# Check metadata.json / sources.json are valid JSON
for name in ("metadata.json", "sources.json"):
path = output_dir / name
if path.exists():
try:
import json
json.loads(path.read_text(encoding="utf-8"))
results.append({"ok": True, "message": f"{name} is valid JSON"})
except Exception as e:
results.append({"ok": False, "message": f"{name} JSON parse error: {e}"})
return results
|