Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve dependency management #1994

Merged
merged 88 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
ce78bee
Fist attempt at using setup.cfg for dependency management
ZanSara Jan 12, 2022
6c90f79
Trying the new package on the CI and in Docker too
ZanSara Jan 12, 2022
1d0a8f6
Remove tool: prefix from a few entries
ZanSara Jan 12, 2022
c84a9a2
Reintroduce ui module installation in linux_ci.yml
ZanSara Jan 13, 2022
2941818
Add composite extras_require
ZanSara Jan 13, 2022
e3920b2
Simplify version management and update CI
ZanSara Jan 13, 2022
5d219c5
Add the safe_import function for document store imports and add some …
ZanSara Jan 13, 2022
0e8a8a2
Try to fix mypy
ZanSara Jan 13, 2022
986cd59
Add latest docstring and tutorial changes
github-actions[bot] Jan 13, 2022
f878153
Fix bug on class import and rephrase error message
ZanSara Jan 14, 2022
efe02a6
Merge branch 'try_out_pyproject_toml' of github.com:deepset-ai/haysta…
ZanSara Jan 14, 2022
097b8ac
Try using string types in retriever
ZanSara Jan 14, 2022
5cb77b2
Add latest docstring and tutorial changes
github-actions[bot] Jan 14, 2022
665a8b7
Introduce typing for optional modules and add type: ignore in sparse.py
ZanSara Jan 14, 2022
ac679d2
Merge branch 'try_out_pyproject_toml' of github.com:deepset-ai/haysta…
ZanSara Jan 14, 2022
3f85f32
Installing ui/ should be no longer necessary
ZanSara Jan 14, 2022
8c14e56
Include importlib_metadata backport for py3.7
ZanSara Jan 14, 2022
51df2e7
Type ignore
ZanSara Jan 14, 2022
d1623a5
Wrong error name
ZanSara Jan 14, 2022
57eab9e
Seems like caching in the CI
ZanSara Jan 14, 2022
cd0524b
Add colab group to extra_requires
ZanSara Jan 14, 2022
d23118f
Fix pillow version
ZanSara Jan 14, 2022
f2d3ed6
Unpin pillow
ZanSara Jan 14, 2022
42e6767
Fix grpcio
ZanSara Jan 14, 2022
3359111
Fix grpcio again
ZanSara Jan 14, 2022
32f9c0c
Fix package name
ZanSara Jan 14, 2022
4a6bc86
Add check on pip version and fix some more unchecked imports in the t…
ZanSara Jan 17, 2022
e7313b7
Separate out the crawler as another extra
ZanSara Jan 17, 2022
320d3a4
Make paths relative in rest_api and ui
ZanSara Jan 17, 2022
14feb76
Remove relative imports, but move rest and ui tests under the respect…
ZanSara Jan 17, 2022
e1d4768
Update the test matrix in the CI
ZanSara Jan 17, 2022
093de48
Add try catch statements around the optional imports too to account f…
ZanSara Jan 17, 2022
0dd1615
Fix crawler imports
ZanSara Jan 17, 2022
7c1a8dc
Merge branch 'master' into try_out_pyproject_toml
ZanSara Jan 17, 2022
4f36741
try again to make the CI find the tests
ZanSara Jan 17, 2022
7e5731a
Remove duplicate test_rest_api.py file
ZanSara Jan 17, 2022
9896d19
Never mix direct deps with self-references and add ES deps to the bas…
ZanSara Jan 18, 2022
0e5790a
Merge branch 'master' into try_out_pyproject_toml
ZanSara Jan 18, 2022
f7a6221
Remove pip version check, too strict
ZanSara Jan 18, 2022
6749af0
General review of optional deps
ZanSara Jan 18, 2022
6e6598a
Add python-multipart back
ZanSara Jan 19, 2022
2fea33d
Merge branch 'master' into try_out_pyproject_toml
ZanSara Jan 19, 2022
162e0a0
Fix Dockerfile-GPU and add psutil to the dev dependencies
ZanSara Jan 19, 2022
a83730e
Typo
ZanSara Jan 19, 2022
12cd502
Give up on opt-out dependency groups in pip
ZanSara Jan 19, 2022
66e785d
Give up on opt-out dependency groups in pip
ZanSara Jan 19, 2022
3ff2723
Refactor several paths in tests to make them insensitive to the execu…
ZanSara Jan 19, 2022
ef64e45
Path was stated incorrectly
ZanSara Jan 19, 2022
f8adaf0
Fix a path in test_distillation and modify slightly the Dockerfiles
ZanSara Jan 20, 2022
67e988f
Add black and flake8, for now not enforced anywhere
ZanSara Jan 20, 2022
be0cffc
Add configuration for flake8 and black
ZanSara Jan 20, 2022
3b26bfe
Solve merge conflict on version due to release
ZanSara Jan 20, 2022
02cd53c
Typo
ZanSara Jan 20, 2022
41b5d3e
Call pytest more explicitly
ZanSara Jan 20, 2022
0473962
Change extra group on the CI install
ZanSara Jan 20, 2022
87970ea
temporarily disable cache
ZanSara Jan 20, 2022
ea20a7c
Update cache keys
ZanSara Jan 20, 2022
b3229c1
Add all-gpu group
ZanSara Jan 20, 2022
03635cb
Change __name__ with __file__
ZanSara Jan 20, 2022
b418234
Fix smaller bugs introduced during path refactoring
ZanSara Jan 20, 2022
7b96a0a
Fix Dockerfile and Dockerfile-GPU
ZanSara Jan 25, 2022
5b81890
Pin Milvus 1 and make Milvus2 the default
ZanSara Jan 25, 2022
4ddf7e9
Clarify error message at failed import in conftest.py
ZanSara Jan 25, 2022
0e41024
Include tstadel review and re-introduce Milvus1 in the tests suite, t…
ZanSara Jan 25, 2022
26f3f72
Remove some unused imports from transformers.py
ZanSara Jan 25, 2022
e947886
Update some import paths in tests
ZanSara Jan 25, 2022
5fbe93d
Replace Path(__file__).parent/'samples' with a constant from conftest.pu
ZanSara Jan 25, 2022
817712b
Switch flake8 with pylint and configure it
ZanSara Jan 25, 2022
83206bc
Wrap pdf conversion utils into safe_import and remove unused quantulu…
ZanSara Jan 25, 2022
a5f603a
Update imports in tutorials, to test
ZanSara Jan 25, 2022
e5055d4
Add latest docstring and tutorial changes
github-actions[bot] Jan 25, 2022
7e9ec23
Update some tutorials and rever Milvus1 as default for now, see #2067
ZanSara Jan 26, 2022
e42946d
Merge branch 'try_out_pyproject_toml' of github.com:deepset-ai/haysta…
ZanSara Jan 26, 2022
057d94e
Add latest docstring and tutorial changes
github-actions[bot] Jan 26, 2022
ddc848a
Some more small changes to the tutorials
ZanSara Jan 26, 2022
40ced5a
Merge branch 'try_out_pyproject_toml' of github.com:deepset-ai/haysta…
ZanSara Jan 26, 2022
d3cc05c
Add latest docstring and tutorial changes
github-actions[bot] Jan 26, 2022
f9f802e
Merge conflict with master
ZanSara Jan 26, 2022
7621e5e
Merge branch 'try_out_pyproject_toml' of github.com:deepset-ai/haysta…
ZanSara Jan 26, 2022
3415273
Add latest docstring and tutorial changes
github-actions[bot] Jan 26, 2022
ed393a1
Forgot one merge conflict
ZanSara Jan 26, 2022
43a5b11
Merge branch 'try_out_pyproject_toml' of github.com:deepset-ai/haysta…
ZanSara Jan 26, 2022
7d8c471
Fix mypy config
ZanSara Jan 26, 2022
1dffda6
Reintroduce quantulum3
ZanSara Jan 26, 2022
9298905
Fix some more paths and add back InMemoryDocumentStore (disappeared i…
ZanSara Jan 26, 2022
cbb4581
Fix some more paths
ZanSara Jan 26, 2022
2b63b14
Fixing more paths in the preprocessor
ZanSara Jan 26, 2022
f3272b4
Merge branch 'master' into try_out_pyproject_toml
ZanSara Jan 26, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/cml.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ jobs:
run: |
apt-get update -y
apt-get install python3-dev -y
pip install -r requirements.txt
pip install .
pip install .[elasticsearch,faiss,milvus,weaviate,graphdb,ray,rest,ui,dev]
cd test/benchmarks && python run.py --retriever_index --retriever_query --reader --ci --save_markdown
echo -en "## Benchmarks: Retriever Indexing\n" >> report.md
cat retriever_index_results.md >> report.md
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/linux_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: linux-${{ env.pythonLocation }}-${{ env.date }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}
key: linux-${{ env.pythonLocation }}-${{ env.date }}-${{ hashFiles('setup.py') }}-${{ hashFiles('setup.cfg') }}-${{ hashFiles('pyproject.toml') }}
- name: Install dependencies
if: steps.cache-python-env.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
pip install --upgrade --upgrade-strategy eager -r requirements-dev.txt -e .
pip install --upgrade --upgrade-strategy eager -r requirements.txt -e .
pip install --upgrade --upgrade-strategy eager -r ui/requirements.txt -e .
pip install --upgrade --upgrade-strategy eager .[test]
pip install torch-scatter -f https://data.pyg.org/whl/torch-1.10.0+cpu.html

prepare-build:
Expand All @@ -51,7 +49,7 @@ jobs:
- uses: actions/checkout@v2
- id: set-matrix
run: |
echo "::set-output name=matrix::$(cd test && ls -d test_*.py | jq -R . | jq -cs .)"
echo "::set-output name=matrix::$(find $(find . -type d -name test -not -path "./*env*/*") -type f -name test_*.py | jq -SR . | jq -cs .)"
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
build:
Expand All @@ -72,7 +70,7 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: linux-${{ env.pythonLocation }}-${{ env.date }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}
key: linux-${{ env.pythonLocation }}-${{ env.date }}-${{ hashFiles('setup.py') }}-${{ hashFiles('setup.cfg') }}-${{ hashFiles('pyproject.toml') }}
- name: Run Elasticsearch
run: docker run -d -p 9200:9200 -e "discovery.type=single-node" -e "ES_JAVA_OPTS=-Xms128m -Xmx128m" elasticsearch:7.9.2

Expand Down Expand Up @@ -101,4 +99,4 @@ jobs:
run: sudo apt-get install tesseract-ocr libtesseract-dev poppler-utils

- name: Run tests
run: cd test && pytest -s ${{ matrix.test-path }}
run: pytest -s ${{ matrix.test-path }}
12 changes: 5 additions & 7 deletions .github/workflows/windows_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,15 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: windows-${{ env.pythonLocation }}-${{ env.date }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}
key: windows-${{ env.pythonLocation }}-${{ env.date }}-${{ hashFiles('setup.py') }}-${{ hashFiles('setup.cfg') }}-${{ hashFiles('pyproject.toml') }}
- name: Install Pytorch on windows
run: |
pip install torch==1.8.1+cpu -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html
- name: Install dependencies
if: steps.cache-python-env.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
pip install --upgrade --upgrade-strategy eager -r requirements-dev.txt -e .
pip install --upgrade --upgrade-strategy eager -r ui/requirements.txt -e .
pip install --upgrade --upgrade-strategy eager -f https://download.pytorch.org/whl/torch_stable.html -r requirements.txt -e .
pip install --upgrade --upgrade-strategy eager .[test]
pip install torch-scatter -f https://data.pyg.org/whl/torch-1.10.0+cpu.html

prepare-build:
Expand All @@ -56,7 +54,7 @@ jobs:
- uses: actions/checkout@v2
- id: set-matrix
run: |
echo "::set-output name=matrix::$(cd test && ls -d test_*.py | jq -R . | jq -cs .)"
echo "::set-output name=matrix::$(find $(find . -type d -name test -not -path "./*env*/*") -type f -name test_*.py | jq -SR . | jq -cs .)"
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

Expand All @@ -78,7 +76,7 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: windows-${{ env.pythonLocation }}-${{ env.date }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}
key: windows-${{ env.pythonLocation }}-${{ env.date }}-${{ hashFiles('setup.py') }}-${{ hashFiles('setup.cfg') }}-${{ hashFiles('pyproject.toml') }}

# Windows runner can't run Linux containers. Refer https://github.com/actions/virtual-environments/issues/1143
- name: Set up Windows test env
Expand All @@ -96,4 +94,4 @@ jobs:
# Removing test_ray, test_utils, test_preprocessor, test_knowledge_graph and test_connector
- name: Run tests
if: ${{ !contains(fromJSON('["test_ray.py", "test_knowledge_graph.py", "test_connector.py", "test_summarizer_translation.py"]'), matrix.test-path) }}
run: cd test && pytest --document_store_type=memory,faiss,elasticsearch -m "not tika and not graphdb" -k "not test_parsr_converter" -s ${{ matrix.test-path }}
run: pytest --document_store_type=memory,faiss,elasticsearch -m "not tika and not graphdb" -k "not test_parsr_converter" -s ${{ matrix.test-path }}
22 changes: 11 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ RUN apt-get update && apt-get install -y \
RUN wget --no-check-certificate https://dl.xpdfreader.com/xpdf-tools-linux-4.03.tar.gz && \
tar -xvf xpdf-tools-linux-4.03.tar.gz && cp xpdf-tools-linux-4.03/bin64/pdftotext /usr/local/bin

# copy code
COPY haystack /home/user/haystack

# install as a package
COPY setup.py requirements.txt README.md /home/user/
COPY setup.py setup.cfg pyproject.toml VERSION.txt LICENSE README.md \
# Haystack code
haystack \
# Saved models
models* \
# REST API cpde
rest_api \
/home/user/
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install -e .
RUN pip install --no-cache-dir -e .[docstores,crawler,preprocessing,ocr,ray,rest]
RUN ls /home/user
RUN pip freeze
RUN python3 -c "from haystack.utils.docker import cache_models;cache_models()"

# create folder for /file-upload API endpoint with write permissions, this might be adjusted depending on FILE_UPLOAD_PATH
RUN mkdir -p /home/user/file-upload
RUN chmod 777 /home/user/file-upload

# copy saved models
COPY README.md models* /home/user/models/

# Copy REST API code
COPY rest_api /home/user/rest_api

# optional : copy sqlite db if needed for testing
#COPY qa.db /home/user/
Expand Down
26 changes: 11 additions & 15 deletions Dockerfile-GPU
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,23 @@ RUN curl -s https://dl.xpdfreader.com/xpdf-tools-linux-4.03.tar.gz | tar -xvzf -
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1 && \
update-alternatives --set python3 /usr/bin/python3.7

# Copy package setup files
COPY setup.py requirements.txt README.md /home/user/
# Copy package files
COPY setup.py setup.cfg pyproject.toml VERSION.txt LICENSE README.md \
# Haystack code
haystack \
# Saved models
models* \
# REST API cpde
rest_api \
/home/user/

RUN pip install --upgrade pip
RUN echo "Install required packages" && \
# Install PyTorch for CUDA 11
pip3 install --no-cache-dir torch==1.10.1+cu111 -f https://download.pytorch.org/whl/torch_stable.html && \
# Install from requirements.txt
pip3 install --no-cache-dir -r requirements.txt

# copy saved models
COPY README.md models* /home/user/models/

# Copy REST API code
COPY rest_api /home/user/rest_api

# copy code
COPY haystack /home/user/haystack
pip3 install --no-cache-dir torch==1.10.1+cu111 -f https://download.pytorch.org/whl/torch_stable.html

# Install package
RUN pip3 install -e .
RUN pip install --no-cache .[docstores_gpu,crawler,preprocessing,ocr,ray,rest]

# Cache Roberta and NLTK data
RUN python3 -c "from haystack.utils.docker import cache_models;cache_models()"
Expand Down
3 changes: 0 additions & 3 deletions MANIFEST.in

This file was deleted.

1 change: 1 addition & 0 deletions VERSION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.1.0
4 changes: 2 additions & 2 deletions docs/_src/api/api/retriever.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ class ElasticsearchRetriever(BaseRetriever)
#### \_\_init\_\_

```python
| __init__(document_store: ElasticsearchDocumentStore, top_k: int = 10, custom_query: str = None)
| __init__(document_store: "ElasticsearchDocumentStore", top_k: int = 10, custom_query: str = None)
```

**Arguments**:

- `document_store`: an instance of a DocumentStore to retrieve documents from.
- `document_store`: an instance of an ElasticsearchDocumentStore to retrieve documents from.
- `custom_query`: query string as per Elasticsearch DSL with a mandatory query placeholder(query).

Optionally, ES `filter` clause can be added where the values of `terms` are placeholders
Expand Down
55 changes: 44 additions & 11 deletions haystack/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
import logging
from typing import Union
from types import ModuleType

try:
import importlib.metadata as metadata
except ModuleNotFoundError:
# Python <= 3.7
import importlib_metadata as metadata # type: ignore

__version__ = metadata.version('farm-haystack')

# This configuration must be done before any import to apply to all submodules
import logging
logging.basicConfig(format="%(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", level=logging.WARNING)
logging.getLogger("haystack").setLevel(logging.INFO)

from haystack import pipelines
from haystack.schema import Document, Answer, Label, MultiLabel, Span
from haystack.nodes import BaseComponent
from haystack.pipelines import Pipeline
from haystack._version import __version__

import pandas as pd
pd.options.display.max_colwidth = 80



# ###########################################
# Enable old style imports (temporary)
import sys
Expand Down Expand Up @@ -57,9 +67,29 @@ def __getattr__(self, attr):
summarizer,
translator
)
from haystack import document_stores
from haystack.nodes.retriever import text2sparql as graph_retriever
from haystack.document_stores import graphdb as knowledge_graph

