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

Handling tfds import part to prevent cli error when installing datumaro with default option only #1454

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
(<https://github.com/openvinotoolkit/datumaro/pull/1450>)

### Bug fixes
- Fix CLI error occurring when installed with default option only
(<https://github.com/openvinotoolkit/datumaro/issues/1444>, <https://github.com/openvinotoolkit/datumaro/pull/1454>)
- Relax Pillow dependency constraint
(<https://github.com/openvinotoolkit/datumaro/pull/1436>)
- Modify Numpy dependency constraint
Expand Down
16 changes: 8 additions & 8 deletions src/datumaro/components/extractor_tfds.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2021-2023 Intel Corporation
# Copyright (C) 2024 Intel Corporation
#
# SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -30,23 +30,23 @@
from datumaro.components.annotation import AnnotationType, Bbox, Label, LabelCategories
from datumaro.components.dataset_base import CategoriesInfo, DatasetInfo, DatasetItem, IDataset
from datumaro.components.media import Image, MediaElement
from datumaro.util.import_util import lazy_import
from datumaro.util.tf_util import import_tf

TFDS_EXTRACTOR_AVAILABLE = True if find_spec("tensorflow_datasets") is not None else False

if TYPE_CHECKING:
if TFDS_EXTRACTOR_AVAILABLE:
try:
tf = import_tf()
import tensorflow_datasets as tfds
if TYPE_CHECKING:
tf = import_tf()
import tensorflow_datasets as tfds
else:
tfds = lazy_import("tensorflow_datasets")
except ImportError:
log.debug(
"Unable to import TensorFlow or TensorFlow Datasets. "
"Dataset downloading via TFDS is disabled."
)
else:
from datumaro.util.import_util import lazy_import

tfds = lazy_import("tensorflow_datasets")


@frozen(kw_only=True)
Expand Down
Loading