server_lib.create_local_server() should create TF server with job_name=localhost

PiperOrigin-RevId: 289994931
Change-Id: Ica2f09beca3cbea8d36c8034e6c930fa96ed8664
This commit is contained in:
Dong Lin 2020-01-15 21:16:16 -08:00 committed by TensorFlower Gardener
parent ce2b814242
commit 7e17fdff28
3 changed files with 6 additions and 5 deletions

View File

@ -54,7 +54,8 @@ class SessionListDevicesTest(test_util.TensorFlowTestCase):
server = server_lib.Server.create_local_server() server = server_lib.Server.create_local_server()
with session.Session(server.target) as sess: with session.Session(server.target) as sess:
devices = sess.list_devices() devices = sess.list_devices()
self.assertTrue('/job:local/replica:0/task:0/device:CPU:0' in set( self.assertTrue(
'/job:localhost/replica:0/task:0/device:CPU:0' in set(
[d.name for d in devices]), devices) [d.name for d in devices]), devices)
# All valid device incarnations must be non-zero. # All valid device incarnations must be non-zero.
self.assertTrue(all(d.incarnation != 0 for d in devices)) self.assertTrue(all(d.incarnation != 0 for d in devices))

View File

@ -231,7 +231,7 @@ class Server(object):
""" """
# Specifying port 0 means that the OS will choose a free port for the # Specifying port 0 means that the OS will choose a free port for the
# server. # server.
return Server({"local": ["localhost:0"]}, return Server({"localhost": ["localhost:0"]},
protocol="grpc", protocol="grpc",
config=config, config=config,
start=start) start=start)

View File

@ -555,7 +555,7 @@ class SupervisorTest(test.TestCase):
def get_session(is_chief): def get_session(is_chief):
g = ops.Graph() g = ops.Graph()
with g.as_default(): with g.as_default():
with ops.device("/job:local"): with ops.device("/job:localhost"):
v = variables.VariableV1( v = variables.VariableV1(
1, name="default_ready_for_local_init_op_v_" + str(uid)) 1, name="default_ready_for_local_init_op_v_" + str(uid))
vadd = v.assign_add(1) vadd = v.assign_add(1)
@ -613,7 +613,7 @@ class SupervisorTest(test.TestCase):
def get_session(is_chief): def get_session(is_chief):
g = ops.Graph() g = ops.Graph()
with g.as_default(): with g.as_default():
with ops.device("/job:local"): with ops.device("/job:localhost"):
v = variables.VariableV1( v = variables.VariableV1(
1.0, name="ready_for_local_init_op_restore_v_" + str(uid)) 1.0, name="ready_for_local_init_op_restore_v_" + str(uid))
vadd = v.assign_add(1) vadd = v.assign_add(1)