Skip to content

Commit ea968f5

Browse files
hartbfacebook-github-bot
authored andcommittedFeb 4, 2020
fix possible pandas import error during tensorboard tests (pytorch#29650)
Summary: TensorBoard tests using SummaryWriter() may fail with a pandas import complaint if TensorFlow packages are installed in the same python environment as PyTorch: Traceback (most recent call last): File "test_tensorboard.py", line 212, in test_writer with self.createSummaryWriter() as writer: File "test_tensorboard.py", line 64, in createSummaryWriter return SummaryWriter(temp_dir) ... File "[...]/site-packages/pandas/core/arrays/categorical.py", line 52, in <module> import pandas.core.algorithms as algorithms AttributeError: module 'pandas' has no attribute 'core' The exact failure may depend on the pandas version. We've also seen: File "[...]/site-packages/pandas/core/arrays/categorical.py", line 9, in <module> import pandas.compat as compat AttributeError: module 'pandas' has no attribute 'compat' The module import chain leading to the failure is tensorboard imports tensorflow imports tensorflow_estimator imports pandas. pandas includes a submodule named 'bottleneck', whose name collides with the PyTorch 'test/bottleneck/' subdirectory. So IF tensorboard, tensorflow, tensorflow_estimator, and pandas are installed in the python environment AND IF testing is run from within PyTorch's 'test/' directory (or maybe just with 'test/' in PYTHONPATH, etc.), then TensorBoard tests using SummaryWriter() will fail. Rename the 'bottleneck/' directory slightly to avoid the name collision. Pull Request resolved: pytorch#29650 Differential Revision: D19698638 Pulled By: ezyang fbshipit-source-id: cb59342ed407cb37aefc833d67f768a8809129ac
1 parent 478356a commit ea968f5

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed
 
File renamed without changes.
File renamed without changes.
File renamed without changes.

‎test/test_utils.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,11 @@ def _run_bottleneck(self, test_file, scriptargs=''):
356356

357357
def _check_run_args(self):
358358
# Check that this fails due to missing args
359-
rc, out, err = self._run_bottleneck('bottleneck/test_args.py')
359+
rc, out, err = self._run_bottleneck('bottleneck_test/test_args.py')
360360
self.assertEqual(rc, 2, None, self._fail_msg('Missing args should error', out + err))
361361

362362
# This should succeed
363-
rc, out, err = self._run_bottleneck('bottleneck/test_args.py', '--foo foo --bar bar')
363+
rc, out, err = self._run_bottleneck('bottleneck_test/test_args.py', '--foo foo --bar bar')
364364
self.assertEqual(rc, 0, None, self._fail_msg('Should pass args to script', out + err))
365365

366366
def _fail_msg(self, msg, output):
@@ -404,7 +404,7 @@ def _check_cuda(self, output):
404404

405405
@unittest.skipIf(HAS_CUDA, 'CPU-only test')
406406
def test_bottleneck_cpu_only(self):
407-
rc, out, err = self._run_bottleneck('bottleneck/test.py')
407+
rc, out, err = self._run_bottleneck('bottleneck_test/test.py')
408408
self.assertEqual(rc, 0, 'Run failed with\n{}'.format(err))
409409

410410
self._check_run_args()
@@ -416,7 +416,7 @@ def test_bottleneck_cpu_only(self):
416416
@unittest.skipIf(not HAS_CUDA, 'No CUDA')
417417
@skipIfRocm
418418
def test_bottleneck_cuda(self):
419-
rc, out, err = self._run_bottleneck('bottleneck/test_cuda.py')
419+
rc, out, err = self._run_bottleneck('bottleneck_test/test_cuda.py')
420420
self.assertEqual(rc, 0, 'Run failed with\n{}'.format(err))
421421

422422
self._check_run_args()

0 commit comments

Comments
 (0)
Please sign in to comment.