def _fit(client: Client, fit_msg: ServerMessage.FitIns) -> ClientMessage: # Deserialize fit instruction fit_ins = serde.fit_ins_from_proto(fit_msg) # Perform fit fit_res = client.fit(fit_ins) # Serialize fit result fit_res_proto = serde.fit_res_to_proto(fit_res) return ClientMessage(fit_res=fit_res_proto)
def _evaluate(client: Client, evaluate_msg: ServerMessage.EvaluateIns) -> ClientMessage: # Deserialize evaluate instruction evaluate_ins = serde.evaluate_ins_from_proto(evaluate_msg) # Perform evaluation evaluate_res = client.evaluate(evaluate_ins) # Serialize evaluate result evaluate_res_proto = serde.evaluate_res_to_proto(evaluate_res) return ClientMessage(evaluate_res=evaluate_res_proto)
def _get_properties( client: Client, properties_msg: ServerMessage.PropertiesIns ) -> ClientMessage: # Deserialize get_properties instruction properties_ins = serde.properties_ins_from_proto(properties_msg) # Request for properties properties_res = client.get_properties(properties_ins) # Serialize response properties_res_proto = serde.properties_res_to_proto(properties_res) return ClientMessage(properties_res=properties_res_proto)
def _federated_personalized_evaluate( client: Client, fpe_msg: ServerMessage.FederatedPersonalizedEvaluateIns ) -> ClientMessage: # Deserialize fpe instruction fpe_ins = serde.fpe_ins_from_proto(fpe_msg) # Perform federated personalized evaluation fpe_res = client.federated_personalized_evaluate(fpe_ins) # Serialize fpe result fpe_res_proto = serde.fpe_res_to_proto(fpe_res) return ClientMessage(fpe_res=fpe_res_proto)
def _get_parameters(client: Client) -> ClientMessage: # No need to deserialize get_parameters_msg (it's empty) parameters_res = client.get_parameters() parameters_res_proto = serde.parameters_res_to_proto(parameters_res) return ClientMessage(parameters_res=parameters_res_proto)