Skill Tracer
Skills › Scientific Agent Skills › pylabrobot › validate_manifest.py

validate_manifest.py

47 lines · skills/pylabrobot/scripts/validate_manifest.py at 5f2bc03

1#!/usr/bin/env python3
2"""Validate a strict offline PyLabRobot protocol manifest."""
3
4from __future__ import annotations
5
6import argparse
7from typing import Sequence
8
9if __package__:
10 from ._common import ValidationError, emit_error, emit_json, load_json, validate_manifest
11else:
12 from _common import ValidationError, emit_error, emit_json, load_json, validate_manifest
15def build_parser() -> argparse.ArgumentParser:
16 parser = argparse.ArgumentParser(
17 description=(
18 "Validate protocol-manifest schema v1.0. This command is dependency-free "
19 "and never imports PyLabRobot or accesses hardware/network interfaces."
20 )
21 )
22 parser.add_argument("--input", required=True, help="Local UTF-8 .json manifest")
23 return parser
26def main(argv: Sequence[str] | None = None) -> int:
27 args = build_parser().parse_args(argv)
28 try:
29 manifest = validate_manifest(load_json(args.input))
30 except (OSError, ValidationError) as error:
31 return emit_error(error)
32 emit_json(
33 {
34 "ok": True,
35 "protocol_id": manifest["protocol_id"],
36 "schema_version": manifest["schema_version"],
37 "mode": manifest["mode"],
38 "resource_count": len(manifest["resources"]),
39 "requires_human_confirmation": True,
40 "hardware_access": False,
41 }
42 )
43 return 0
46if __name__ == "__main__":
47 raise SystemExit(main())