aiida_restapi.services package#
Submodules#
aiida_restapi.services.entity module#
REST API entity repository.
- class aiida_restapi.services.entity.EntityService(entity_class)[source]#
Bases:
Generic[EntityType,EntityModelType]Service for managing AiiDA entities.
This class provides methods to retrieve AiiDA entities with optional filtering, sorting, and pagination.
- Parameters:
entity_class – The AiiDA ORM entity class associated with this utility, e.g. orm.User, orm.Node, etc.
- __annotations__ = {}#
- __dict__ = mappingproxy({'__module__': 'aiida_restapi.services.entity', '__doc__': 'Service for managing AiiDA entities.\n\n This class provides methods to retrieve AiiDA entities with optional filtering, sorting, and pagination.\n\n :param entity_class: The AiiDA ORM entity class associated with this utility, e.g. `orm.User`, `orm.Node`, etc.\n ', '__init__': <function EntityService.__init__>, 'project': <property object>, 'get_schema': <function EntityService.get_schema>, 'get_projections': <function EntityService.get_projections>, 'get_one': <function EntityService.get_one>, 'get_many': <function EntityService.get_many>, 'get_related_one': <function EntityService.get_related_one>, 'get_related_many': <function EntityService.get_related_many>, 'get_field': <function EntityService.get_field>, 'add': <function EntityService.add>, 'update': <function EntityService.update>, '_get_projections': <function EntityService._get_projections>, '_apply_update': <function EntityService._apply_update>, '__orig_bases__': (typing.Generic[~EntityType, ~EntityModelType],), '__dict__': <attribute '__dict__' of 'EntityService' objects>, '__weakref__': <attribute '__weakref__' of 'EntityService' objects>, '__parameters__': (~EntityType, ~EntityModelType), '__annotations__': {}})#
- __module__ = 'aiida_restapi.services.entity'#
- __orig_bases__ = (typing.Generic[~EntityType, ~EntityModelType],)#
- __parameters__ = (~EntityType, ~EntityModelType)#
- __weakref__#
list of weak references to the object
- _apply_update(entity, model)[source]#
Apply changes to stored entity from a model payload.
- Parameters:
entity (orm.Entity) – The AiiDA entity to update.
model (EntityModelType) – The Pydantic model of the entity to update.
- _get_projections(orm_class=None)[source]#
Get the list of projections to use when querying the AiiDA entity.
Exclude fields that may be large.
- get_many(query_params)[source]#
Get AiiDA entities with optional filtering, sorting, and/or pagination.
- Parameters:
query_params (QueryBuilderParams) – The query parameters for filtering, sorting, and pagination.
- Returns:
The paginated results, including total count, current page, page size, and list of serialized entities.
- Return type:
Get related foreign entities of an entity.
- Parameters:
- Returns:
The paginated results of related foreign entities.
- Return type:
Get a related foreign entity of an entity.
- get_schema(which=None)[source]#
Get JSON schema for the AiiDA entity.
- Parameters:
which (str | None) – The type of schema to retrieve: ‘read’ or ‘write’.
- Returns:
A dictionary with ‘read’ and ‘write’ keys containing the respective JSON schemas.
- Return type:
- Raises:
ValueError – If the ‘which’ parameter is not ‘read’ or ‘write’.
- property project#
Get the list of projections to use when querying the AiiDA entity.
aiida_restapi.services.node module#
REST API node repository.
- class aiida_restapi.services.node.NodeService(entity_class)[source]#
Bases:
EntityService[NodeType,NodeModelType]Service for managing AiiDA nodes.
- DEFAULT_NAMESPACE_LABEL = '~no-entry-point~'#
- FULL_TYPE_CONCATENATOR = '|'#
- LIKE_OPERATOR_CHARACTER = '%'#
- __annotations__ = {}#
- __module__ = 'aiida_restapi.services.node'#
- __orig_bases__ = (aiida_restapi.services.entity.EntityService[~NodeType, ~NodeModelType],)#
- __parameters__ = (~NodeType, ~NodeModelType)#
- _apply_update(entity, model)[source]#
Apply changes to stored entity from a model payload.
- Parameters:
entity (orm.Entity) – The AiiDA entity to update.
model (EntityModelType) – The Pydantic model of the entity to update.
- _construct_full_type(node_type, process_type)[source]#
Return the full type, which fully identifies the type of any Node with the given node_type and process_type.
- _get_full_type_filters(full_type)[source]#
Return the QueryBuilder filters that will return all Nodes identified by the given full_type.
- Parameters:
full_type (str) – the full_type node type identifier
- Returns:
dictionary of filters to be passed for the filters keyword in QueryBuilder.append
- Return type:
- Raises:
ValueError – if the full_type is invalid
TypeError – if the full_type is not a string type
- _load_entry_point_from_full_type(full_type)[source]#
Return the loaded entry point for the given full_type unique node type identifier.
- Parameters:
full_type (str) – the full_type unique node type identifier
- Returns:
the loaded entry point
- Return type:
t.Any
- Raises:
ValueError – if the full_type is invalid
TypeError – if the full_type is not a string type
EntryPointError – if the corresponding entry point cannot be loaded
- _load_entry_point_from_node_type(node_type)[source]#
Return the loaded entry point for the given node_type.
- Parameters:
node_type (str) – the node_type unique node type identifier
- Returns:
the loaded entry point
- Return type:
- Raises:
ValueError – if the node_type is invalid
- _validate_full_type(full_type)[source]#
Validate that the full_type is a valid full type unique node identifier.
- Parameters:
full_type (str) – a Node full type
- Raises:
ValueError – if the full_type is invalid
TypeError – if the full_type is not a string type
- get_download_formats(full_type=None)[source]#
Returns dict of possible node formats for all available node types.
- get_links(uuid, direction, query_params=QueryBuilderParams(page_size=10, page=1, offset=0, order_by=None, filters={}))[source]#
Get the incoming links of a node.
- Parameters:
uuid (str) – The uuid of the node to retrieve the incoming links for.
query_params (QueryBuilderParams) – The query parameters for filtering, sorting, and pagination.
direction (str) – Specify whether to retrieve incoming or outgoing links.
- Returns:
The paginated requested linked nodes.
- Return type:
- with_key = 'node'#