| |
| from __future__ import annotations |
|
|
| from pathlib import Path |
| import argparse |
| import json |
| import sys |
|
|
| sys.dont_write_bytecode = True |
|
|
|
|
| def read_first_jsonl(path: Path) -> dict: |
| with open(path, "r", encoding="utf-8") as f: |
| for line in f: |
| if line.strip(): |
| return json.loads(line) |
| raise ValueError(f"no JSONL records found: {path}") |
|
|
|
|
| def main() -> None: |
| parser = argparse.ArgumentParser() |
| parser.add_argument("--artifact", required=True, help="Path to a JSONL artifact file.") |
| parser.add_argument("--bundle-root", default=None, help="Bundle root override.") |
| args = parser.parse_args() |
|
|
| bundle_root = Path(args.bundle_root).resolve() if args.bundle_root else Path(__file__).resolve().parents[1] |
| sys.path.insert(0, str(bundle_root)) |
|
|
| from real_pipeline.psy_infer import infer_artifact |
|
|
| record = read_first_jsonl(Path(args.artifact)) |
| result = infer_artifact(record, bundle_root) |
| print(json.dumps(result, sort_keys=True, separators=(",", ":"))) |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|