From b3546cc509cfed48c2f41205c7ed354b10d17152 Mon Sep 17 00:00:00 2001 From: Tolga Date: Thu, 23 May 2019 13:36:06 -0400 Subject: [PATCH] Fix long type not found for json input in python3 (#2269) --- .../plugins/interactive_inference/utils/inference_utils.py | 4 ++-- .../interactive_inference/witwidget/notebook/visualization.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tensorboard/plugins/interactive_inference/utils/inference_utils.py b/tensorboard/plugins/interactive_inference/utils/inference_utils.py index a7992ea4f7..8401b66a95 100644 --- a/tensorboard/plugins/interactive_inference/utils/inference_utils.py +++ b/tensorboard/plugins/interactive_inference/utils/inference_utils.py @@ -22,7 +22,7 @@ import tensorflow as tf from google.protobuf import json_format from six import iteritems -from six import string_types +from six import string_types, integer_types from six.moves import zip # pylint: disable=redefined-builtin from tensorboard.plugins.interactive_inference.utils import common_utils @@ -155,7 +155,7 @@ def __init__(self, original_feature, index, mutant_value): 'unexpected type: {}'.format(type(original_feature))) self.original_feature = original_feature - if index is not None and not isinstance(index, int): + if index is not None and not isinstance(index, integer_types): raise ValueError( 'index should be None or int, but had unexpected type: {}'.format( type(index))) diff --git a/tensorboard/plugins/interactive_inference/witwidget/notebook/visualization.py b/tensorboard/plugins/interactive_inference/witwidget/notebook/visualization.py index 14944e2c2c..ede559d0b0 100644 --- a/tensorboard/plugins/interactive_inference/witwidget/notebook/visualization.py +++ b/tensorboard/plugins/interactive_inference/witwidget/notebook/visualization.py @@ -16,6 +16,7 @@ import sys import tensorflow as tf from numbers import Number +from six import integer_types def _is_colab(): @@ -488,7 +489,7 @@ def _convert_json_to_tf_examples(self, examples): return tf_examples def _add_single_feature(self, feat, value, ex): - if isinstance(value, (int, long)): + if isinstance(value, integer_types): ex.features.feature[feat].int64_list.value.append(value) elif isinstance(value, Number): ex.features.feature[feat].float_list.value.append(value)