# Note that we ignore the ImportError here because if the user did not install
# the correct dependency group for a document store, we don't need to setup
# import warnings for that, so the import here is useless and should fail silently.

document_stores: Union[ModuleType, None] = None
try:
from haystack import document_stores
except ImportError:
pass

graph_retriever: Union[ModuleType, None] = None
try:
from haystack.nodes.retriever import text2sparql as graph_retriever
except ImportError:
pass

knowledge_graph: Union[ModuleType, None] = None
try:
from haystack.document_stores import graphdb as knowledge_graph
except ImportError:
pass

from haystack.modeling.evaluation import eval
from haystack.modeling.logger import MLFlowLogger, StdoutLogger, TensorBoardLogger
from haystack.nodes.other import JoinDocuments, Docs2Answers
Expand All @@ -73,8 +103,9 @@ def __getattr__(self, attr):
# modules need to be set as attributes of their parent model.
# To make chain imports work (`from haystack.reader import FARMReader`) the module
# needs to be also present in sys.modules with its complete import path.
setattr(knowledge_graph, "graphdb", DeprecatedModule(knowledge_graph))
sys.modules["haystack.knowledge_graph.graphdb"] = DeprecatedModule(knowledge_graph)
if knowledge_graph:
setattr(knowledge_graph, "graphdb", DeprecatedModule(knowledge_graph))
sys.modules["haystack.knowledge_graph.graphdb"] = DeprecatedModule(knowledge_graph)

