mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-06-21 15:41:12 +00:00
21a7784682
- gtsam_isam2_estimator: shim for gtsam>=4.3a0 aarch64 pre-release where IncrementalFixedLagSmoother/FixedLagSmootherKeyTimestampMap moved from gtsam_unstable to gtsam - inference_factory: eager import of c7_inference package so register_component_block runs before config.components is read - docker-compose.test.jetson.yml: remove companion and operator-orchestrator (not needed by replay CLI tests and crash in test env due to AZ-618 live-mode deps); add db-migrate and tile-init setup-profile services for Alembic migrations and FAISS fixture provisioning; update e2e-runner depends_on to db only - scripts/mk_test_faiss_fixture.py: generate minimal HNSW32 FAISS descriptor index into the tile-data volume for the test harness Co-authored-by: Cursor <cursoragent@cursor.com>
62 lines
1.8 KiB
Python
62 lines
1.8 KiB
Python
#!/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/:
|
|
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 hashlib
|
|
import json
|
|
from datetime import datetime, timezone
|
|
from pathlib import Path
|
|
|
|
import faiss # type: ignore[import-untyped]
|
|
|
|
DESCRIPTOR_DIM = 512
|
|
HNSW_M = 32
|
|
|
|
root = Path("/var/lib/gps-denied/tiles")
|
|
root.mkdir(parents=True, exist_ok=True)
|
|
|
|
inner = faiss.IndexHNSWFlat(DESCRIPTOR_DIM, HNSW_M, faiss.METRIC_INNER_PRODUCT)
|
|
index = faiss.IndexIDMap2(inner)
|
|
|
|
idx_path = root / "descriptor.index"
|
|
faiss.write_index(index, str(idx_path))
|
|
idx_bytes = idx_path.read_bytes()
|
|
sha256 = hashlib.sha256(idx_bytes).hexdigest()
|
|
|
|
(idx_path.parent / (idx_path.name + ".sha256")).write_text(sha256, encoding="ascii")
|
|
|
|
meta = {
|
|
"descriptor_dim": DESCRIPTOR_DIM,
|
|
"n_vectors": 0,
|
|
"backbone_label": "ultra_vpr",
|
|
"backbone_sha256_hex": "0" * 64,
|
|
"built_at": datetime.now(timezone.utc).isoformat(),
|
|
"hnsw_params": {
|
|
"m": HNSW_M,
|
|
"ef_construction": 40,
|
|
"ef_search": 16,
|
|
"metric": "INNER_PRODUCT",
|
|
},
|
|
"sidecar_sha256_hex": sha256,
|
|
"file_path": str(idx_path),
|
|
"id_mapping": [],
|
|
}
|
|
(idx_path.parent / (idx_path.name + ".meta.json")).write_text(
|
|
json.dumps(meta, sort_keys=True, indent=2), encoding="utf-8"
|
|
)
|
|
|
|
print(
|
|
f"[tile-init] OK: empty HNSW32 dim={DESCRIPTOR_DIM} index "
|
|
f"at {idx_path} sha256={sha256[:16]}..."
|
|
)
|