def bufferize(worker: AbstractWorker, action_message: "CommandMessage") -> "CommandMessagePB": """ This function takes the attributes of a CommandMessage and saves them in Protobuf Args: worker (AbstractWorker): a reference to the worker doing the serialization action_message (CommandMessage): an CommandMessage Returns: protobuf_obj: a Protobuf message holding the unique attributes of the message Examples: data = bufferize(message) """ protobuf_op_msg = CommandMessagePB() protobuf_op = ComputationAction.bufferize(worker, action_message.action) protobuf_op_msg.action.CopyFrom(protobuf_op) return protobuf_op_msg
def bufferize( worker: AbstractWorker, action_message: "TensorCommandMessage" ) -> "CommandMessagePB": """ This function takes the attributes of a TensorCommandMessage and saves them in Protobuf Args: worker (AbstractWorker): a reference to the worker doing the serialization action_message (TensorCommandMessage): an TensorCommandMessage Returns: protobuf_obj: a Protobuf message holding the unique attributes of the message Examples: data = bufferize(message) """ protobuf_action_msg = CommandMessagePB() protobuf_action = sy.serde.protobuf.serde._bufferize(worker, action_message.action) if isinstance(action_message.action, ComputationAction): protobuf_action_msg.computation.CopyFrom(protobuf_action) elif isinstance(action_message.action, CommunicationAction): protobuf_action_msg.communication.CopyFrom(protobuf_action) return protobuf_action_msg