[TF cmake] Bugfix: lazy import of portpicker in test_util.

Also remove a test that relies on it from the cmake tests: tensor_array_ops_test.py

PiperOrigin-RevId: 156311187
This commit is contained in:
Eugene Brevdo 2017-05-17 08:37:12 -07:00 committed by TensorFlower Gardener
parent eb937e62c5
commit 9a47c258c9
3 changed files with 13 additions and 1 deletions

View File

@ -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"

View File

@ -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 = {

View File

@ -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(