Skip to content

Commit

Permalink
fix: add edge case for non-existent persistent dir
Browse files Browse the repository at this point in the history
  • Loading branch information
SawyerCzupka committed Feb 23, 2025
1 parent 726a0bb commit a8dd745
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ml-api/src/ml_api/ingestion/pipeline.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import logging

from llama_index.core.ingestion import IngestionPipeline
from llama_index.core.node_parser import SentenceSplitter
from llama_index.core.schema import TransformComponent
from ml_api.config import settings
from ml_api.utils.embeddings import get_embed_model
from ml_api.utils.qdrant import get_qdrant_vector_store

logger = logging.getLogger(__name__)


def get_pipeline(
persist=settings.PIPELINE_PERSIST,
Expand Down Expand Up @@ -35,6 +39,11 @@ def get_pipeline(
pipeline = IngestionPipeline(transformations=transformations, vector_store=qdrant)

if persist and persist_path:
pipeline.load(persist_dir=persist_path)
try:
pipeline.load(persist_dir=persist_path)
except Exception:
logger.warning(
f"Failed to load pipeline from {persist_path}, likely because it does not exist yet."
)

return pipeline

0 comments on commit a8dd745

Please sign in to comment.