DataClayObject API

class DataClayObject(*args, **kwargs)[source]

Main class for Persistent Objects.

Objects that has to be made persistent should derive this class (either directly, through the StorageObject alias, or through a derived class).

property is_persistent: bool

Whether the object is registered in the dataClay system or not.

property backends: set[UUID]

Returns a set with all the backend ids where the object is stored

async a_get_properties() dict[str, Any][source]

Async version of get_properties().

get_properties() dict[str, Any][source]

Returns the properties of the object.

getID() str | None[source]

Return the JSON-encoded metadata of the persistent object for COMPSs.

If the object is NOT persistent, then this method returns None.

async a_sync()[source]

Async version of sync().

sync()[source]

Synchronizes the object metadata

It will always retrieve the current metadata from the kv database. It won’t update local changes to the database.

Raises:
async a_make_persistent(alias: str | None = None, backend_id: UUID | None = None)[source]

Async version of make_persistent().

make_persistent(alias: str | None = None, backend_id: UUID | None = None)[source]

Makes the object persistent.

Parameters:
  • alias – Alias of the object. If None, the object will not have an alias.

  • backend_id – ID of the backend where the object will be stored. If None, the object will be stored in a random backend.

Raises:

KeyError: If the backend_id is not registered in dataClay.

async classmethod a_get_by_id(object_id: UUID) DataClayObject[source]

Async version of get_by_id().

classmethod get_by_id(object_id: UUID) DataClayObject[source]

Returns the object with the given id.

Parameters:

object_id – ID of the object.

Returns:

The object with the given id.

Raises:

DoesNotExistError – If the object does not exist.

async classmethod a_get_by_alias(alias: str, dataset_name: str = None) T[source]

Async version of get_by_alias().

classmethod get_by_alias(alias: str, dataset_name: str = None) T[source]

Retrieve an object by its alias.

Parameters:
  • alias – The alias of the object to retrieve.

  • dataset_name – Optional. The name of the dataset where the alias is stored. If not provided, the active dataset is used.

Returns:

The object associated with the given alias.

Raises:
async a_add_alias(alias: str)[source]

Async version of add_alias().

add_alias(alias: str)[source]

Adds an alias to the object.

Parameters:

alias – Alias to be added.

Raises:
async a_get_aliases() set[str][source]

Async version of get_aliases().

get_aliases() set[str][source]

Returns a set with all the aliases of the object.

async classmethod a_delete_alias(alias: str, dataset_name: str = None)[source]

Async version of delete_alias().

classmethod delete_alias(alias: str, dataset_name: str = None)[source]

Removes the alias linked to an object.

If this object is not referenced starting from a root object and no active session is accessing it, the garbage collector will remove it from the system.

Parameters:
  • alias – Alias to be removed.

  • dataset_name – Name of the dataset where the alias is stored. If None, the active dataset is used.

Raises:
async a_move(backend_id: UUID, recursive: bool = False, remotes: bool = True)[source]

Async version of move().

move(backend_id: UUID, recursive: bool = False, remotes: bool = True)[source]

Moves the object to the specified backend.

If the object is not registered, it will be registered with all its references to the corresponding backend

Parameters:
  • backend_id – Id of the backend where the object will be moved.

  • recursive – If True, all objects referenced by this object registered in the same backend will also be moved.

  • remotes – If True (default), when recursive is True the remote references will also be moved. Otherwise only the local references are moved.

Raises:

KeyError – If the backend_id is not registered in dataClay.

async a_new_version(backend_id: UUID = None, recursive: bool = False) DataClayObject[source]

Async version of new_version().

new_version(backend_id: UUID = None, recursive: bool = False) DataClayObject[source]

Create a new version of the current object.

Parameters:

backend_id – the backend where the object will be stored. If this parameter is not specified, a random backend will be chosen.

Returns:

A new object instance initialized with the field values of the current object.

Raises:
  • ObjectNotRegisteredError – If the object is not registered in dataClay.

  • KeyError – If the backend_id is not registered in dataClay.

async a_consolidate_version()[source]

Async version of consolidate_version().

consolidate_version()[source]

Consolidate the current version of the object with the original one.

Raises:

ObjectIsNotVersionError – If the object is not a version.

async a_new_replica(backend_id: UUID = None, recursive: bool = False, remotes: bool = True)[source]
async classmethod dc_clone_by_alias(alias: str, recursive: bool = False) DataClayObject[source]

Returns a non-persistent object as a copy of the object with the alias specified.

Fields referencing to other objects are kept as remote references to objects stored in dataClay, unless the recursive parameter is set to True.

Parameters:
  • alias – alias of the object to be retrieved.

  • recursive – When this is set to True, the default behavior is altered so not only current object but all of its references are also retrieved locally.

Returns:

A new instance initialized with the field values of the object with the alias specified.

Raises:

DoesNotExistError – If the alias does not exist.

async dc_clone(recursive: bool = False) DataClayObject[source]

Returns a non-persistent object as a copy of the current object.

Parameters:

recursive – When this is set to True, the default behavior is altered so not only current object but all of its references are also retrieved locally.

Returns:

A new object instance initialized with the field values of the current object.

Raises:

ObjectNotRegisteredError – If the object is not registered.

async classmethod dc_update_by_alias(alias: str, from_object: DataClayObject)[source]

Updates the object identified by specified alias with contents of from_object.

Parameters:
  • alias – alias of the object to be updated.

  • from_object – object with the new values to be updated.

Raises:
  • DoesNotExistError – If the alias does not exist.

  • TypeError – If the objects are not of the same type.

async dc_update(from_object: DataClayObject)[source]

Updates the current object with the properties of from_object.

Parameters:

from_object – The object with the new values to update current object.

Raises:

TypeError – If the objects are not of the same type.

async a_dc_update_properties(new_properties: dict[str, Any])[source]

Async version of dc_update_properties().

dc_update_properties(new_properties: dict[str, Any])[source]

Updates current object with the new properties.

Parameters:

new_properties – dictionary with the new properties to update current object.

Raises:

TypeError – If the objects are not of the same type.

async dc_put(alias: str, backend_id: UUID = None)[source]

Makes the object persistent in the specified backend.

Parameters:
  • alias – a string that will identify the object in addition to its OID. Aliases are unique for dataset.

  • backend_id – the backend where the object will be stored. If this parameter is not specified, a random backend will be chosen.

Raises:
  • AttributeError – if alias is null or empty.

  • AlreadyExistError – If the alias already exists.

  • KeyError – If the backend_id is not registered in dataClay.

activemethod(func)[source]

Decorator for DataClayObject active methods.