Download scripts/check_generated_committed.py from Simple7up/IOM: direct link, hf CLI and curl.
- Browser
- Download file 2.28 kB
-
https://huggingface.co/datasets/Simple7up/IOM/resolve/main/scripts/check_generated_committed.py
- Command line
-
hf download hf://datasets/Simple7up/IOM/scripts/check_generated_committed.py
-
curl -L -o check_generated_committed.py https://huggingface.co/datasets/Simple7up/IOM/resolve/main/scripts/check_generated_committed.py
2.28 kB
| #!/usr/bin/env python3 | |
| """Comprueba que los CSV versionados coinciden con generate_ontology.py. | |
| Solo se exige igualdad exacta de: | |
| - datasets/triad_nodes.csv | |
| - datasets/vector_steps.csv | |
| - datasets/relation_candidates.csv | |
| - datasets/GENERATED_FROM.json (spec_version del generador) | |
| El TTL no se compara byte-a-byte (serialización rdflib). | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import subprocess | |
| import sys | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| GENERATED_CSV = [ | |
| "datasets/triad_nodes.csv", | |
| "datasets/vector_steps.csv", | |
| "datasets/relation_candidates.csv", | |
| "datasets/GENERATED_FROM.json", | |
| ] | |
| def run(cmd: list[str]) -> subprocess.CompletedProcess: | |
| return subprocess.run(cmd, cwd=ROOT, capture_output=True, text=True) | |
| def main() -> int: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--with-manifest", action="store_true") | |
| parser.add_argument("--skip-generate", action="store_true") | |
| parser.add_argument("--include-ttl", action="store_true") | |
| args = parser.parse_args() | |
| if not args.skip_generate: | |
| print(">>> generate_ontology.py") | |
| r = run([sys.executable, "scripts/generate_ontology.py"]) | |
| print(r.stdout, end="") | |
| if r.returncode != 0: | |
| print(r.stderr, file=sys.stderr) | |
| return 1 | |
| paths = list(GENERATED_CSV) | |
| if args.include_ttl: | |
| paths.insert(0, "ontology/io_ontology.ttl") | |
| if args.with_manifest: | |
| print(">>> create_manifest.py") | |
| r = run([sys.executable, "scripts/create_manifest.py"]) | |
| print(r.stdout, end="") | |
| if r.returncode != 0: | |
| print(r.stderr, file=sys.stderr) | |
| return 1 | |
| paths.append("MANIFEST.sha256") | |
| print(">>> git diff --ignore-space-at-eol --exit-code", " ".join(paths)) | |
| r = run(["git", "diff", "--ignore-space-at-eol", "--exit-code", "--", *paths]) | |
| if r.returncode != 0: | |
| print( | |
| "ERROR: los artefactos generados no coinciden con lo versionado.", | |
| file=sys.stderr, | |
| ) | |
| print(r.stdout or r.stderr, file=sys.stderr) | |
| return 1 | |
| print("OK: derivados (CSV + GENERATED_FROM) coinciden con HEAD") | |
| return 0 | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |