Add deployment artifact integrity check
Browse files- Dockerfile +2 -0
- src/medirag/vector_index.py +7 -2
Dockerfile
CHANGED
|
@@ -36,6 +36,8 @@ ENV HF_HUB_OFFLINE=1 \
|
|
| 36 |
|
| 37 |
COPY --chown=user:user src/ src/
|
| 38 |
COPY --chown=user:user knowledge_base/ knowledge_base/
|
|
|
|
|
|
|
| 39 |
|
| 40 |
EXPOSE 7860
|
| 41 |
|
|
|
|
| 36 |
|
| 37 |
COPY --chown=user:user src/ src/
|
| 38 |
COPY --chown=user:user knowledge_base/ knowledge_base/
|
| 39 |
+
RUN echo "451a017d1d53ef21f502a2effd9edf8932d39a55e584e6888b9e99529ea41c09 knowledge_base/indexes/medlineplus/multilingual-e5-small/embeddings.npy" \
|
| 40 |
+
| sha256sum --check
|
| 41 |
|
| 42 |
EXPOSE 7860
|
| 43 |
|
src/medirag/vector_index.py
CHANGED
|
@@ -327,9 +327,14 @@ class LoadedVectorIndex:
|
|
| 327 |
raise IndexValidationError(
|
| 328 |
"Chunk corpus hash does not match the index manifest"
|
| 329 |
)
|
| 330 |
-
|
|
|
|
|
|
|
| 331 |
raise IndexValidationError(
|
| 332 |
-
"Embedding matrix hash does not match the index manifest"
|
|
|
|
|
|
|
|
|
|
| 333 |
)
|
| 334 |
|
| 335 |
fingerprint_payload = _index_fingerprint_payload(
|
|
|
|
| 327 |
raise IndexValidationError(
|
| 328 |
"Chunk corpus hash does not match the index manifest"
|
| 329 |
)
|
| 330 |
+
observed_embeddings_sha256 = sha256_file(self.embeddings_path)
|
| 331 |
+
expected_embeddings_sha256 = str(vectors_info["npy_sha256"])
|
| 332 |
+
if observed_embeddings_sha256 != expected_embeddings_sha256:
|
| 333 |
raise IndexValidationError(
|
| 334 |
+
"Embedding matrix hash does not match the index manifest "
|
| 335 |
+
f"(expected={expected_embeddings_sha256}, "
|
| 336 |
+
f"observed={observed_embeddings_sha256}, "
|
| 337 |
+
f"bytes={self.embeddings_path.stat().st_size})"
|
| 338 |
)
|
| 339 |
|
| 340 |
fingerprint_payload = _index_fingerprint_payload(
|