setattr(preprocessor, "utils", DeprecatedModule(preprocessing))
setattr(preprocessor, "cleaning", DeprecatedModule(cleaning))
Expand All @@ -88,7 +119,6 @@ def __getattr__(self, attr):
setattr(haystack, "extractor", DeprecatedModule(extractor))
setattr(haystack, "eval", DeprecatedModule(eval))
setattr(haystack, "file_converter", DeprecatedModule(file_converter, deprecated_attributes=["FileTypeClassifier"]))
setattr(haystack, "graph_retriever", DeprecatedModule(graph_retriever))
setattr(haystack, "knowledge_graph", DeprecatedModule(knowledge_graph, deprecated_attributes=["graphdb"]))
setattr(haystack, "pipeline", DeprecatedModule(pipelines, deprecated_attributes=["JoinDocuments", "Docs2Answers", "SklearnQueryClassifier", "TransformersQueryClassifier"]))
setattr(haystack, "preprocessor", DeprecatedModule(preprocessor, deprecated_attributes=["utils", "cleaning"]))
Expand All @@ -105,7 +135,6 @@ def __getattr__(self, attr):
sys.modules["haystack.extractor"] = DeprecatedModule(extractor)
sys.modules["haystack.eval"] = DeprecatedModule(eval)
sys.modules["haystack.file_converter"] = DeprecatedModule(file_converter)
sys.modules["haystack.graph_retriever"] = DeprecatedModule(graph_retriever)
sys.modules["haystack.knowledge_graph"] = DeprecatedModule(knowledge_graph)
sys.modules["haystack.pipeline"] = DeprecatedModule(pipelines)
sys.modules["haystack.preprocessor"] = DeprecatedModule(preprocessor, deprecated_attributes=["utils", "cleaning"])
Expand All @@ -115,6 +144,9 @@ def __getattr__(self, attr):
sys.modules["haystack.retriever"] = DeprecatedModule(retriever)
sys.modules["haystack.summarizer"] = DeprecatedModule(summarizer)
sys.modules["haystack.translator"] = DeprecatedModule(translator)
if graph_retriever:
setattr(haystack, "graph_retriever", DeprecatedModule(graph_retriever))
sys.modules["haystack.graph_retriever"] = DeprecatedModule(graph_retriever)

