DataClayObject API

class dataclay.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).

async a_add_alias(alias: str)[source]

Adds an alias to the object.

Parameters:

alias – Alias to be added.

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

  • AttributeError – If the alias is an empty string.

  • DataClayException – If the alias already exists.

async a_consolidate_version()[source]

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

Raises:

ObjectIsNotVersionError – If the object is not a version.

async classmethod a_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:
  • DoesNotExistError – If the alias does not exist.

  • DatasetIsNotAccessibleError – If the dataset is not accessible.

async a_get_aliases() set[str][source]

Returns a set with all the aliases of the object.

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

Returns the object with the given alias.

Parameters:
  • alias – Alias of the object.

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

Returns:

The object with the given alias.

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

  • DatasetIsNotAccessibleError – If the dataset is not accessible.

async classmethod a_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 a_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 a_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_replica(backend_id: UUID = None, recursive: bool = False, remotes: bool = True)[source]
async a_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_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:
  • ObjectNotRegisteredError – If the object is not registered.

  • ObjectIsMasterError – If the object is the master.

add_alias(alias: str)[source]
property backends: set[UUID]

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

consolidate_version()[source]
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_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_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.

  • ObjectAlreadyRegisteredError – If the object is already registered in dataClay.

async dc_update(from_object: DataClayObject)[source]

Updates current object with contents of from_object.

Parameters:

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

Raises:

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

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.

classmethod delete_alias(alias: str, dataset_name: str | None = None)[source]
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.

get_aliases() set[str][source]
classmethod get_by_alias(alias: str, dataset_name: str | None = None) T[source]
classmethod get_by_id(object_id: UUID) DataClayObject[source]
property is_persistent: bool

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

make_persistent(alias: str | None = None, backend_id: UUID | None = None)[source]
move(backend_id: UUID, recursive: bool = False, remotes: bool = True)[source]
new_version(backend_id: UUID = None, recursive: bool = False) DataClayObject[source]
sync()[source]
dataclay.activemethod(func)[source]

Decorator for DataClayObject active methods.