[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:
parent
eb937e62c5
commit
9a47c258c9
@ -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/cast_op_test.py"
|
||||||
"${tensorflow_source_dir}/tensorflow/python/kernel_tests/string_to_number_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/clip_ops_test.py"
|
||||||
|
"${tensorflow_source_dir}/tensorflow/python/kernel_tests/tensor_array_ops_test.py" # Needs portpicker.
|
||||||
# misc
|
# misc
|
||||||
"${tensorflow_source_dir}/tensorflow/python/kernel_tests/variable_scope_test.py"
|
"${tensorflow_source_dir}/tensorflow/python/kernel_tests/variable_scope_test.py"
|
||||||
"${tensorflow_source_dir}/tensorflow/python/kernel_tests/reshape_op_test.py"
|
"${tensorflow_source_dir}/tensorflow/python/kernel_tests/reshape_op_test.py"
|
||||||
|
@ -27,9 +27,14 @@ import tempfile
|
|||||||
import threading
|
import threading
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import portpicker
|
|
||||||
import six
|
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 descriptor_pool
|
||||||
from google.protobuf import text_format
|
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
|
A tuple `(worker_servers, ps_servers)`. `worker_servers` is a list
|
||||||
of `num_workers` objects of type `tf.train.Server` (all running locally);
|
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.
|
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)]
|
worker_ports = [portpicker.pick_unused_port() for _ in range(num_workers)]
|
||||||
ps_ports = [portpicker.pick_unused_port() for _ in range(num_ps)]
|
ps_ports = [portpicker.pick_unused_port() for _ in range(num_ps)]
|
||||||
cluster_dict = {
|
cluster_dict = {
|
||||||
|
@ -1905,6 +1905,7 @@ cuda_py_test(
|
|||||||
"//tensorflow/python:tensor_array_ops",
|
"//tensorflow/python:tensor_array_ops",
|
||||||
"//tensorflow/python:variables",
|
"//tensorflow/python:variables",
|
||||||
],
|
],
|
||||||
|
flaky = 1, # create_local_cluster sometimes times out.
|
||||||
)
|
)
|
||||||
|
|
||||||
cuda_py_test(
|
cuda_py_test(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user