File tree Expand file tree Collapse file tree
contrib/learn/python/learn/learn_io Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919from __future__ import division
2020from __future__ import print_function
2121
22- from tensorflow .python .estimator .inputs .pandas_import import HAS_PANDAS
2322from tensorflow .python .estimator .inputs .pandas_io import pandas_input_fn # pylint: disable=unused-import
2423
25- if HAS_PANDAS :
24+ try :
2625 # pylint: disable=g-import-not-at-top
2726 import pandas as pd
27+ HAS_PANDAS = True
28+ except IOError :
29+ # Pandas writes a temporary file during import. If it fails, don't use pandas.
30+ HAS_PANDAS = False
31+ except ImportError :
32+ HAS_PANDAS = False
2833
2934PANDAS_DTYPES = {
3035 'int8' : 'int' ,
Original file line number Diff line number Diff line change @@ -163,7 +163,6 @@ py_library(
163163 srcs_version = "PY2AND3" ,
164164 deps = [
165165 ":numpy_io" ,
166- ":pandas_import" ,
167166 ":pandas_io" ,
168167 ],
169168)
@@ -190,20 +189,11 @@ py_test(
190189 ],
191190)
192191
193- py_library (
194- name = "pandas_import" ,
195- srcs = ["inputs/pandas_import.py" ],
196- srcs_version = "PY2AND3" ,
197- )
198-
199192py_library (
200193 name = "pandas_io" ,
201194 srcs = ["inputs/pandas_io.py" ],
202195 srcs_version = "PY2AND3" ,
203- deps = [
204- ":inputs_queues" ,
205- ":pandas_import" ,
206- ],
196+ deps = [":inputs_queues" ],
207197)
208198
209199py_test (
@@ -228,10 +218,7 @@ py_library(
228218 "inputs/queues/feeding_queue_runner.py" ,
229219 ],
230220 srcs_version = "PY2AND3" ,
231- deps = [
232- ":pandas_import" ,
233- "//tensorflow/python:training" ,
234- ],
221+ deps = ["//tensorflow/python:training" ],
235222)
236223
237224py_test (
Original file line number Diff line number Diff line change 1919from __future__ import print_function
2020
2121from tensorflow .python .estimator .inputs .numpy_io import numpy_input_fn
22- from tensorflow .python .estimator .inputs .pandas_import import HAS_PANDAS
2322from tensorflow .python .estimator .inputs .pandas_io import pandas_input_fn
Load diff This file was deleted.
Original file line number Diff line number Diff line change 2020from __future__ import print_function
2121
2222import numpy as np
23- from tensorflow .python .estimator .inputs .pandas_import import HAS_PANDAS
2423from tensorflow .python .estimator .inputs .queues import feeding_functions
2524
25+ try :
26+ # pylint: disable=g-import-not-at-top
27+ # pylint: disable=unused-import
28+ import pandas as pd
29+ HAS_PANDAS = True
30+ except IOError :
31+ # Pandas writes a temporary file during import. If it fails, don't use pandas.
32+ HAS_PANDAS = False
33+ except ImportError :
34+ HAS_PANDAS = False
35+
2636
2737def pandas_input_fn (x ,
2838 y = None ,
Original file line number Diff line number Diff line change 2121import numpy as np
2222
2323from tensorflow .python .estimator .inputs import pandas_io
24- from tensorflow .python .estimator .inputs .pandas_import import HAS_PANDAS
2524from tensorflow .python .framework import errors
2625from tensorflow .python .platform import test
2726from tensorflow .python .training import coordinator
2827from tensorflow .python .training import queue_runner_impl
2928
30- if HAS_PANDAS :
29+ try :
3130 # pylint: disable=g-import-not-at-top
3231 import pandas as pd
32+ HAS_PANDAS = True
33+ except IOError :
34+ # Pandas writes a temporary file during import. If it fails, don't use pandas.
35+ HAS_PANDAS = False
36+ except ImportError :
37+ HAS_PANDAS = False
3338
3439
3540class PandasIoTest (test .TestCase ):
Original file line number Diff line number Diff line change 2222import random
2323import numpy as np
2424
25- from tensorflow .python .estimator .inputs .pandas_import import HAS_PANDAS
2625from tensorflow .python .estimator .inputs .queues import feeding_queue_runner as fqr
2726from tensorflow .python .framework import dtypes
2827from tensorflow .python .framework import errors
3433from tensorflow .python .summary import summary
3534from tensorflow .python .training import queue_runner
3635
37- if HAS_PANDAS :
36+ try :
3837 # pylint: disable=g-import-not-at-top
3938 import pandas as pd
39+ HAS_PANDAS = True
40+ except IOError :
41+ # Pandas writes a temporary file during import. If it fails, don't use pandas.
42+ HAS_PANDAS = False
43+ except ImportError :
44+ HAS_PANDAS = False
4045
4146
4247def _get_integer_indices_for_next_batch (
Original file line number Diff line number Diff line change 2222
2323import numpy as np
2424
25- from tensorflow .python .estimator .inputs .pandas_import import HAS_PANDAS
2625from tensorflow .python .estimator .inputs .queues import feeding_functions as ff
2726from tensorflow .python .platform import test
2827
29- if HAS_PANDAS :
28+ try :
3029 # pylint: disable=g-import-not-at-top
3130 import pandas as pd
31+ HAS_PANDAS = True
32+ except IOError :
33+ # Pandas writes a temporary file during import. If it fails, don't use pandas.
34+ HAS_PANDAS = False
35+ except ImportError :
36+ HAS_PANDAS = False
3237
3338
3439def vals_to_list (a ):
Original file line number Diff line number Diff line change 2121import numpy as np
2222
2323from tensorflow .python .client import session
24- from tensorflow .python .estimator .inputs .pandas_import import HAS_PANDAS
2524from tensorflow .python .estimator .inputs .queues import feeding_functions as ff
2625from tensorflow .python .framework import ops
2726from tensorflow .python .platform import test
2827from tensorflow .python .training import coordinator
2928from tensorflow .python .training import queue_runner_impl
3029
31- if HAS_PANDAS :
30+ try :
3231 # pylint: disable=g-import-not-at-top
3332 import pandas as pd
33+ HAS_PANDAS = True
34+ except IOError :
35+ # Pandas writes a temporary file during import. If it fails, don't use pandas.
36+ HAS_PANDAS = False
37+ except ImportError :
38+ HAS_PANDAS = False
3439
3540
3641def get_rows (array , row_indices ):
You can’t perform that action at this time.
0 commit comments