Interpreting metadata#

Many client functions return metadata. This class includes information about what objects records were created or already existing on the server, or which objects were deleted, modified, or had errors.

All metadata objects have some common features. Notably, if the operation was completely successful operation, then meta.success will be True. If any errors happened, these are also stored in meta.errors and meta.success will be False.

Metadata classes also have fields with an _idx suffix. These are lists that reference the zero-based index of the input list. If we take molecules as an example,

>>> water = Molecule(symbols=['H', 'H', 'O'], geometry=[0.0, 2.0, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0])
>>> nitrogen = Molecule(symbols=['N', 'N'], geometry=[0.0, 0.0, 0.0, 0.0, 0.0, 2.0])
>>> meta, ids = client.add_molecules([water, nitrogen])

>>> print(meta.success)
True

>>> print(meta)
InsertMetadata(error_description=None, errors=[], inserted_idx=[0], existing_idx=[1])

In this case, the addition of the two molecules to the server was a success. The first molecule water did not exist and was added to the server - this is represented by 0 in the inserted_idx attribute of the metadata. Likewise, the nitrogen molecule already existed (because 1 is in the existing_idx list).

If the water molecule already existed as well, inserted_idx would be [] and existing_idx would be [0, 1].

The total number of inserted or existing objects can be retrieved with n_inserted and n_existing.

Metadata API#

class InsertMetadata(error_description=None, errors=<factory>, inserted_idx=<factory>, existing_idx=<factory>)[source]#

Bases: object

Metadata returned by insertion / adding functions

Parameters:
  • error_description (str | None)

  • errors (List[Tuple[int, str]])

  • inserted_idx (List[int])

  • existing_idx (List[int])

error_description: str | None = None#
errors: List[Tuple[int, str]]#
inserted_idx: List[int]#
existing_idx: List[int]#
property n_inserted#
property n_existing#
property n_errors#
property error_idx#
property success#
property error_string#
classmethod sort_fields(v)[source]#
classmethod check_all_indices(values)[source]#
dict()[source]#

Returns the information from this dataclass as a dictionary

Return type:

Dict[str, Any]

static merge(metadata)[source]#
Parameters:

metadata (Sequence[InsertMetadata])

Return type:

InsertMetadata

class DeleteMetadata(error_description=None, errors=<factory>, deleted_idx=<factory>, n_children_deleted=0)[source]#

Bases: object

Metadata returned by delete functions

Parameters:
  • error_description (str | None)

  • errors (List[Tuple[int, str]])

  • deleted_idx (List[int])

  • n_children_deleted (int)

error_description: str | None = None#
errors: List[Tuple[int, str]]#
deleted_idx: List[int]#
n_children_deleted: int = 0#
property n_deleted#
property n_errors#
property error_idx#
property success#
property error_string#
classmethod sort_fields(v)[source]#
classmethod check_all_indices(values)[source]#
dict()[source]#

Returns the information from this dataclass as a dictionary

Return type:

Dict[str, Any]

class UpdateMetadata(error_description=None, errors=<factory>, updated_idx=<factory>, n_children_updated=0)[source]#

Bases: object

Metadata returned by update functions

Parameters:
  • error_description (str | None)

  • errors (List[Tuple[int, str]])

  • updated_idx (List[int])

  • n_children_updated (int)

error_description: str | None = None#
errors: List[Tuple[int, str]]#
updated_idx: List[int]#
n_children_updated: int = 0#
property n_updated#
property n_errors#
property error_idx#
property success#
property error_string#
classmethod sort_fields(v)[source]#
classmethod check_all_indices(values)[source]#
dict()[source]#

Returns the information from this dataclass as a dictionary

Return type:

Dict[str, Any]

class TaskReturnMetadata(error_description=None, rejected_info=<factory>, accepted_ids=<factory>)[source]#

Bases: object

Metadata returned to managers that have sent completed tasks back to the server

Parameters:
  • error_description (str | None)

  • rejected_info (List[Tuple[int, str]])

  • accepted_ids (List[int])

error_description: str | None = None#
rejected_info: List[Tuple[int, str]]#
accepted_ids: List[int]#
property n_accepted#
property n_rejected#
property rejected_ids#
property success#
property error_string#
classmethod sort_fields(v)[source]#
dict()[source]#

Returns the information from this dataclass as a dictionary

Return type:

Dict[str, Any]