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

consolidate_version()[source]#

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

property dataclay_id#

ID of the object in the dataClay system.

property dataset#

Name of the dataset where the object is stored.

dc_clone(recursive=False)[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.

classmethod dc_clone_by_alias(alias, recursive=False)[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.

dc_put(alias, backend_id=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.

dc_update(from_object)[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.

classmethod dc_update_by_alias(alias, from_object)[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, dataset_name=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 session’s dataset is used.

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

  • DatasetIsNotAccessibleError – If the dataset is not accessible.

get_backends()[source]#

Returns the set of backends where the object is stored

classmethod get_by_alias(alias, dataset_name=None)[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 session’s 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.

classmethod get_by_id(object_id: UUID)[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.

get_id()[source]#

Return the string representation of the persistent object for COMPSs.

dataClay specific implementation: The objects are internally represented through ObjectID, which are UUID. In addition to that, some extra fields are added to the representation. Currently, a “COMPSs ID” will be:

<objectID>:<backendID|empty>:<classID>

In which all ID are UUID and the “hint” (backendID) can be empty.

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

property is_registered#

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

make_persistent(alias=None, backend_id=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:
  • AttributeError – If the alias is an empty string.

  • RuntimeError – If the object is already persistent.

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

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

Moves the object to the specified 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.

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

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

new_version(backend_id=None, recursive=False)[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.

dataclay.activemethod(func)[source]#

Decorator for DataClayObject active methods.