aiida.cmdline.utils.query package¶
Submodules¶
A utility module with a factory of standard QueryBuilder instances for Calculation nodes.
-
class
aiida.cmdline.utils.query.calculation.
CalculationQueryBuilder
(mapper=None)[source]¶ Bases:
object
Utility class to construct a QueryBuilder instance for Calculation nodes and project the query set.
-
__dict__
= mappingproxy({'__module__': 'aiida.cmdline.utils.query.calculation', '__doc__': 'Utility class to construct a QueryBuilder instance for Calculation nodes and project the query set.', '_compound_projections': ('state',), '_default_projections': ('pk', 'ctime', 'process_label', 'state', 'process_status'), '_valid_projections': ('pk', 'uuid', 'ctime', 'mtime', 'state', 'process_state', 'process_status', 'exit_status', 'sealed', 'process_label', 'label', 'description', 'node_type', 'paused', 'process_type', 'job_state', 'scheduler_state'), '__init__': <function CalculationQueryBuilder.__init__>, 'mapper': <property object>, 'default_projections': <aiida.common.lang.classproperty object>, 'valid_projections': <aiida.common.lang.classproperty object>, 'get_filters': <function CalculationQueryBuilder.get_filters>, 'get_query_set': <function CalculationQueryBuilder.get_query_set>, 'get_projected': <function CalculationQueryBuilder.get_projected>, '__dict__': <attribute '__dict__' of 'CalculationQueryBuilder' objects>, '__weakref__': <attribute '__weakref__' of 'CalculationQueryBuilder' objects>})¶
-
__module__
= 'aiida.cmdline.utils.query.calculation'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
_compound_projections
= ('state',)¶
-
_default_projections
= ('pk', 'ctime', 'process_label', 'state', 'process_status')¶
-
_valid_projections
= ('pk', 'uuid', 'ctime', 'mtime', 'state', 'process_state', 'process_status', 'exit_status', 'sealed', 'process_label', 'label', 'description', 'node_type', 'paused', 'process_type', 'job_state', 'scheduler_state')¶
-
default_projections
= ('pk', 'ctime', 'process_label', 'state', 'process_status')¶
-
get_filters
(all_entries=False, process_state=None, process_label=None, exit_status=None, failed=False, node_types=None)[source]¶ Return a set of QueryBuilder filters based on typical command line options.
- Parameters
node_types – a tuple of node classes to filter for (must be sub classes of Calculation)
all_entries – boolean to negate filtering for process state
process_state – filter for this process state attribute
process_label – filter for this process label attribute
exit_status – filter for this exit status
failed – boolean to filter only failed processes
- Returns
dictionary of filters suitable for a QueryBuilder.append() call
-
get_projected
(query_set, projections)[source]¶ Project the query set for the given set of projections
-
get_query_set
(relationships=None, filters=None, order_by=None, past_days=None, limit=None)[source]¶ Return the query set of calculations for the given filters and query parameters
- Parameters
relationships – a mapping of relationships to join on, e.g. {‘with_node’: Group} to join on a Group. The keys in this dictionary should be the keyword used in the append method of the QueryBuilder to join the entity on that is defined as the value.
filters – rules to filter query results with
order_by – order the query set by this criterion
past_days – only include entries from the last past days
limit – limit the query set to this number of entries
- Returns
the query set, a list of dictionaries
-
property
mapper
¶
-
valid_projections
= ('pk', 'uuid', 'ctime', 'mtime', 'state', 'process_state', 'process_status', 'exit_status', 'sealed', 'process_label', 'label', 'description', 'node_type', 'paused', 'process_type', 'job_state', 'scheduler_state')¶
-
A utility module with simple functions to format variables into strings for cli outputs.
-
aiida.cmdline.utils.query.formatting.
format_process_state
(process_state)[source]¶ Return a string formatted representation of the given process state
- Parameters
process_state – the process state
- Returns
string representation of process state
-
aiida.cmdline.utils.query.formatting.
format_relative_time
(datetime)[source]¶ Return a string formatted timedelta of the given datetime with respect to the current datetime
- Parameters
datetime – the datetime to format
- Returns
string representation of the relative time since the given datetime
-
aiida.cmdline.utils.query.formatting.
format_sealed
(sealed)[source]¶ Return a string formatted representation of a node’s sealed status
- Parameters
sealed – the value for the sealed attribute of the node
- Returns
string representation of seal status
-
aiida.cmdline.utils.query.formatting.
format_state
(process_state, paused=None, exit_status=None)[source]¶ Return a string formatted representation of a process’ state, which consists of its process state and exit status
- Parameters
process_state – the process state
exit_status – the process’ exit status
- Returns
string representation of the process’ state
A utility module with mapper objects that map database entities projections on attributes and labels.
-
class
aiida.cmdline.utils.query.mapping.
CalculationProjectionMapper
(projections, projection_labels=None, projection_attributes=None, projection_formatters=None)[source]¶ Bases:
aiida.cmdline.utils.query.mapping.ProjectionMapper
The CLI projection mapper for Calculation derived entities.
-
__init__
(projections, projection_labels=None, projection_attributes=None, projection_formatters=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
__module__
= 'aiida.cmdline.utils.query.mapping'¶
-
-
class
aiida.cmdline.utils.query.mapping.
ProjectionMapper
(projection_labels=None, projection_attributes=None, projection_formatters=None)[source]¶ Bases:
object
Class to map projection names from the CLI to entity labels, attributes and formatters.
The command line interface will often have to display database entities and their attributes. The names of the attributes exposed on the CLI do not always match one-to-one with the attributes in the ORM and often they need to be formatted for the screen in some way. Additionally, for commands that display lists of entries, often a header needs to be printed with a label for each attribute, which also are not necessarily identical.
For any given entity, the CLI typically exposes a set of projections, which are the keywords to reference certain attributes. This mapper class serves to map these projections onto the corresponding label and attribute names, as well as formatter functions to format the attribute values into strings, suitable to be printed by the CLI.
-
__dict__
= mappingproxy({'__module__': 'aiida.cmdline.utils.query.mapping', '__doc__': '\n Class to map projection names from the CLI to entity labels, attributes and formatters.\n\n The command line interface will often have to display database entities and their attributes. The names of\n the attributes exposed on the CLI do not always match one-to-one with the attributes in the ORM and often\n they need to be formatted for the screen in some way. Additionally, for commands that display lists of entries,\n often a header needs to be printed with a label for each attribute, which also are not necessarily identical.\n\n For any given entity, the CLI typically exposes a set of projections, which are the keywords to reference certain\n attributes. This mapper class serves to map these projections onto the corresponding label and attribute names, as\n well as formatter functions to format the attribute values into strings, suitable to be printed by the CLI.\n ', '_valid_projections': [], '__init__': <function ProjectionMapper.__init__>, 'valid_projections': <property object>, 'get_label': <function ProjectionMapper.get_label>, 'get_attribute': <function ProjectionMapper.get_attribute>, 'get_formatter': <function ProjectionMapper.get_formatter>, 'format': <function ProjectionMapper.format>, '__dict__': <attribute '__dict__' of 'ProjectionMapper' objects>, '__weakref__': <attribute '__weakref__' of 'ProjectionMapper' objects>})¶
-
__init__
(projection_labels=None, projection_attributes=None, projection_formatters=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
__module__
= 'aiida.cmdline.utils.query.mapping'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
_valid_projections
= []¶
-
property
valid_projections
¶
-