syft.core.store

class syft.core.store.DiskObjectStore(db_path=None)[source]

Bases: syft.core.store.store_interface.ObjectStore

keys()[source]

Method to return all indexes from the store.

Returns

an iterable containing the keys of the store.

Return type

Iterable[UID]

values()[source]

Method to return all values from the store.

Returns

an iterable containing the keys of the store.

Return type

Iterable[StorableObject]

delete(key)[source]

We should write custom deletion code so we can check if the item exists and then ensure deletion is called at a single place and that full __delitem__ is used where possible instead of the weaker del ref count. Also, care needs to be taken to not capture the deleted item in the Exception stack trace so it doesn’t keep the item around longer.

Method to remove an object from the store based on its UID.

Parameters

key (UID) – the key at which to delete the object.

Raises

ValueError – if the key is not present in the store.

clear()[source]

Clears all storage owned by the store.

class syft.core.store.ObjectStore[source]

Bases: abc.ABC

ObjectStore is the common interface for all the stores that a Node can handle. This should provide a dict-like interface on handling data on a worker. Indexing should be always done by using UID objects, while de-indexed value should always be a SerizableObject.

keys()[source]

Method to return all indexes from the store.

Returns

an iterable containing the keys of the store.

Return type

Iterable[UID]

values()[source]

Method to return all values from the store.

Returns

an iterable containing the keys of the store.

Return type

Iterable[StorableObject]

delete(key)[source]

We should write custom deletion code so we can check if the item exists and then ensure deletion is called at a single place and that full __delitem__ is used where possible instead of the weaker del ref count. Also, care needs to be taken to not capture the deleted item in the Exception stack trace so it doesn’t keep the item around longer.

Method to remove an object from the store based on its UID.

Parameters

key (UID) – the key at which to delete the object.

Raises

ValueError – if the key is not present in the store.

clear()[source]

Clears all storage owned by the store.

class syft.core.store.MemoryStore[source]

Bases: syft.core.store.store_interface.ObjectStore

Class that implements an in-memory ObjectStorage, backed by a dict.

_objects

the dict that backs the storage of the MemoryStorage.

Type

dict

_search_engine

the objects that handles searching by using tags or

Type

ObjectSearchEngine

description.
keys()[source]

Method to return all indexes from the store.

Returns

an iterable containing the keys of the store.

Return type

Iterable[UID]

values()[source]

Method to return all values from the store.

Returns

an iterable containing the keys of the store.

Return type

Iterable[StorableObject]

delete(key)[source]

We should write custom deletion code so we can check if the item exists and then ensure deletion is called at a single place and that full __delitem__ is used where possible instead of the weaker del ref count. Also, care needs to be taken to not capture the deleted item in the Exception stack trace so it doesn’t keep the item around longer.

Method to remove an object from the store based on its UID.

Parameters

key (UID) – the key at which to delete the object.

Raises

ValueError – if the key is not present in the store.

clear()[source]

Clears all storage owned by the store.

class syft.core.store.Dataset(id, data, description=None, tags=None, read_permissions=None, search_permissions=None)[source]

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

Dataset is a wrapper over a collection of Serializable objects.

Parameters
  • id (UID) – the id at which to store the data.

  • data (List[Serializable]) – A list of serializable objects.

  • description (Optional[str]) – An optional string that describes what you are storing. Useful

  • when searching.

  • tags (Optional[List[str]]) – An optional list of strings that are tags used at search.

  • TODO – add docs about read_permission and search_permission

id

the id at which to store the data.

Type

UID

data

A list of serializable objects.

Type

List[Serializable]

description

An optional string that describes what you are storing. Useful

Type

Optional[str]

when searching.
tags

An optional list of strings that are tags used at search.

Type

Optional[List[str]]

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

Modules

syft.core.store.dataset

syft.core.store.store_disk

syft.core.store.store_interface

syft.core.store.store_memory

syft.core.store.storeable_object