# To be imported from modules, classes need only to be set as attributes,
# they don't need to be present in sys.modules too.
Expand All @@ -138,7 +170,6 @@ def __getattr__(self, attr):
"extractor",
"eval",
"file_converter",
"graph_retriever",
"knowledge_graph",
"pipeline",
"preprocessor",
Expand All @@ -149,4 +180,6 @@ def __getattr__(self, attr):
"summarizer",
"translator"
]
sys.modules["haystack"] = DeprecatedModule(haystack, is_module_deprecated=False, deprecated_attributes=deprecated_attributes)
if graph_retriever:
deprecated_attributes.append("graph_retriever")
sys.modules["haystack"] = DeprecatedModule(haystack, is_module_deprecated=False, deprecated_attributes=deprecated_attributes)
1 change: 0 additions & 1 deletion haystack/_version.py

This file was deleted.

24 changes: 14 additions & 10 deletions haystack/document_stores/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import os
import importlib
from haystack.utils.import_utils import safe_import
from haystack.document_stores.base import BaseDocumentStore, BaseKnowledgeGraph
from haystack.document_stores.elasticsearch import ElasticsearchDocumentStore, OpenDistroElasticsearchDocumentStore, OpenSearchDocumentStore
from haystack.document_stores.faiss import FAISSDocumentStore
from haystack.document_stores.memory import InMemoryDocumentStore

