Historie 1949–2022 bleibt in lawgit, bis der GPU-Lauf endet; Schnitt ohne Lücke. Co-authored-by: Cursor <cursoragent@cursor.com>
103 lines
3.0 KiB
Python
103 lines
3.0 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Inkrementeller Abgleich ab 2023: laden → Text → Heuristik-Parse.
|
|
|
|
Idempotent und wiederaufsetzbar: vorhandene PDFs, Extrakte und Events
|
|
werden übersprungen. LLM bleibt aus, außer mit --llm (kostet, nicht
|
|
parallel zum lawgit-GPU-Lauf starten).
|
|
|
|
python3 sync.py --live-test
|
|
python3 sync.py --from-year 2023
|
|
python3 sync.py --year 2026
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import subprocess
|
|
import sys
|
|
from datetime import datetime
|
|
from pathlib import Path
|
|
|
|
from bgbl_util import META_DIR, ROOT, save_json
|
|
|
|
PY = sys.executable
|
|
|
|
|
|
def run(args: list[str]) -> None:
|
|
print("+", " ".join(args), flush=True)
|
|
subprocess.run([PY, *args], cwd=ROOT, check=True)
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser(description="BGBl ab 2023 nachziehen (recht.bund.de)")
|
|
parser.add_argument("--live-test", action="store_true", help="2024/1, 2025/1, 2026/1")
|
|
parser.add_argument("--year", type=int, action="append")
|
|
parser.add_argument("--from-year", type=int)
|
|
parser.add_argument("--to-year", type=int)
|
|
parser.add_argument("--kind", choices=["bgbl1", "bgbl2"], default="bgbl1")
|
|
parser.add_argument("--limit", type=int, default=0)
|
|
parser.add_argument(
|
|
"--llm",
|
|
action="store_true",
|
|
help="Nach dem Download mit LLM parsen. Standard: Heuristik. "
|
|
"Nicht setzen, solange lawgit auf RunPod parst.",
|
|
)
|
|
parser.add_argument("--force", action="store_true")
|
|
args = parser.parse_args()
|
|
|
|
dl = ["download_rechtbund.py", "--kind", args.kind]
|
|
if args.live_test:
|
|
dl.append("--live-test")
|
|
for y in args.year or []:
|
|
dl.extend(["--year", str(y)])
|
|
if args.from_year:
|
|
dl.extend(["--from-year", str(args.from_year)])
|
|
if args.to_year:
|
|
dl.extend(["--to-year", str(args.to_year)])
|
|
if args.limit:
|
|
dl.extend(["--limit", str(args.limit)])
|
|
if not args.live_test and not args.year and not args.from_year:
|
|
parser.error("Bitte --live-test, --year oder --from-year angeben")
|
|
|
|
run(dl)
|
|
|
|
ex = ["extract_bgbl.py", "--kind", args.kind]
|
|
years = list(args.year or [])
|
|
if args.live_test:
|
|
years.extend([2024, 2025, 2026])
|
|
if args.from_year:
|
|
years.extend(range(args.from_year, (args.to_year or datetime.now().year) + 1))
|
|
years = sorted(set(years))
|
|
for y in years:
|
|
ex.extend(["--year", str(y)])
|
|
if args.force:
|
|
ex.append("--force")
|
|
run(ex)
|
|
|
|
pr = ["parse_bgbl.py"]
|
|
for y in years:
|
|
pr.extend(["--year", str(y)])
|
|
if args.llm:
|
|
pr.append("--llm")
|
|
if args.force:
|
|
pr.append("--force")
|
|
run(pr)
|
|
|
|
save_json(
|
|
META_DIR / "letzter-sync.json",
|
|
{
|
|
"zeit": datetime.now().isoformat(timespec="seconds"),
|
|
"jahre": years,
|
|
"kind": args.kind,
|
|
"llm": bool(args.llm),
|
|
"live_test": bool(args.live_test),
|
|
},
|
|
)
|
|
print("\nSync fertig. Nächster voller Nachzug ab 2023:")
|
|
print(" python3 sync.py --from-year 2023")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|