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

Improve dependency management #1994

merged 88 commits into from
Jan 26, 2022

Conversation

ZanSara
Copy link
Contributor

@ZanSara ZanSara commented Jan 12, 2022

Improve dependecy management by introducing extras_require and migrating to setup.cfg and pyproject.toml.

Related to #1979

@ZanSara
Copy link
Contributor Author

ZanSara commented Jan 12, 2022

@tholor I have plenty of testing to do still, but this branch is already working on Python3.9 on Linux, so feel free to try it out and let me know if you encounter errors.

The dependency groups are also just stubs, there are a lot of dependencies that I'm not quite sure about, so if you already see something out of place let me know and I'll move them 🙂

@ZanSara ZanSara added breaking change journey:first steps topic:installation type:feature New feature or request type:refactor Not necessarily visible to the users labels Jan 12, 2022
@ZanSara ZanSara mentioned this pull request Jan 12, 2022
5 tasks
@ZanSara ZanSara linked an issue Jan 12, 2022 that may be closed by this pull request
5 tasks
@ZanSara ZanSara self-assigned this Jan 12, 2022
@ZanSara ZanSara mentioned this pull request Jan 13, 2022
@ZanSara
Copy link
Contributor Author

ZanSara commented Jan 14, 2022

Example of workflow for document stores:

$ pip install .

... pip logs ...

$ python
>>> import haystack
>>> from haystack.document_stores import FAISSDocumentStore
>>> e = FAISSDocumentStore()
Traceback (most recent call last):
  File "/home/sara/work/haystack/haystack/utils/import_utils.py", line 28, in safe_import
    module = importlib.import_module(import_path)
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/sara/work/haystack/haystack/document_stores/faiss.py", line 13, in <module>
    import faiss
ModuleNotFoundError: No module named 'faiss'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sara/work/haystack/haystack/utils/import_utils.py", line 42, in __init__
    raise ImportError(f"Failed to import {classname}. "
ImportError: Failed to import FAISSDocumentStore. Run 'pip install farm-haystack[faiss] to install them.'
>>>
$ pip install .[faiss]

... pip logs ...

$ python
>>> import haystack
>>> from haystack.document_stores import FAISSDocumentStore
>>> e = FAISSDocumentStore()
>>>

For other optional modules like rest or ui, the process is more eager instead:

$ pip install .

... pip logs ...

$ python
>>> import rest_api.application
Traceback (most recent call last):
  File "/home/sara/work/haystack/rest_api/application.py", line 10, in <module>
    import uvicorn
ModuleNotFoundError: No module named 'uvicorn'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sara/work/haystack/rest_api/application.py", line 20, in <module>
    raise ImportError("Failed to import the REST API due to missing dependencies. Run 'pip install farm-haystack[rest]' to install them.") from ie
ImportError: Failed to import the REST API due to missing dependencies. Run 'pip install farm-haystack[rest]' to install them.
>>>
$ pip install .[rest]

... pip logs ...

$ python
>>> import rest_api.application
>>>

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@ZanSara ZanSara merged commit d470b9d into master Jan 26, 2022
@ZanSara ZanSara deleted the try_out_pyproject_toml branch January 26, 2022 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change topic:installation type:feature New feature or request type:refactor Not necessarily visible to the users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve dependency management Improve Colab setup experience by simplifying dependencies
4 participants