How to use the syft.serde._detail function in syft

To help you get started, we’ve selected a few syft examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenMined / PySyft / syft / serde / native_serde.py View on Github external
Args:
        worker: the worker doing the deserialization
        my_collection (Collection): a collection of simple python objects (including binary).

    Returns:
        Collection: a collection of the same type as the input where the objects
            in the collection have been detailed.
    """

    pieces = list()

    # Step 1: deserialize each part of the collection
    for part in my_collection:
        try:
            pieces.append(
                serde._detail(worker, part).decode("utf-8")
            )  # transform bytes back to string
        except AttributeError:
            pieces.append(serde._detail(worker, part))

    return pieces
github OpenMined / PySyft / syft / frameworks / torch / pointers / object_wrapper.py View on Github external
def detail(worker: AbstractWorker, obj_wrapper_tuple: str) -> "ObjectWrapper":
        obj_wrapper = ObjectWrapper(
            id=obj_wrapper_tuple[0], obj=sy.serde._detail(worker, obj_wrapper_tuple[1])
        )
        return obj_wrapper
github OpenMined / PySyft / syft / workers / virtual.py View on Github external
def detail(worker: AbstractWorker, worker_tuple: tuple) -> "pointers.PointerTensor":
        """
        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:
            PointerTensor: a PointerTensor
        Examples:
            ptr = detail(data)
        """
        worker_id = sy.serde._detail(worker, worker_tuple[0])

        referenced_worker = worker.get_worker(worker_id)

        return referenced_worker
github OpenMined / PySyft / syft / messaging / plan.py View on Github external
state_ids = sy.serde._detail(worker, state_ids)

        plan = sy.Plan(
            owner=worker,
            id=id,
            arg_ids=arg_ids,
            result_ids=result_ids,
            readable_plan=readable_plan,  # We're not detailing, see simplify() for details
            is_built=is_built,
        )

        plan.state_ids = state_ids

        plan.name = sy.serde._detail(worker, name)
        plan.tags = sy.serde._detail(worker, tags)
        plan.description = sy.serde._detail(worker, description)

        return plan
github OpenMined / PySyft / syft / workers / virtual.py View on Github external
def force_detail(worker: AbstractWorker, worker_tuple: tuple) -> tuple:
        worker_id, _objects, auto_add = worker_tuple
        worker_id = sy.serde._detail(worker, worker_id)

        result = sy.VirtualWorker(sy.hook, worker_id, auto_add=auto_add)
        _objects = sy.serde._detail(worker, _objects)
        result._objects = _objects

        # make sure they weren't accidentally double registered
        for _, obj in _objects.items():
            if obj.id in worker._objects:
                del worker._objects[obj.id]

        return result
github OpenMined / PySyft / syft / messaging / plan / procedure.py View on Github external
def detail(worker: AbstractWorker, procedure_tuple: tuple) -> "State":
        operations, arg_ids, result_ids = procedure_tuple
        operations = list(operations)
        arg_ids = sy.serde._detail(worker, arg_ids)
        result_ids = sy.serde._detail(worker, result_ids)

        procedure = Procedure(operations, arg_ids, result_ids)
        return procedure
github OpenMined / PySyft / syft / frameworks / torch / tensors / interpreters / precision.py View on Github external
FixedPrecisionTensor: a FixedPrecisionTensor
            Examples:
                shared_tensor = detail(data)
            """

        tensor_id, field, base, precision_fractional, kappa, tags, description, chain = tensor_tuple

        tensor = FixedPrecisionTensor(
            owner=worker,
            id=syft.serde._detail(worker, tensor_id),
            field=field,
            base=base,
            precision_fractional=precision_fractional,
            kappa=kappa,
            tags=syft.serde._detail(worker, tags),
            description=syft.serde._detail(worker, description),
        )

        if chain is not None:
            chain = syft.serde._detail(worker, chain)
            tensor.child = chain

        return tensor
github OpenMined / PySyft / syft / exceptions.py View on Github external
def detail(worker: "sy.workers.AbstractWorker", error_tuple: Tuple[str, str, dict]):
        """
        Detail and re-raise an Exception forwarded by another worker
        """
        error_name, traceback_str, attributes = error_tuple
        error_name, traceback_str = error_name.decode("utf-8"), traceback_str.decode("utf-8")
        attributes = sy.serde._detail(worker, attributes)
        # De-serialize the traceback
        tb = Traceback.from_string(traceback_str)
        # Check that the error belongs to a valid set of Exceptions
        if error_name in dir(sy.exceptions):
            error_type = getattr(sy.exceptions, error_name)
            error = error_type()
            # Include special attributes if any
            for attr_name, attr in attributes.items():
                setattr(error, attr_name, attr)
            reraise(error_type, error, tb.as_traceback())
        else:
            raise ValueError(f"Invalid Exception returned:\n{traceback_str}")
github OpenMined / PySyft / syft / messaging / plan.py View on Github external
def detail(worker: AbstractWorker, plan_tuple: tuple) -> "Plan":
        """This function reconstructs a Plan object given its attributes in the form of a tuple.
        Args:
            worker: the worker doing the deserialization
            plan_tuple: a tuple holding the attributes of the Plan
        Returns:
            plan: a Plan object
        """

        readable_plan, id, arg_ids, result_ids, state_ids, name, tags, description, is_built = (
            plan_tuple
        )
        id = sy.serde._detail(worker, id)
        arg_ids = sy.serde._detail(worker, arg_ids)
        result_ids = sy.serde._detail(worker, result_ids)
        state_ids = sy.serde._detail(worker, state_ids)

        plan = sy.Plan(
            owner=worker,
            id=id,
            arg_ids=arg_ids,
            result_ids=result_ids,
            readable_plan=readable_plan,  # We're not detailing, see simplify() for details
            is_built=is_built,
        )

        plan.state_ids = state_ids

        plan.name = sy.serde._detail(worker, name)
        plan.tags = sy.serde._detail(worker, tags)
        plan.description = sy.serde._detail(worker, description)