#!/usr/bin/env python3 """Create a minimal valid FAISS HNSW32 + IndexIDMap2 fixture for the test harness. Used by the `tile-init` init service in docker-compose.test.jetson.yml. Writes three files to /var/lib/gps-denied/tiles/ via the shared `tests.e2e.replay._faiss_seed.seed_empty_faiss_index` helper (AZ-964): descriptor.index — empty HNSW32 dim=512 binary descriptor.index.sha256 — sha256 sidecar (matches FaissDescriptorIndex._load) descriptor.index.meta.json — metadata (descriptor_dim, hnsw_params.metric, ...) Running this twice is idempotent (overwrites the previous fixture). """ from __future__ import annotations import sys from pathlib import Path # Make the repo root importable so `tests.e2e.replay._faiss_seed` resolves # when this script runs in the `tile-init` compose service (which mounts # the repo at /opt/project but doesn't add it to PYTHONPATH). _REPO_ROOT = Path(__file__).resolve().parent.parent if str(_REPO_ROOT) not in sys.path: sys.path.insert(0, str(_REPO_ROOT)) from tests.e2e.replay._faiss_seed import seed_empty_faiss_index # noqa: E402 def main() -> int: idx_path = seed_empty_faiss_index(Path("/var/lib/gps-denied/tiles")) sha256_path = idx_path.parent / (idx_path.name + ".sha256") sha256 = sha256_path.read_text(encoding="ascii").strip() print( f"[tile-init] OK: empty HNSW32 index at {idx_path} " f"sha256={sha256[:16]}..." ) return 0 if __name__ == "__main__": sys.exit(main())