import os
ElasticsearchDocumentStore = safe_import("haystack.document_stores.elasticsearch", "ElasticsearchDocumentStore", "elasticsearch")
OpenDistroElasticsearchDocumentStore = safe_import("haystack.document_stores.elasticsearch", "OpenDistroElasticsearchDocumentStore", "elasticsearch")
OpenSearchDocumentStore = safe_import("haystack.document_stores.elasticsearch", "OpenSearchDocumentStore", "elasticsearch")

SQLDocumentStore = safe_import("haystack.document_stores.sql", "SQLDocumentStore", "sql")
FAISSDocumentStore = safe_import("haystack.document_stores.faiss", "FAISSDocumentStore", "faiss")
if os.getenv("MILVUS2_ENABLED"):
print("Using experimental Milvus2DocumentStore")
from haystack.document_stores.milvus2x import Milvus2DocumentStore as MilvusDocumentStore
MilvusDocumentStore = safe_import("haystack.document_stores.milvus2x", "MilvusDocumentStore", "milvus2")
else:
from haystack.document_stores.milvus import MilvusDocumentStore # type: ignore
MilvusDocumentStore = safe_import("haystack.document_stores.milvus", "MilvusDocumentStore", "milvus")
WeaviateDocumentStore = safe_import("haystack.document_stores.weaviate", "WeaviateDocumentStore", "weaviate")
GraphDBKnowledgeGraph = safe_import("haystack.document_stores.graphdb", "GraphDBKnowledgeGraph", "graphdb")

