Skip to content

Commit

Permalink
chore: remove outdated error message (#935)
Browse files Browse the repository at this point in the history
There's an issue in unstructured-inference about these blocks trapping unrelated import errors. The fix for that would be to narrow the scope of the traps, but I think this is made redundant by the requires_dependencies decorator, so I removed it completely.
  • Loading branch information
qued authored Jul 22, 2023
1 parent 050cfaf commit d032912
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 23 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 0.8.2-dev3
## 0.8.2-dev4

### Enhancements

Expand All @@ -18,6 +18,7 @@
* Adds `.txt`, `.text`, and `.tab` to list of extensions to check if file
has a `text/plain` MIME type.
* Enables filters to be passed to `partition_doc` so it doesn't error with LibreOffice7.
* Removed old error message that's superseded by `requires_dependencies`.

## 0.8.1

Expand Down
2 changes: 1 addition & 1 deletion unstructured/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.8.2-dev3" # pragma: no cover
__version__ = "0.8.2-dev4" # pragma: no cover
23 changes: 4 additions & 19 deletions unstructured/partition/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,25 +189,10 @@ def _partition_pdf_or_image_local(
**kwargs,
) -> List[Element]:
"""Partition using package installed locally."""
try:
from unstructured_inference.inference.layout import (
process_data_with_model,
process_file_with_model,
)
except ModuleNotFoundError as e:
raise Exception(
"unstructured_inference module not found... try running pip install "
"unstructured[local-inference] if you installed the unstructured library as a package. "
"If you cloned the unstructured repository, try running make install-local-inference "
"from the root directory of the repository.",
) from e
except ImportError as e:
raise Exception(
"There was a problem importing unstructured_inference module - it may not be installed "
"correctly... try running pip install unstructured[local-inference] if you installed "
"the unstructured library as a package. If you cloned the unstructured repository, try "
"running make install-local-inference from the root directory of the repository.",
) from e
from unstructured_inference.inference.layout import (
process_data_with_model,
process_file_with_model,
)

model_name = model_name if model_name else os.environ.get("UNSTRUCTURED_HI_RES_MODEL_NAME")
if file is None:
Expand Down
6 changes: 4 additions & 2 deletions unstructured/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ def wrapper(*args, **kwargs):
def dependency_exists(dependency):
try:
importlib.import_module(dependency)
except ImportError:
return False
except ImportError as e:
# Check to make sure this isn't some unrelated import error.
if dependency in repr(e):
return False
return True


Expand Down

0 comments on commit d032912

Please sign in to comment.