syft.core.common.object¶
Classes
|
This object is the superclass for nearly all Syft objects. |
- class syft.core.common.object.ObjectWithID(id=None)[source]¶
Bases:
syft.core.common.serde.serializable.Serializable
This object is the superclass for nearly all Syft objects. Subclassing from this object will cause an object to be initialized with a unique id using the process specified in the UID class.
Note
At the time of writing, the only class in Syft which doesn’t have an ID of some kind is the Client class because it’s job is to point to another object (which has an ID).
Note
Be aware of performance choices in this class because it is used so heavily across the entire codebase. Assume every method is going to be called thousands of times during the working day of an average data scientist using syft (and millions of times in the context of a machine learning job).
- __init__(id=None)[source]¶
This initializer only exists to set the id attribute, which is the primary purpose of this class. It also sets the ‘as_wrapper’ flag for the ‘Serializable’ superclass.
- Parameters
id – an override which can be used to set an ID for this object
- property id¶
We reveal ObjectWithID.id as a property to discourage users and developers of Syft from modifying .id attributes after an object has been initialized.
- Returns
returns the unique id of the object
- repr_short()[source]¶
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.
- Returns
a SHORT human-readable version of SpecificLocation
- 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.