def test_channel(self): channel = make_insecure_channel('worker_0', mode=ChannelType.INTERNAL) stub = tm_grpc.TrainerMasterServiceStub(channel) request = tm_pb.DataBlockRequest() print(stub.RequestDataBlock(request)) self.assertIsNotNone(stub.RequestDataBlock(request)) channel = make_insecure_channel('worker_0', mode=ChannelType.REMOTE) stub = tm_grpc.TrainerMasterServiceStub(channel) request = tm_pb.DataBlockRequest() print(stub.RequestDataBlock(request)) self.assertIsNotNone(stub.RequestDataBlock(request))
def __init__(self, addr, role, task_id): self._addr = addr self._role = role self._task_id = task_id channel = make_insecure_channel(self._addr, ChannelType.INTERNAL) self._stub = tm_grpc.TrainerMasterServiceStub(channel) self._request = tm_pb.DataBlockRequest() if self._role == 'leader': self._request.worker_rank = self._task_id
def __init__(self, address, worker_rank): channel = make_insecure_channel( address, mode=ChannelType.INTERNAL, options=( ('grpc.max_send_message_length', -1), ('grpc.max_receive_message_length', -1), ('grpc.max_reconnect_backoff_ms', 1000), )) client = tm_grpc.TrainerMasterServiceStub(channel) super(TrainerMasterClient, self).__init__(client, worker_rank)