File size: 1,220 Bytes
adc02fa | 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 | #!/usr/bin/env python
from __future__ import annotations
import argparse
import json
import sys
from pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parents[1]
if str(PROJECT_ROOT) not in sys.path:
sys.path.insert(0, str(PROJECT_ROOT))
from dovla_cil.data.datasets import CILDataset, write_cil_collection # noqa: E402
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(
description="Create a zero-copy collection over multiple CIL datasets."
)
parser.add_argument("--sources", nargs="+", type=Path, required=True)
parser.add_argument("--out", type=Path, required=True)
parser.add_argument("--name", default="dovla_cil_collection")
args = parser.parse_args(argv)
path = write_cil_collection(args.out, args.sources, dataset_name=args.name)
dataset = CILDataset(args.out)
print(
json.dumps(
{
"collection": str(path),
"num_sources": len(args.sources),
"num_groups": len(dataset.group_ids),
"num_records": len(dataset),
},
indent=2,
)
)
return 0
if __name__ == "__main__":
raise SystemExit(main())
|