Upload folder using huggingface_hub
Browse files- scripts/validate.py +46 -0
scripts/validate.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Validate examples/sample_signal_log.json against datasets/schema/signal-log.schema.json
|
| 4 |
+
|
| 5 |
+
Usage:
|
| 6 |
+
python scripts/validate.py
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
import json
|
| 10 |
+
import sys
|
| 11 |
+
from pathlib import Path
|
| 12 |
+
|
| 13 |
+
from jsonschema import validate
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def main() -> int:
|
| 17 |
+
repo_root = Path(__file__).resolve().parents[1]
|
| 18 |
+
|
| 19 |
+
schema_path = repo_root / "datasets" / "schema" / "signal-log.schema.json"
|
| 20 |
+
sample_path = repo_root / "examples" / "sample_signal_log.json"
|
| 21 |
+
|
| 22 |
+
if not schema_path.exists():
|
| 23 |
+
print(f"[ERROR] Schema not found: {schema_path}", file=sys.stderr)
|
| 24 |
+
return 2
|
| 25 |
+
|
| 26 |
+
if not sample_path.exists():
|
| 27 |
+
print(f"[ERROR] Sample log not found: {sample_path}", file=sys.stderr)
|
| 28 |
+
return 2
|
| 29 |
+
|
| 30 |
+
with schema_path.open("r", encoding="utf-8") as f:
|
| 31 |
+
schema = json.load(f)
|
| 32 |
+
|
| 33 |
+
with sample_path.open("r", encoding="utf-8") as f:
|
| 34 |
+
data = json.load(f)
|
| 35 |
+
|
| 36 |
+
validate(instance=data, schema=schema)
|
| 37 |
+
print("OK: sample log matches schema")
|
| 38 |
+
return 0
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
if __name__ == "__main__":
|
| 42 |
+
try:
|
| 43 |
+
raise SystemExit(main())
|
| 44 |
+
except Exception as e:
|
| 45 |
+
print(f"[ERROR] Validation failed: {e}", file=sys.stderr)
|
| 46 |
+
raise
|