From e3c4e39db56150dc4d698b197eee17ab3f1e858b Mon Sep 17 00:00:00 2001 From: trducng Date: Wed, 13 Nov 2024 06:34:59 +0000 Subject: [PATCH] fix: update empty loader check --- libs/ktem/ktem/index/file/pipelines.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libs/ktem/ktem/index/file/pipelines.py b/libs/ktem/ktem/index/file/pipelines.py index 69b8a124..0d2e0051 100644 --- a/libs/ktem/ktem/index/file/pipelines.py +++ b/libs/ktem/ktem/index/file/pipelines.py @@ -545,6 +545,13 @@ class IndexPipeline(BaseComponent): def stream( self, file_path: str | Path, reindex: bool, **kwargs ) -> Generator[Document, None, tuple[str, list[Document]]]: + if self.loader is None: + raise NotImplementedError( + f"No supported pipeline to index {Path(file_path).name}. " + "Please specify " + "the suitable pipeline for this file type in the settings." + ) + # check for duplication file_path = Path(file_path).resolve() file_id = self.get_id_if_exists(file_path) @@ -617,11 +624,6 @@ class IndexDocumentPipeline(BaseFileIndexIndexing): ext = file_path.suffix reader = readers.get(ext, KH_DEFAULT_FILE_EXTRACTORS.get(ext, None)) - if reader is None: - raise NotImplementedError( - f"No supported pipeline to index {file_path.name}. Please specify " - "the suitable pipeline for this file type in the settings." - ) pipeline: IndexPipeline = IndexPipeline( loader=reader,