SA-663 Load embedding from flat file#66
Open
ivyONS wants to merge 10 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✨ Summary
Refactors
EmbeddingHandlerto load and build vector stores from arbitrary flat CSV files instead of only from the SIC hierarchy XLS sources. SIC-specific loading is extracted into a standalone utility (sic_specific_embed.py). Return types forsearch_indexandsearch_index_multiare replaced with typed Pydantic response models, that is imported into***-vector-store-api. GCS support is extended to single-file downloads (to handle CSV indes source files).📜 Changes Introduced
EmbeddingHandler.__init__acceptsindex_source_file(CSV path or GCS URI); when provided, builds a new vector store; otherwise loads an existing one — replaces the previous _load_or_build_vector_store logic_load_existing_vector_storenow raisesFileNotFoundErrorinstead of returning None, making the error explicit_build_vector_store— loads data from flat file (native classifai format, no metadata)sic_specific_embed.load_embedding_handler_from_sic_index_filespreserves the old SIC-hierarchy-based build path as an explicit utility functiongcs_file_access.download_one_file_from_gcs— downloads a single GCS file to a temp directory for use during vector store buildSearchIndexItem&SearchIndexResponsePydantic models replacelist[dict]return types onsearch_indexandsearch_index_multiEmbeddingHandler.get_embed_configreturns a typedEmbeddingConfigsnapshotEmbeddingConfigmigrated from TypedDict to Pydantic BaseModel; addsindex_source_fileandindex_sizefieldsCustomVertexAIEmbeddingsremovedtest_embedding.pyfully updated - adds unit teststest_gcs_file_access.pyadds tests fordownload_one_file_from_gcs(success + missing file)✅ Checklist
terraform fmt&terraform validate)🔍 How to Test
make all-testsdemos/embed/sic_embedding_example.py)sic-classification-vector-store