Skip to content

Commit

Permalink
fix: fitz import switcher (#5012)
Browse files Browse the repository at this point in the history
* fix pymupdf import switcher

* install pdf

* check after the import

* revert workflow change

* pylint

* pylint

* pylint again
  • Loading branch information
ZanSara authored May 24, 2023
1 parent 929b8d1 commit 44fd0cf
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions haystack/nodes/file_converter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from haystack import is_imported
from haystack.nodes.file_converter.base import BaseConverter

from haystack.utils.import_utils import safe_import
Expand All @@ -10,16 +11,16 @@
from haystack.nodes.file_converter.azure import AzureConverter
from haystack.nodes.file_converter.parsr import ParsrConverter

# Try to use PyMuPDF, if not available fall back to xpdf
from haystack.nodes.file_converter.pdf import PDFToTextConverter

if not is_imported("fitz"):
from haystack.nodes.file_converter.pdf_xpdf import PDFToTextConverter # type: ignore # pylint: disable=reimported


MarkdownConverter = safe_import(
"haystack.nodes.file_converter.markdown", "MarkdownConverter", "preprocessing"
) # Has optional dependencies
ImageToTextConverter = safe_import(
"haystack.nodes.file_converter.image", "ImageToTextConverter", "ocr"
) # Has optional dependencies

# Try to use PyMuPDF, if not available fall back to xpdf
try:
from haystack.nodes.file_converter.pdf import PDFToTextConverter
except ImportError:
from haystack.nodes.file_converter.pdf_xpdf import PDFToTextConverter # type: ignore

0 comments on commit 44fd0cf

Please sign in to comment.