syft.core.common.uid

Classes

UID([value])

A unique ID for every Syft object.

class syft.core.common.uid.UID(value=None)[source]

Bases: syft.core.common.serde.serializable.Serializable

A unique ID for every Syft object.

This object creates a unique ID for every object in the Syft ecosystem. This ID is guaranteed to be unique for the node on which it is initialized and is very likely to be unique across the whole ecosystem (because it is long and randomly generated).

Nearly all objects within Syft subclass from this object because nearly all objects need to have a unique ID. The only major exception a the time of writing is the Client object because it just points to another object which itself has an id.

There is no other way in Syft to create an ID for any object.

__init__(value=None)[source]

Initializes the internal id using the uuid package.

This initializes the object. Normal use for this object is to initialize the constructor with value==None because you want to initialize with a novel ID. The only major exception is deserialization, wherein a UID object is created with a specific id value.

Parameters

value (uuid.uuid4, optional) – if you want to initialize an object with a specific UID, pass it in here. This is normally only used during deserialization.

Returns

returns the initialized object

Return type

UID

from syft.core.common.uid import UID
my_id = UID()
repr_short()[source]

Returns a SHORT human-readable version of the ID

Return a SHORT human-readable version of the ID which makes it print nicer when embedded (often alongside other UID objects) within other object __repr__ methods.

static get_protobuf_schema()[source]

Return the type of protobuf object which stores a class of this type

As a part of serialization and deserialization, we need the ability to lookup the protobuf object type directly from the object type. This static method allows us to do this.

Importantly, this method is also used to create the reverse lookup ability within the metaclass of Serializable. In the metaclass, it calls this method and then it takes whatever type is returned from this method and adds an attribute to it with the type of this class attached to it. See the MetaSerializable class for details.

Returns

the type of protobuf object which corresponds to this class.

Return type

GeneratedProtocolMessageType