File size: 1,112 Bytes
6fb01b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import argparse
import importlib
import json
from pathlib import Path

from govdata.common.pipeline import Options, run

DATASETS = ["wetten", "belastingdienst"]


def main(argv: list[str] | None = None) -> None:
    p = argparse.ArgumentParser(prog="govdata", description="Rebuild a dataset and publish it to Hugging Face.")
    p.add_argument("dataset", choices=DATASETS)
    p.add_argument("--limit", type=int, help="only index/fetch the first N records (for smoke runs)")
    p.add_argument("--no-upload", action="store_true", help="build locally, skip HF download and upload")
    p.add_argument("--out", type=Path, default=Path("out"))
    p.add_argument("--budget-hours", type=float, default=5.0, help="stop fetching after this long")
    args = p.parse_args(argv)

    src = importlib.import_module(f"govdata.{args.dataset}.source").SOURCE
    opt = Options(limit=args.limit, upload=not args.no_upload, out=args.out, budget_s=args.budget_hours * 3600)
    stats = run(src, opt, repo_root=Path(__file__).resolve().parents[2])
    print(json.dumps(stats, indent=2))


if __name__ == "__main__":
    main()