from haystack.document_stores.sql import SQLDocumentStore
from haystack.document_stores.weaviate import WeaviateDocumentStore
from haystack.document_stores.graphdb import GraphDBKnowledgeGraph
from haystack.document_stores.memory import InMemoryDocumentStore
from haystack.document_stores.utils import eval_data_from_json, eval_data_from_jsonl, squad_json_to_jsonl
12 changes: 9 additions & 3 deletions haystack/document_stores/elasticsearch.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from modulefinder import Module
from typing import List, Optional, Union, Dict, Any, Generator

import json
Expand All @@ -8,11 +9,16 @@
import numpy as np
from scipy.special import expit
from tqdm.auto import tqdm
from elasticsearch import Elasticsearch, RequestsHttpConnection
from elasticsearch.helpers import bulk, scan
from elasticsearch.exceptions import RequestError
import pandas as pd

try:
from elasticsearch import Elasticsearch, RequestsHttpConnection
from elasticsearch.helpers import bulk, scan
from elasticsearch.exceptions import RequestError
except (ImportError, ModuleNotFoundError) as ie:
from haystack.utils.import_utils import _optional_component_not_installed
_optional_component_not_installed(__name__, "elasticsearch", ie)

from haystack.document_stores import BaseDocumentStore
from haystack.schema import Document, Label
from haystack.document_stores.base import get_batches_from_generator
Expand Down
12 changes: 7 additions & 5 deletions haystack/document_stores/faiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@
from typing import Union, List, Optional, Dict, Generator
from tqdm.auto import tqdm
import warnings
import numpy as np
from inspect import Signature, signature

try:
import faiss
except ImportError:
faiss = None
import numpy as np
from haystack.document_stores.sql import SQLDocumentStore # its deps are optional, but get installed with the `faiss` extra
except (ImportError, ModuleNotFoundError) as ie:
from haystack.utils.import_utils import _optional_component_not_installed
_optional_component_not_installed(__name__, "faiss", ie)


from haystack.schema import Document
from haystack.document_stores.sql import SQLDocumentStore
from haystack.document_stores.base import get_batches_from_generator
from inspect import Signature, signature


logger = logging.getLogger(__name__)
Expand Down
Loading