Skip to content

Commit

Permalink
Use epy.lazy_imports in datasets instead of try/except.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 625597756
  • Loading branch information
marcenacp authored and The TensorFlow Datasets Authors committed May 10, 2024
1 parent 7b66e9b commit fd6c111
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tensorflow_datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

_TIMESTAMP_IMPORT_STARTS = time.time()
from absl import logging
from etils import epy as _epy
import tensorflow_datasets.core.logging as _tfds_logging
from tensorflow_datasets.core.logging import call_metadata as _call_metadata

Expand All @@ -55,7 +56,7 @@
# pytype: disable=import-error
# For builds that don't include all dataset builders, we don't want to fail on
# import errors of dataset builders.
try:
with _epy.lazy_api_imports(globals()):
from tensorflow_datasets import audio
from tensorflow_datasets import graphs
from tensorflow_datasets import image
Expand All @@ -79,8 +80,6 @@
from tensorflow_datasets import video
from tensorflow_datasets import vision_language

except ImportError:
pass
# pytype: enable=import-error

_import_time_ms_dataset_builders = int(
Expand All @@ -103,3 +102,5 @@
import_time_ms_tensorflow=0,
import_time_ms_dataset_builders=_import_time_ms_dataset_builders,
)

del _epy

0 comments on commit fd6c111

Please sign in to comment.