From 3d8bdf3cb69c5592518e9ca7c5274c3a551ea4a3 Mon Sep 17 00:00:00 2001 From: Sara Zan Date: Mon, 9 May 2022 18:07:42 +0200 Subject: [PATCH] Remove safe import from `ElasticsearchDocumentStore` (#2522) * Update version to 1.4.1rc0 * Elasticsearch is not an optional dependency * Fix import path * Update Documentation & Code Style Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- docs/_src/api/api/file_converter.md | 2 +- docs/_src/api/api/pipelines.md | 21 ++++++++++----------- haystack/document_stores/__init__.py | 20 +++++++------------- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/docs/_src/api/api/file_converter.md b/docs/_src/api/api/file_converter.md index f21c2ba20..c39a711a4 100644 --- a/docs/_src/api/api/file_converter.md +++ b/docs/_src/api/api/file_converter.md @@ -83,7 +83,7 @@ Validate if the language of the text is one of valid languages. -#### run +#### BaseConverter.run ```python def run(file_paths: Union[Path, List[Path]], meta: Optional[Union[Dict[str, str], List[Optional[Dict[str, str]]]]] = None, remove_numeric_tables: Optional[bool] = None, known_ligatures: Dict[str, str] = KNOWN_LIGATURES, valid_languages: Optional[List[str]] = None, encoding: Optional[str] = "UTF-8") diff --git a/docs/_src/api/api/pipelines.md b/docs/_src/api/api/pipelines.md index db057bced..aa049f70d 100644 --- a/docs/_src/api/api/pipelines.md +++ b/docs/_src/api/api/pipelines.md @@ -18,8 +18,7 @@ Reader from multiple Retrievers, or re-ranking of candidate documents. - -#### root\_node +#### Pipeline.root\_node ```python @property @@ -30,7 +29,7 @@ Returns the root node of the pipeline's graph. -#### BasePipeline.to\_code +#### Pipeline.to\_code ```python def to_code(pipeline_variable_name: str = "pipeline", generate_imports: bool = True, add_comment: bool = False) -> str @@ -49,7 +48,7 @@ Default value is False. -#### BasePipeline.to\_notebook\_cell +#### Pipeline.to\_notebook\_cell ```python def to_notebook_cell(pipeline_variable_name: str = "pipeline", generate_imports: bool = True, add_comment: bool = True) @@ -68,7 +67,7 @@ Default value is True. -#### BasePipeline.load\_from\_deepset\_cloud +#### Pipeline.load\_from\_deepset\_cloud ```python @classmethod @@ -101,7 +100,7 @@ variable 'READER_PARAMS_RETURN_NO_ANSWER=False' can be set. Note that an -#### BasePipeline.list\_pipelines\_on\_deepset\_cloud +#### Pipeline.list\_pipelines\_on\_deepset\_cloud ```python @classmethod @@ -137,7 +136,7 @@ Returns: -#### BasePipeline.save\_to\_deepset\_cloud +#### Pipeline.save\_to\_deepset\_cloud ```python @classmethod @@ -162,7 +161,7 @@ If not specified, will be read from DEEPSET_CLOUD_API_ENDPOINT environment varia -#### BasePipeline.deploy\_on\_deepset\_cloud +#### Pipeline.deploy\_on\_deepset\_cloud ```python @classmethod @@ -191,7 +190,7 @@ If the timeout is exceeded an error will be raised. -#### BasePipeline.undeploy\_on\_deepset\_cloud +#### Pipeline.undeploy\_on\_deepset\_cloud ```python @classmethod @@ -676,7 +675,7 @@ class _HaystackBeirRetrieverAdapter() -#### \_\_init\_\_ +#### \_HaystackBeirRetrieverAdapter.\_\_init\_\_ ```python def __init__(index_pipeline: Pipeline, query_pipeline: Pipeline, index_params: dict, query_params: dict) @@ -852,7 +851,7 @@ Ray calls this method which is then re-directed to the corresponding component's -#### load\_from\_pipeline\_config +#### \_RayDeploymentWrapper.load\_from\_pipeline\_config ```python @staticmethod diff --git a/haystack/document_stores/__init__.py b/haystack/document_stores/__init__.py index 3f7e3903f..41fe98f91 100644 --- a/haystack/document_stores/__init__.py +++ b/haystack/document_stores/__init__.py @@ -7,20 +7,14 @@ from haystack.document_stores.memory import InMemoryDocumentStore from haystack.document_stores.deepsetcloud import DeepsetCloudDocumentStore from haystack.document_stores.utils import eval_data_from_json, eval_data_from_jsonl, squad_json_to_jsonl -ElasticsearchDocumentStore = safe_import( - "haystack.document_stores.elasticsearch", "ElasticsearchDocumentStore", "elasticsearch" +from haystack.document_stores.elasticsearch import ( + ElasticsearchDocumentStore, + OpenSearchDocumentStore, + OpenDistroElasticsearchDocumentStore, ) -OpenDistroElasticsearchDocumentStore = safe_import( - "haystack.document_stores.elasticsearch", "OpenDistroElasticsearchDocumentStore", "elasticsearch" -) -OpenSearchDocumentStore = safe_import( - "haystack.document_stores.elasticsearch", "OpenSearchDocumentStore", "elasticsearch" -) -elasticsearch_index_to_document_store = safe_import( - "haystack.document_stores.elasticsearch", "elasticsearch_index_to_document_store", "elasticsearch" -) -open_search_index_to_document_store = safe_import( - "haystack.document_stores.elasticsearch", "open_search_index_to_document_store", "elasticsearch" +from haystack.document_stores.es_converter import ( + elasticsearch_index_to_document_store, + open_search_index_to_document_store, ) SQLDocumentStore = safe_import("haystack.document_stores.sql", "SQLDocumentStore", "sql")