def detail(worker: AbstractWorker, protocol_tuple: tuple) -> "Protocol": """This function reconstructs a Protocol object given its attributes in the form of a tuple. Args: worker: the worker doing the deserialization protocol_tuple: a tuple holding the attributes of the Protocol Returns: protocol: a Protocol object """ id, tags, description, plans_reference, workers_resolved = map( lambda o: sy.serde._detail(worker, o), protocol_tuple ) plans = [] for owner_id, plan_id in plans_reference: if workers_resolved: plan_owner = worker.get_worker(owner_id, fail_hard=True) plan_pointer = worker.request_search(plan_id, location=plan_owner)[0] worker.register_obj(plan_pointer) plans.append((plan_owner, plan_pointer)) else: try: plan_owner = worker.get_worker(owner_id, fail_hard=True) plan_pointer = worker.request_search(plan_id, location=plan_owner)[0] plan = plan_pointer.get() except WorkerNotFoundException: plan = worker.get_obj(plan_id) plans.append((worker.id, plan)) protocol = sy.Protocol(plans=plans, id=id, owner=worker, tags=tags, description=description) return protocol
def detail(worker: AbstractWorker, tensor_tuple: tuple) -> "AdditiveSharingTensor": """ This function reconstructs a AdditiveSharingTensor given it's attributes in form of a tuple. Args: worker: the worker doing the deserialization tensor_tuple: a tuple holding the attributes of the AdditiveSharingTensor Returns: AdditiveSharingTensor: a AdditiveSharingTensor Examples: shared_tensor = detail(data) """ tensor_id, field, dtype, crypto_provider, chain, garbage_collect = tensor_tuple crypto_provider = sy.serde.msgpack.serde._detail( worker, crypto_provider) tensor = AdditiveSharingTensor( owner=worker, id=sy.serde.msgpack.serde._detail(worker, tensor_id), field=sy.serde.msgpack.serde._detail(worker, field), dtype=dtype.decode("utf-8"), crypto_provider=worker.get_worker(crypto_provider), ) if chain is not None: chain = sy.serde.msgpack.serde._detail(worker, chain) tensor.child = chain tensor.set_garbage_collect_data(garbage_collect) return tensor
def detail(worker: AbstractWorker, tensor_tuple: tuple) -> "AdditiveSharingTensor": """ This function reconstructs a AdditiveSharingTensor given it's attributes in form of a tuple. Args: worker: the worker doing the deserialization tensor_tuple: a tuple holding the attributes of the AdditiveSharingTensor Returns: AdditiveSharingTensor: a AdditiveSharingTensor Examples: shared_tensor = detail(data) """ tensor_id, field, crypto_provider, chain = tensor_tuple tensor = AdditiveSharingTensor( owner=worker, id=tensor_id, field=field, crypto_provider=worker.get_worker(crypto_provider), ) if chain is not None: chain = sy.serde._detail(worker, chain) tensor.child = chain return tensor
def unbufferize( worker: AbstractWorker, protobuf_tensor: "AdditiveSharingTensorPB" ) -> "AdditiveSharingTensor": """ This function reconstructs a AdditiveSharingTensor given its' attributes in form of a protobuf object. Args: worker: the worker doing the deserialization protobuf_tensor: a protobuf object holding the attributes of the AdditiveSharingTensor Returns: AdditiveSharingTensor: a AdditiveSharingTensor Examples: shared_tensor = unprotobuf(data) """ tensor_id = sy.serde.protobuf.proto.get_protobuf_id(protobuf_tensor.id) crypto_provider_id = sy.serde.protobuf.proto.get_protobuf_id( protobuf_tensor.crypto_provider_id ) field = protobuf_tensor.field_size tensor = AdditiveSharingTensor( owner=worker, id=tensor_id, field=field, crypto_provider=worker.get_worker(crypto_provider_id), ) if protobuf_tensor.location_ids is not None: chain = {} for pb_location_id, share in zip(protobuf_tensor.location_ids, protobuf_tensor.shares): location_id = sy.serde.protobuf.proto.get_protobuf_id(pb_location_id) chain[location_id] = sy.serde.protobuf.serde._unbufferize(worker, share) tensor.child = chain return tensor
def detail(worker: AbstractWorker, worker_tuple: tuple) -> Union[AbstractWorker, int, str]: """ This function reconstructs a PlanPointer given it's attributes in form of a tuple. Args: worker: the worker doing the deserialization plan_pointer_tuple: a tuple holding the attributes of the PlanPointer Returns: A worker id or worker instance. """ worker_id = sy.serde.msgpack.serde._detail(worker, worker_tuple[0]) referenced_worker = worker.get_worker(worker_id) return referenced_worker
def detail(worker: AbstractWorker, tensor_tuple: tuple) -> "AdditiveSharingTensor": """ This function reconstructs a AdditiveSharingTensor given it's attributes in form of a tuple. Args: worker: the worker doing the deserialization tensor_tuple: a tuple holding the attributes of the AdditiveSharingTensor Returns: AdditiveSharingTensor: a AdditiveSharingTensor Examples: shared_tensor = detail(data) """ _detail = lambda x: sy.serde.msgpack.serde._detail(worker, x) tensor_id, field, protocol, dtype, crypto_provider, chain, garbage_collect = tensor_tuple crypto_provider = _detail(crypto_provider) tensor = AdditiveSharingTensor( owner=worker, id=_detail(tensor_id), field=_detail(field), protocol=_detail(protocol), dtype=dtype.decode("utf-8"), crypto_provider=worker.get_worker(crypto_provider), ) chain = _detail(chain) tensor.child = {} for share in chain: if share.location is not None: # Remote tensor.child[share.location.id] = share else: # Local tensor.child[share.owner.id] = share tensor.set_garbage_collect_data(garbage_collect) return tensor