aiida.tools.groups package¶
Provides tools for interacting with AiiDA Groups.
-
class
aiida.tools.groups.
GroupPath
(path='', cls=<class 'aiida.orm.groups.Group'>, warn_invalid_child=True)[source]¶ Bases:
object
A class to provide label delimited access to groups.
See tests for usage examples.
-
__dict__
= mappingproxy({'__module__': 'aiida.tools.groups.paths', '__doc__': 'A class to provide label delimited access to groups.\n\n See tests for usage examples.\n ', '__init__': <function GroupPath.__init__>, '_validate_path': <function GroupPath._validate_path>, '__repr__': <function GroupPath.__repr__>, '__eq__': <function GroupPath.__eq__>, '__lt__': <function GroupPath.__lt__>, 'path': <property object>, 'path_list': <property object>, 'key': <property object>, 'delimiter': <property object>, 'cls': <property object>, 'parent': <property object>, '__truediv__': <function GroupPath.__truediv__>, '__getitem__': <function GroupPath.__getitem__>, 'get_group': <function GroupPath.get_group>, 'group_ids': <property object>, 'is_virtual': <property object>, 'get_or_create_group': <function GroupPath.get_or_create_group>, 'delete_group': <function GroupPath.delete_group>, 'children': <property object>, '__iter__': <function GroupPath.__iter__>, '__len__': <function GroupPath.__len__>, '__contains__': <function GroupPath.__contains__>, 'walk': <function GroupPath.walk>, 'walk_nodes': <function GroupPath.walk_nodes>, 'browse': <property object>, '__dict__': <attribute '__dict__' of 'GroupPath' objects>, '__weakref__': <attribute '__weakref__' of 'GroupPath' objects>, '__hash__': None, '__gt__': <function _gt_from_lt>, '__le__': <function _le_from_lt>, '__ge__': <function _ge_from_lt>})¶
-
__ge__
(other, NotImplemented=NotImplemented)¶ Return a >= b. Computed by @total_ordering from (not a < b).
-
__getitem__
(path)[source]¶ Return a child
GroupPath
, with a new path formed by appendingpath
to the current path.
-
__gt__
(other, NotImplemented=NotImplemented)¶ Return a > b. Computed by @total_ordering from (not a < b) and (a != b).
-
__hash__
= None¶
-
__init__
(path='', cls=<class 'aiida.orm.groups.Group'>, warn_invalid_child=True)[source]¶ Instantiate the class.
- Parameters
path – The initial path of the group.
cls – The subclass of Group to operate on.
warn_invalid_child – Issue a warning, when iterating children, if a child path is invalid.
-
__le__
(other, NotImplemented=NotImplemented)¶ Return a <= b. Computed by @total_ordering from (a < b) or (a == b).
-
__lt__
(other)[source]¶ Compare less-than operator of path and
Group
subclass to anotherGroupPath
object.
-
__module__
= 'aiida.tools.groups.paths'¶
-
__truediv__
(path)[source]¶ Return a child
GroupPath
, with a new path formed by appendingpath
to the current path.
-
__weakref__
¶ list of weak references to the object (if defined)
-
property
browse
¶ Return a
GroupAttr
instance, for attribute access to children.
-
property
children
¶ Iterate through all (direct) children of this path.
-
property
cls
¶ Return the cls used to query for and instantiate a
Group
with.
-
delete_group
()[source]¶ Delete the concrete group associated with this path.
- Raises
GroupNotFoundError, GroupNotUniqueError
-
property
delimiter
¶ Return the delimiter used to split path into components.
-
get_or_create_group
()[source]¶ Return the concrete group associated with this path or, create it, if it does not already exist.
-
property
group_ids
¶ Return all the UUID associated with this GroupPath.
- Returns
and empty list, if no group associated with this label, or can be multiple if cls was None
This is an efficient method for checking existence, which does not require the (slow) loading of the ORM entity.
-
property
is_virtual
¶ Return whether there is one or more concrete groups associated with this path.
-
property
key
¶ Return the final component of the the path.
-
property
parent
¶ Return the parent path.
-
property
path
¶ Return the path string.
-
property
path_list
¶ Return a list of the path components.
-
walk_nodes
(filters=None, node_class=None, query_batch=None)[source]¶ Recursively iterate through all nodes of this path and its children.
- Parameters
filters – filters to apply to the node query
node_class – return only nodes of a certain class (or list of classes)
batch_size (int) – The size of the batches to ask the backend to batch results in subcollections. You can optimize the speed of the query by tuning this parameter. Be aware though that is only safe if no commit will take place during this transaction.
-
-
exception
aiida.tools.groups.
InvalidPath
[source]¶ Bases:
Exception
An exception to indicate that a path is not valid.
-
__module__
= 'aiida.tools.groups.paths'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
exception
aiida.tools.groups.
GroupNotFoundError
(grouppath)[source]¶ Bases:
Exception
An exception raised when a path does not have an associated group.
-
__module__
= 'aiida.tools.groups.paths'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
exception
aiida.tools.groups.
GroupNotUniqueError
(grouppath)[source]¶ Bases:
Exception
An exception raised when a path has multiple associated groups.
-
__module__
= 'aiida.tools.groups.paths'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
exception
aiida.tools.groups.
NoGroupsInPathError
(grouppath)[source]¶ Bases:
Exception
An exception raised when a path has multiple associated groups.
-
__module__
= 'aiida.tools.groups.paths'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
Submodules¶
Provides functionality for managing large numbers of AiiDA Groups, via label delimitation.
-
class
aiida.tools.groups.paths.
GroupPath
(path='', cls=<class 'aiida.orm.groups.Group'>, warn_invalid_child=True)[source]¶ Bases:
object
A class to provide label delimited access to groups.
See tests for usage examples.
-
__dict__
= mappingproxy({'__module__': 'aiida.tools.groups.paths', '__doc__': 'A class to provide label delimited access to groups.\n\n See tests for usage examples.\n ', '__init__': <function GroupPath.__init__>, '_validate_path': <function GroupPath._validate_path>, '__repr__': <function GroupPath.__repr__>, '__eq__': <function GroupPath.__eq__>, '__lt__': <function GroupPath.__lt__>, 'path': <property object>, 'path_list': <property object>, 'key': <property object>, 'delimiter': <property object>, 'cls': <property object>, 'parent': <property object>, '__truediv__': <function GroupPath.__truediv__>, '__getitem__': <function GroupPath.__getitem__>, 'get_group': <function GroupPath.get_group>, 'group_ids': <property object>, 'is_virtual': <property object>, 'get_or_create_group': <function GroupPath.get_or_create_group>, 'delete_group': <function GroupPath.delete_group>, 'children': <property object>, '__iter__': <function GroupPath.__iter__>, '__len__': <function GroupPath.__len__>, '__contains__': <function GroupPath.__contains__>, 'walk': <function GroupPath.walk>, 'walk_nodes': <function GroupPath.walk_nodes>, 'browse': <property object>, '__dict__': <attribute '__dict__' of 'GroupPath' objects>, '__weakref__': <attribute '__weakref__' of 'GroupPath' objects>, '__hash__': None, '__gt__': <function _gt_from_lt>, '__le__': <function _le_from_lt>, '__ge__': <function _ge_from_lt>})¶
-
__ge__
(other, NotImplemented=NotImplemented)¶ Return a >= b. Computed by @total_ordering from (not a < b).
-
__getitem__
(path)[source]¶ Return a child
GroupPath
, with a new path formed by appendingpath
to the current path.
-
__gt__
(other, NotImplemented=NotImplemented)¶ Return a > b. Computed by @total_ordering from (not a < b) and (a != b).
-
__hash__
= None¶
-
__init__
(path='', cls=<class 'aiida.orm.groups.Group'>, warn_invalid_child=True)[source]¶ Instantiate the class.
- Parameters
path – The initial path of the group.
cls – The subclass of Group to operate on.
warn_invalid_child – Issue a warning, when iterating children, if a child path is invalid.
-
__le__
(other, NotImplemented=NotImplemented)¶ Return a <= b. Computed by @total_ordering from (a < b) or (a == b).
-
__lt__
(other)[source]¶ Compare less-than operator of path and
Group
subclass to anotherGroupPath
object.
-
__module__
= 'aiida.tools.groups.paths'¶
-
__truediv__
(path)[source]¶ Return a child
GroupPath
, with a new path formed by appendingpath
to the current path.
-
__weakref__
¶ list of weak references to the object (if defined)
-
property
browse
¶ Return a
GroupAttr
instance, for attribute access to children.
-
property
children
¶ Iterate through all (direct) children of this path.
-
property
cls
¶ Return the cls used to query for and instantiate a
Group
with.
-
delete_group
()[source]¶ Delete the concrete group associated with this path.
- Raises
GroupNotFoundError, GroupNotUniqueError
-
property
delimiter
¶ Return the delimiter used to split path into components.
-
get_or_create_group
()[source]¶ Return the concrete group associated with this path or, create it, if it does not already exist.
-
property
group_ids
¶ Return all the UUID associated with this GroupPath.
- Returns
and empty list, if no group associated with this label, or can be multiple if cls was None
This is an efficient method for checking existence, which does not require the (slow) loading of the ORM entity.
-
property
is_virtual
¶ Return whether there is one or more concrete groups associated with this path.
-
property
key
¶ Return the final component of the the path.
-
property
parent
¶ Return the parent path.
-
property
path
¶ Return the path string.
-
property
path_list
¶ Return a list of the path components.
-
walk_nodes
(filters=None, node_class=None, query_batch=None)[source]¶ Recursively iterate through all nodes of this path and its children.
- Parameters
filters – filters to apply to the node query
node_class – return only nodes of a certain class (or list of classes)
batch_size (int) – The size of the batches to ask the backend to batch results in subcollections. You can optimize the speed of the query by tuning this parameter. Be aware though that is only safe if no commit will take place during this transaction.
-
-
exception
aiida.tools.groups.paths.
InvalidPath
[source]¶ Bases:
Exception
An exception to indicate that a path is not valid.
-
__module__
= 'aiida.tools.groups.paths'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
exception
aiida.tools.groups.paths.
GroupNotFoundError
(grouppath)[source]¶ Bases:
Exception
An exception raised when a path does not have an associated group.
-
__module__
= 'aiida.tools.groups.paths'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
exception
aiida.tools.groups.paths.
GroupNotUniqueError
(grouppath)[source]¶ Bases:
Exception
An exception raised when a path has multiple associated groups.
-
__module__
= 'aiida.tools.groups.paths'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-