docling-project / docling-project/docling-eval
Add import guards for optional dependencies
- Dominant language
- Python
- Stars
- 77
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
Description
Optional dependencies like `boto3` are imported without guards (e.g. in `/Users/nli/nikos/code/public_github/DS4SD/docling-eval/docling-eval/docling_eval/dataset_builders/dataset_builder.py`). Therefore when a python `venv` without the optional packages is created, calling the `docling-eval` CLI causes a `ModuleNotFoundError`.
This is how to reproduce it:
Create `venv` and install `docling-eval` packages from pypi
```
python -m venv venv
. venv/bin/activate
pip install docling-eval
```
Try to run `docling-eval` CLI:
```
docling-eval --help
Traceback (most recent call last):
File "/Users/nli/tmp/del/venv/bin/docling-eval", line 5, in
from docling_eval.cli.main import app
File "/Users/nli/tmp/del/venv/lib/python3.13/site-packages/docling_eval/cli/main.py", line 48, in
from docling_eval.dataset_builders.cvat_dataset_builder import CvatDatasetBuilder
File "/Users/nli/tmp/del/venv/lib/python3.13/site-packages/docling_eval/dataset_builders/cvat_dataset_builder.py", line 43, in
from docling_eval.dataset_builders.dataset_builder import BaseEvaluationDatasetBuilder
File "/Users/nli/tmp/del/venv/lib/python3.13/site-packages/docling_eval/dataset_builders/dataset_builder.py", line 9, in
import ibm_boto3 # type: ignore
^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'ibm_boto3'
```
Contributor guide
Assessment
This issue has not been assessed yet.