def Foo(self, request, context):
     print('Accept new request')
     
     time.sleep(5)
     
     print('Done with request')
     return service_pb2.Empty()
Exemple #2
0
def main():
    channel = grpc.insecure_channel('localhost:50001')
    stub = service_pb2_grpc.ServerStub(channel)

    print('Send request')
    stub.Foo(service_pb2.Empty())
    print('Request successful')
async def main():

    with grpc.insecure_channel('localhost:50001') as channel:
        stub = service_pb2_grpc.ServerStub(channel)

        print('Send request')
        await _submit(stub.Foo, service_pb2.Empty())

        print('Request successful')
Exemple #4
0
    def Aggregate(self, request, _):
        LOGGER.info("Aggregate: request [%s]", request)

        self.request_validate(request)

        threading.Thread(target=self.send_response,
                         daemon=True,
                         args=(request.aggregatedModel.path, )).start()

        return service_pb2.Empty()
Exemple #5
0
    def LocalTrain(self, request, _):
        LOGGER.info("LocalTrain: request [%s]", request)

        self.request_validate(request)

        threading.Thread(target=self.send_response,
                         daemon=True,
                         args=(request.localModel.path, )).start()

        return service_pb2.Empty()
Exemple #6
0
    def Aggregate(self, request, context):
        logging.info("received Aggregate message [%s]", request)

        threading.Thread(
            target=aggregate,
            args=(request.localModels, request.aggregatedModel),
            daemon=True
        ).start()

        response = service_pb2.Empty()
        return response
Exemple #7
0
    def LocalTrain(self, request, context):
        logging.info("LocalTrain")

        threading.Thread(target=train,
                         args=(request.baseModel, request.localModel.path,
                               request.EpR),
                         daemon=True).start()

        resp = service_pb2.Empty()
        logging.info("Sending response: {}".format(resp))
        return resp
Exemple #8
0
def main():
    host = 'localhost'
    port = 1337

    with open('server.crt') as f:
        trusted_certs = f.read()

    credentials = grpc.ssl_channel_credentials(root_certificates=trusted_certs)
    channel = grpc.secure_channel('{}:{}'.format(host, port), credentials)

    stub = service_pb2.ServerStub(channel)
    stub.Foo(service_pb2.Empty())
Exemple #9
0
    def AggregateFinish(self, request, _):
        print(f"Aggregate finish: [{request}]")

        result = torch.load("/repos/output/weights.tar", 'cpu')
        print(f"Aggregate result: [{result}]")

        if operator.eq(result, EXPECTED):
            os.kill(os.getpid(), signal.SIGUSR1)
        else:
            print(f"Expect [{EXPECTED}], Got [{result}]")
            os.kill(os.getpid(), signal.SIGUSR2)

        sys.stdout.flush()
        return service_pb2.Empty()
Exemple #10
0
def main():
    host = 'localhost'
    port = 1337

    with open('server.crt', 'rb') as f:
        trusted_certs = f.read()

    credentials = grpc.ssl_channel_credentials(root_certificates=trusted_certs)
    channel = grpc.secure_channel('{}:{}'.format(host, port), credentials)

    stub = service_pb2_grpc.ServerStub(channel)
    stub.Foo(service_pb2.Empty())

    response = stub.SayHello(service_pb2.HelloRequest(name='you'))
    print("Greeter client received: " + response.message)

    response = stub.SayHelloAgain(service_pb2.HelloRequest(name='you'))
    print("Greeter client received: " + response.message)
 async def Foo(self, request, context):
     print('Accept new request')
     await asyncio.sleep(1)
     print('Done with request')
     return service_pb2.Empty()
Exemple #12
0
 def Foo(self, request, context):
     return service_pb2.Empty(message='Hello! Current time is ' + time.ctime())
Exemple #13
0
 def Foo(self, request, context):
     return service_pb2.Empty()
Exemple #14
0
 def TrainFinish(self, _request, _context):
     logging.info("TrainFinish")
     STOP_EVENT.set()
     return service_pb2.Empty()
Exemple #15
0
 def TrainInterrupt(self, _request, _context):
     # Not Implemented
     return service_pb2.Empty()
Exemple #16
0
 def TrainInit(self, _0, _1):
     LOGGER.info("Initialize train")
     return service_pb2.Empty()
Exemple #17
0
 def TrainInit(self, request, context):
     logging.info("TrainInit")
     resp = service_pb2.Empty()
     logging.info(f"Sending response: {resp}")
     return resp
Exemple #18
0
 def Unsubscribe(self, request, unused_context):
     DramaInfo.Unsubscribe(request.user_id, request.drama_id)
     return service_pb2.Empty()
Exemple #19
0
 def TrainFinish(self, _0, _1):
     LOGGER.info("Train Finish")
     STOP_EVENT.set()
     return service_pb2.Empty()