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

summary: avoid using 'tensorflow' package in import logic #3515

Merged
merged 1 commit into from
Apr 14, 2020
Merged
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
8 changes: 2 additions & 6 deletions tensorboard/summary/_tf/summary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ def reexport_tf_summary():

# API packages to check for the original V2 summary API, in preference order
# to avoid going "under the hood" to the _api packages unless necessary.
# Skip the top-level `tensorflow` package since it's hard to confirm that it
# is the actual v2 API (just checking tf.__version__ is not always enough).
packages = [
"tensorflow",
"tensorflow.compat.v2",
"tensorflow_core._api.v2",
"tensorflow_core._api.v2.compat.v2",
Expand All @@ -135,11 +136,6 @@ def reexport_tf_summary():
"tensorflow._api.v2.compat.v2",
"tensorflow._api.v1.compat.v2",
]
# If we aren't sure we're on V2, don't use tf.summary since it could be V1.
# Note there may be false positives since the __version__ attribute may not be
# defined at this point in the import process.
if not getattr(tf, "__version__", "").startswith("2."): # noqa: F821
packages.remove("tensorflow")

def dynamic_wildcard_import(module):
"""Implements the logic of "from module import *" for the given
Expand Down