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

Use epy.lazy_imports in datasets instead of try/except. #5365

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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
Loading