diff --git a/tensorflow/contrib/cmake/tf_tests.cmake b/tensorflow/contrib/cmake/tf_tests.cmake index 2a51ab62d45..7da0a0cbe92 100644 --- a/tensorflow/contrib/cmake/tf_tests.cmake +++ b/tensorflow/contrib/cmake/tf_tests.cmake @@ -181,6 +181,7 @@ if (tensorflow_BUILD_PYTHON_TESTS) "${tensorflow_source_dir}/tensorflow/python/kernel_tests/cast_op_test.py" "${tensorflow_source_dir}/tensorflow/python/kernel_tests/string_to_number_op_test.py" "${tensorflow_source_dir}/tensorflow/python/kernel_tests/clip_ops_test.py" + "${tensorflow_source_dir}/tensorflow/python/kernel_tests/tensor_array_ops_test.py" # Needs portpicker. # misc "${tensorflow_source_dir}/tensorflow/python/kernel_tests/variable_scope_test.py" "${tensorflow_source_dir}/tensorflow/python/kernel_tests/reshape_op_test.py" diff --git a/tensorflow/python/framework/test_util.py b/tensorflow/python/framework/test_util.py index 194d608a884..485bb3b109b 100644 --- a/tensorflow/python/framework/test_util.py +++ b/tensorflow/python/framework/test_util.py @@ -27,9 +27,14 @@ import tempfile import threading import numpy as np -import portpicker import six +try: + import portpicker # pylint: disable=g-import-not-at-top +except ImportError as _portpicker_import_error: + portpicker = None + +# pylint: disable=g-import-not-at-top from google.protobuf import descriptor_pool from google.protobuf import text_format @@ -811,7 +816,12 @@ def create_local_cluster(num_workers, num_ps, protocol="grpc"): A tuple `(worker_servers, ps_servers)`. `worker_servers` is a list of `num_workers` objects of type `tf.train.Server` (all running locally); and `ps_servers` is a list of `num_ps` objects of similar type. + + Raises: + ImportError: if portpicker module was not found at load time """ + if not portpicker: + raise _portpicker_import_error worker_ports = [portpicker.pick_unused_port() for _ in range(num_workers)] ps_ports = [portpicker.pick_unused_port() for _ in range(num_ps)] cluster_dict = { diff --git a/tensorflow/python/kernel_tests/BUILD b/tensorflow/python/kernel_tests/BUILD index ab69b33cb12..56ebc796f91 100644 --- a/tensorflow/python/kernel_tests/BUILD +++ b/tensorflow/python/kernel_tests/BUILD @@ -1905,6 +1905,7 @@ cuda_py_test( "//tensorflow/python:tensor_array_ops", "//tensorflow/python:variables", ], + flaky = 1, # create_local_cluster sometimes times out. ) cuda_py_test(