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

Do not load WIT TB plugin in TB versions earlier than 2.2 #64

Merged
merged 2 commits into from
Apr 6, 2020

Conversation

jameswex
Copy link
Collaborator

@jameswex jameswex commented Apr 2, 2020

See tensorflow/tensorboard#3460 for root cause.

This PR ensures that the tensorboard-plugin-wit package will only load the plugin in TensorBoards 2.2 or later, when WIT was removed as a built-in plugin.

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.

LGTM: a couple comments inline, but all optional.

Comment on lines 45 to 47
version_list = tensorboard.__version__.split(".")
if (int(version_list[0]) < 2 or
(int(version_list[0]) == 2 and int(version_list[1]) < 2)):
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional, but consider using pkg_resources.parse_version here:

import pkg_resources

_MIN_TENSORBOARD_VERSION = pkg_resources.parse_version("2.2.0")

version = pkg_resources.parse_version(tensorboard.__version__)
if version < _MIN_TENSORBOARD_VERSION:
    return None

This way, you don’t have to do the parsing yourself, and you don’t have
to worry about edge cases (like, 2.9a0 is a valid version number, even
if we’re not super likely to use it).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah great didn't know about that build-in lib. tried out packaging but that required a new dep and i didn't want to add one.

used this code and retested.


# If TB version is before 2.2.0, then do not load the WIT plugin
# as it is already included directly in TensorBoard.
version_list = tensorboard.__version__.split(".")
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: tensorboard.__version__ was added in TensorBoard 1.14.0. If
you want to be back-compatible with older versions, you can use:

import tensorboard.version

tb_version = tensorboard.version.VERSION

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

don't think we'll need backwards compat with 1.14, as colab falls back to 1.15 with the tensorflow 1.x magic and anyone installing 1.14 from scratch won't get this pip package

@wchargin
Copy link
Contributor

wchargin commented Apr 2, 2020

I’ve tested this in Colab with:

%tensorflow_version 1.x

!wget -q 'https://raw.githubusercontent.com/PAIR-code/what-if-tool/a0b339e66603c3e5eeac60b7f064849cfe446923/tensorboard_plugin_wit/wit_plugin_loader.py' -O patch.py

import tensorboard_plugin_wit.wit_plugin_loader
import shutil
shutil.copyfile("patch.py", tensorboard_plugin_wit.wit_plugin_loader.__file__)

%load_ext tensorboard
%tensorboard --logdir logs

and verified that the result launches with a working What-If Tool both
with and without the %tensorflow_version 1.x directive.

@jameswex
Copy link
Collaborator Author

jameswex commented Apr 2, 2020

thanks @wchargin , made your pkg_resources change and retested to verify.

Copy link
Collaborator

@tolga-b tolga-b left a comment

Choose a reason for hiding this comment

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

Looks good to me as well.
Do we need to add pkg_resources as a dependency to pip? A quick search suggests it's part of python setuptools.

@jameswex
Copy link
Collaborator Author

jameswex commented Apr 3, 2020

Good quesion. Since this is a TB package that runs as part of TB, and TB has a dep on setuptools, is that situation appropriate for this package? Or should we explicitly also have a requirement on setuptools? @wchargin your opinion?

@jameswex jameswex merged commit 01fcc6a into master Apr 6, 2020
@jameswex jameswex deleted the wit_tb_1x_fix branch April 6, 2020 13:12
@wchargin
Copy link
Contributor

wchargin commented Apr 6, 2020

Good quesion. Since this is a TB package that runs as part of TB, and TB has a dep on setuptools, is that situation appropriate for this package? Or should we explicitly also have a requirement on setuptools? @wchargin your opinion?

Hi, sorry, just saw this. It might be a little nicer to have an explicit
requirement on setuptools, but I don’t think it’s a big deal either
way, because setuptools is one of the few packages installed by
default in every virtualenv. I actually don’t know how to create a
Python environment that does not have it installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants