Does pandas import check in each caller file directly to avoid flaky tests.

Change: 149118694
This commit is contained in:
Jianwei Xie 2017-03-03 09:10:25 -08:00 committed by TensorFlower Gardener
parent 2299ffe31d
commit 936e593722
9 changed files with 48 additions and 59 deletions

View File

@ -19,12 +19,17 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from tensorflow.python.estimator.inputs.pandas_import import HAS_PANDAS
from tensorflow.python.estimator.inputs.pandas_io import pandas_input_fn # pylint: disable=unused-import
if HAS_PANDAS:
try:
# pylint: disable=g-import-not-at-top
import pandas as pd
HAS_PANDAS = True
except IOError:
# Pandas writes a temporary file during import. If it fails, don't use pandas.
HAS_PANDAS = False
except ImportError:
HAS_PANDAS = False
PANDAS_DTYPES = {
'int8': 'int',

View File

@ -163,7 +163,6 @@ py_library(
srcs_version = "PY2AND3",
deps = [
":numpy_io",
":pandas_import",
":pandas_io",
],
)
@ -190,20 +189,11 @@ py_test(
],
)
py_library(
name = "pandas_import",
srcs = ["inputs/pandas_import.py"],
srcs_version = "PY2AND3",
)
py_library(
name = "pandas_io",
srcs = ["inputs/pandas_io.py"],
srcs_version = "PY2AND3",
deps = [
":inputs_queues",
":pandas_import",
],
deps = [":inputs_queues"],
)
py_test(
@ -228,10 +218,7 @@ py_library(
"inputs/queues/feeding_queue_runner.py",
],
srcs_version = "PY2AND3",
deps = [
":pandas_import",
"//tensorflow/python:training",
],
deps = ["//tensorflow/python:training"],
)
py_test(

View File

@ -19,5 +19,4 @@ from __future__ import division
from __future__ import print_function
from tensorflow.python.estimator.inputs.numpy_io import numpy_input_fn
from tensorflow.python.estimator.inputs.pandas_import import HAS_PANDAS
from tensorflow.python.estimator.inputs.pandas_io import pandas_input_fn

View File

@ -1,32 +0,0 @@
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Handles pandas import for tensorflow."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as _ # pylint: disable=unused-import
try:
# pylint: disable=g-import-not-at-top
# pylint: disable=unused-import
import pandas as _
HAS_PANDAS = True
except IOError:
# Pandas writes a temporary file during import. If it fails, don't use pandas.
HAS_PANDAS = False
except ImportError:
HAS_PANDAS = False

View File

@ -20,9 +20,19 @@ from __future__ import division
from __future__ import print_function
import numpy as np
from tensorflow.python.estimator.inputs.pandas_import import HAS_PANDAS
from tensorflow.python.estimator.inputs.queues import feeding_functions
try:
# pylint: disable=g-import-not-at-top
# pylint: disable=unused-import
import pandas as pd
HAS_PANDAS = True
except IOError:
# Pandas writes a temporary file during import. If it fails, don't use pandas.
HAS_PANDAS = False
except ImportError:
HAS_PANDAS = False
def pandas_input_fn(x,
y=None,

View File

@ -21,15 +21,20 @@ from __future__ import print_function
import numpy as np
from tensorflow.python.estimator.inputs import pandas_io
from tensorflow.python.estimator.inputs.pandas_import import HAS_PANDAS
from tensorflow.python.framework import errors
from tensorflow.python.platform import test
from tensorflow.python.training import coordinator
from tensorflow.python.training import queue_runner_impl
if HAS_PANDAS:
try:
# pylint: disable=g-import-not-at-top
import pandas as pd
HAS_PANDAS = True
except IOError:
# Pandas writes a temporary file during import. If it fails, don't use pandas.
HAS_PANDAS = False
except ImportError:
HAS_PANDAS = False
class PandasIoTest(test.TestCase):

View File

@ -22,7 +22,6 @@ import collections
import random
import numpy as np
from tensorflow.python.estimator.inputs.pandas_import import HAS_PANDAS
from tensorflow.python.estimator.inputs.queues import feeding_queue_runner as fqr
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import errors
@ -34,9 +33,15 @@ from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.summary import summary
from tensorflow.python.training import queue_runner
if HAS_PANDAS:
try:
# pylint: disable=g-import-not-at-top
import pandas as pd
HAS_PANDAS = True
except IOError:
# Pandas writes a temporary file during import. If it fails, don't use pandas.
HAS_PANDAS = False
except ImportError:
HAS_PANDAS = False
def _get_integer_indices_for_next_batch(

View File

@ -22,13 +22,18 @@ import collections
import numpy as np
from tensorflow.python.estimator.inputs.pandas_import import HAS_PANDAS
from tensorflow.python.estimator.inputs.queues import feeding_functions as ff
from tensorflow.python.platform import test
if HAS_PANDAS:
try:
# pylint: disable=g-import-not-at-top
import pandas as pd
HAS_PANDAS = True
except IOError:
# Pandas writes a temporary file during import. If it fails, don't use pandas.
HAS_PANDAS = False
except ImportError:
HAS_PANDAS = False
def vals_to_list(a):

View File

@ -21,16 +21,21 @@ from __future__ import print_function
import numpy as np
from tensorflow.python.client import session
from tensorflow.python.estimator.inputs.pandas_import import HAS_PANDAS
from tensorflow.python.estimator.inputs.queues import feeding_functions as ff
from tensorflow.python.framework import ops
from tensorflow.python.platform import test
from tensorflow.python.training import coordinator
from tensorflow.python.training import queue_runner_impl
if HAS_PANDAS:
try:
# pylint: disable=g-import-not-at-top
import pandas as pd
HAS_PANDAS = True
except IOError:
# Pandas writes a temporary file during import. If it fails, don't use pandas.
HAS_PANDAS = False
except ImportError:
HAS_PANDAS = False
def get_rows(array, row_indices):