KEMBAR78
compat: avoid tf.__version__ in tf2 API lazy loader by nfelt · Pull Request #3525 · tensorflow/tensorboard · GitHub
Skip to content

Conversation

@nfelt
Copy link
Contributor

@nfelt nfelt commented Apr 16, 2020

Similar to #3515, this is problematic because tf.__version__.startswith("2.") does not necessary imply that the TF 2.x API is available at the tensorflow root API package; in particular this will not be true if TensorFlow was built with --define=tf_api_version=1.

Rather than attempting to detect that situation correctly, as in #3515, we sidestep the problem by just always relying on tf.compat.v2 regardless of what the root API package is providing. This should be safe because we only care about versions of TensorFlow that should consistently provide the tf.compat.v2 sub-API, and unlike in #3515 where this is resolved as part of the TensorFlow API import process itself, here the tf2 lazy loader is only invoked at runtime (i.e. after import time) at which point the API should be intact.

Test plan: unit tests should suffice for OSS; confirmed internally that this fixes the repro case using --define=tf_api_version=1.

Copy link
Contributor

@wchargin wchargin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On— once and, uh, *checks notes* for all.

@nfelt nfelt merged commit e7bfcbd into tensorflow:master Apr 16, 2020
@nfelt nfelt deleted the summary-import-yetagain branch April 16, 2020 22:53
caisq pushed a commit to caisq/tensorboard that referenced this pull request May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants