Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions tensorboard/plugins/interactive_inference/witwidget/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ py_library(
"notebook/**/*.py",
]),
srcs_version = "PY2AND3",
deps = [
"//tensorboard:expect_tensorflow_installed",
"//tensorboard/plugins/interactive_inference/utils:inference_utils",
"@com_google_protobuf//:protobuf_python",
"@org_pythonhosted_six",
]
)

py_library(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
import json
import googleapiclient.discovery
Copy link
Contributor

Choose a reason for hiding this comment

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

Should probably do this as a separate PR but how was this previously working? GAPI isn't part of our dependency declaration and I believe we didn't do anything special to install it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

acknowledged

import tensorflow as tf
import sys
from IPython import display
from google.protobuf import json_format
from numbers import Number
from six import ensure_str
Copy link
Contributor

Choose a reason for hiding this comment

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

You may want to add six dependency on the BUILD file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

from tensorboard.plugins.interactive_inference.utils import inference_utils

# Constants used in mutant inference generation.
Expand Down Expand Up @@ -228,10 +228,8 @@ def create_sprite(self):
example_strings = [
self.json_to_proto(ex).SerializeToString()
for ex in self.examples]
encoded = base64.b64encode(
inference_utils.create_sprite_image(example_strings))
if sys.version_info >= (3, 0):
encoded = encoded.decode('utf-8')
encoded = ensure_str(base64.b64encode(
inference_utils.create_sprite_image(example_strings)))
return 'data:image/png;base64,{}'.format(encoded)
else:
return None
Expand Down Expand Up @@ -264,7 +262,8 @@ def _json_from_tf_examples(self, tf_examples):
elif ex.features.feature[feat].HasField('float_list'):
json_ex[feat_idx] = ex.features.feature[feat].float_list.value[0]
else:
json_ex[feat_idx] = ex.features.feature[feat].bytes_list.value[0]
json_ex[feat_idx] = ensure_str(
ex.features.feature[feat].bytes_list.value[0])
else:
json_ex = {}
for feat in ex.features.feature:
Expand All @@ -275,7 +274,8 @@ def _json_from_tf_examples(self, tf_examples):
elif ex.features.feature[feat].HasField('float_list'):
json_ex[feat] = ex.features.feature[feat].float_list.value[0]
else:
json_ex[feat] = ex.features.feature[feat].bytes_list.value[0]
json_ex[feat] = ensure_str(
ex.features.feature[feat].bytes_list.value[0])
json_exs.append(json_ex)
return json_exs

Expand Down