Skip to content

Commit a3e9750

Browse files
Jianwei Xietensorflower-gardener
Jianwei Xie
authored andcommitted
Add more debug information to pandas_io_test
Change: 149496080
1 parent 828a41f commit a3e9750

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tensorflow/python/estimator/inputs/pandas_io_test.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,30 @@
2626
from tensorflow.python.training import coordinator
2727
from tensorflow.python.training import queue_runner_impl
2828

29+
30+
def print_debug_info(module_pd, has_pandas, msg):
31+
if module_pd is None:
32+
print('HAS_PANDAS {} and module pd is None. Msg {}'.format(has_pandas, msg))
33+
else:
34+
has_data_frame = hasattr(module_pd, 'DataFrame')
35+
print('HAS_PANDAS {} and hasattr(pd, "DataFrame") {}. Msg {}'.format(
36+
has_pandas, has_data_frame, msg))
37+
if not has_data_frame:
38+
print('symbols in pd {}'.format(dir(module_pd)))
39+
40+
2941
try:
3042
# pylint: disable=g-import-not-at-top
3143
import pandas as pd
3244
HAS_PANDAS = True
45+
print_debug_info(pd, HAS_PANDAS, 'import statement')
3346
except IOError:
3447
# Pandas writes a temporary file during import. If it fails, don't use pandas.
3548
HAS_PANDAS = False
49+
print_debug_info(None, HAS_PANDAS, 'import statement')
3650
except ImportError:
3751
HAS_PANDAS = False
52+
print_debug_info(None, HAS_PANDAS, 'import statement')
3853

3954

4055
class PandasIoTest(test.TestCase):
@@ -43,6 +58,7 @@ def makeTestDataFrame(self):
4358
index = np.arange(100, 104)
4459
a = np.arange(4)
4560
b = np.arange(32, 36)
61+
print_debug_info(pd, HAS_PANDAS, 'in test case')
4662
x = pd.DataFrame({'a': a, 'b': b}, index=index)
4763
y = pd.Series(np.arange(-32, -28), index=index)
4864
return x, y

0 commit comments

Comments
 (0)