Ejemplo n.º 1
0
    def start(self, config):
        """

        :param config:
        :return:
        """
        channel = Channel(self.address, self.port,
                          self.certificate).get_channel()
        control = rpc.ControlStub(channel)
        request = fedn.ControlRequest()
        request.command = fedn.Command.START
        for k, v in config.items():
            p = request.parameter.add()
            p.key = str(k)
            p.value = str(v)

        try:
            response = control.Start(request)
        except grpc.RpcError as e:
            if e.code() == grpc.StatusCode.UNAVAILABLE:
                raise CombinerUnavailableError
            else:
                raise

        print("Response from combiner {}".format(response.message))
        return response
Ejemplo n.º 2
0
 def set_model_id(self, model_id):
     channel = Channel(self.address, self.port, self.certificate).get_channel()
     control = rpc.ControlStub(channel)
     request = fedn.ControlRequest()
     p = request.parameter.add()
     p.key = 'model_id'
     p.value = str(model_id)
     response = control.Configure(request)
Ejemplo n.º 3
0
 def report(self,config=None):
     channel = Channel(self.address, self.port, self.certificate).get_channel()
     control = rpc.ControlStub(channel)
     request = fedn.ControlRequest()
     response = control.Report(request)
     data = {}
     for p in response.parameter:
         data[p.key] = p.value
     return data
Ejemplo n.º 4
0
 def configure(self,config=None):
     if not config:
         config = self.config
     channel = Channel(self.address, self.port, self.certificate).get_channel()
     control = rpc.ControlStub(channel)
     request = fedn.ControlRequest()
     for key,value in config.items():  
         p = request.parameter.add()
         p.key = key
         p.value = str(value)
     response = control.Configure(request)
Ejemplo n.º 5
0
    def start(self, config):
        channel = Channel(self.address, self.port, self.certificate).get_channel()
        control = rpc.ControlStub(channel)
        request = fedn.ControlRequest()
        request.command = fedn.Command.START
        for k, v in config.items():
            p = request.parameter.add()
            p.key = str(k)
            p.value = str(v)

        response = control.Start(request)
        print("Response from combiner {}".format(response.message))
        return response
Ejemplo n.º 6
0
 def report(self, config=None):
     channel = Channel(self.address, self.port,
                       self.certificate).get_channel()
     control = rpc.ControlStub(channel)
     request = fedn.ControlRequest()
     try:
         response = control.Report(request)
         data = {}
         for p in response.parameter:
             data[p.key] = p.value
         return data
     except grpc.RpcError as e:
         if e.code() == grpc.StatusCode.UNAVAILABLE:
             raise CombinerUnavailableError
         else:
             raise
Ejemplo n.º 7
0
    def set_model_id(self, model_id):
        channel = Channel(self.address, self.port,
                          self.certificate).get_channel()
        control = rpc.ControlStub(channel)
        request = fedn.ControlRequest()
        p = request.parameter.add()
        p.key = 'model_id'
        p.value = str(model_id)

        try:
            response = control.Configure(request)
        except grpc.RpcError as e:
            if e.code() == grpc.StatusCode.UNAVAILABLE:
                raise CombinerUnavailableError
            else:
                raise
Ejemplo n.º 8
0
    def configure(self, config=None):
        if not config:
            config = self.config
        channel = Channel(self.address, self.port,
                          self.certificate).get_channel()
        control = rpc.ControlStub(channel)

        request = fedn.ControlRequest()
        for key, value in config.items():
            p = request.parameter.add()
            p.key = key
            p.value = str(value)

        try:
            response = control.Configure(request)
        except grpc.RpcError as e:
            if e.code() == grpc.StatusCode.UNAVAILABLE:
                raise CombinerUnavailableError
            else:
                raise