aiida.orm.calculation package

class aiida.orm.calculation.Calculation(**kwargs)[source]

Bases: aiida.orm.implementation.general.calculation.AbstractCalculation, aiida.orm.implementation.django.node.Node

__abstractmethods__ = frozenset([])
__module__ = 'aiida.orm.implementation.django.calculation'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 38
_abc_registry = <_weakrefset.WeakSet object>
_logger = <logging.Logger object>
_plugin_type_string = 'calculation.Calculation.'
_query_type_string = 'calculation.'
class aiida.orm.calculation.JobCalculation(**kwargs)[source]

Bases: aiida.orm.implementation.general.calculation.job.AbstractJobCalculation, aiida.orm.implementation.django.calculation.Calculation

__abstractmethods__ = frozenset([])
__module__ = 'aiida.orm.implementation.django.calculation.job'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 38
_abc_registry = <_weakrefset.WeakSet object>
classmethod _list_calculations_old(states=None, past_days=None, group=None, group_pk=None, all_users=False, pks=[], relative_ctime=True)[source]

Return a string with a description of the AiiDA calculations.

Todo

does not support the query for the IMPORTED state (since it checks the state in the Attributes, not in the DbCalcState table). Decide which is the correct logic and implement the correct query.

Parameters:
  • states – a list of string with states. If set, print only the calculations in the states “states”, otherwise shows all. Default = None.
  • past_days – If specified, show only calculations that were created in the given number of past days.
  • group – If specified, show only calculations belonging to a user-defined group with the given name. Can use colons to separate the group name from the type, as specified in aiida.orm.group.Group.get_from_string() method.
  • group_pk – If specified, show only calculations belonging to a user-defined group with the given PK.
  • pks – if specified, must be a list of integers, and only calculations within that list are shown. Otherwise, all calculations are shown. If specified, sets state to None and ignores the value of the past_days option.”)
  • relative_ctime – if true, prints the creation time relative from now. (like 2days ago). Default = True
  • all_users – if True, list calculation belonging to all users. Default = False
Returns:

a string with description of calculations.

_logger = <logging.Logger object>
_plugin_type_string = 'calculation.job.JobCalculation.'
_query_type_string = 'calculation.job.'
_set_state(state)[source]

Set the state of the calculation.

Set it in the DbCalcState to have also the uniqueness check. Moreover (except for the IMPORTED state) also store in the ‘state’ attribute, useful to know it also after importing, and for faster querying.

Todo

Add further checks to enforce that the states are set in order?

Parameters:state – a string with the state. This must be a valid string, from aiida.common.datastructures.calc_states.
Raise:ModificationNotAllowed if the given state was already set.
get_state(from_attribute=False)[source]

Get the state of the calculation.

Note

this method returns the NOTFOUND state if no state is found in the DB.

Note

the ‘most recent’ state is obtained using the logic in the aiida.common.datastructures.sort_states function.

Todo

Understand if the state returned when no state entry is found in the DB is the best choice.

Parameters:from_attribute – if set to True, read it from the attributes (the attribute is also set with set_state, unless the state is set to IMPORTED; in this way we can also see the state before storing).
Returns:a string. If from_attribute is True and no attribute is found, return None. If from_attribute is False and no entry is found in the DB, return the “NOTFOUND” state.
class aiida.orm.calculation.InlineCalculation(**kwargs)[source]

Bases: aiida.orm.implementation.django.calculation.Calculation

Subclass used for calculations that are automatically generated using the make_inline wrapper/decorator.

This is used to automatically create a calculation node for a simple calculation

__abstractmethods__ = frozenset([])
__module__ = 'aiida.orm.implementation.general.calculation.inline'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 38
_abc_registry = <_weakrefset.WeakSet object>
_cacheable = True
_logger = <logging.Logger object>
_plugin_type_string = 'calculation.inline.InlineCalculation.'
_query_type_string = 'calculation.inline.'
get_desc()[source]

Returns a string with infos retrieved from a InlineCalculation node’s properties. :return: description string

get_function_name()[source]

Get the function name.

Returns:a string
has_failed()[source]

Returns whether the Calculation has failed.

has_finished_ok()[source]

Returns whether the Calculation has finished successfully.

aiida.orm.calculation.make_inline(func)[source]

Submodules

aiida.orm.calculation.inline.optional_inline(func)[source]

optional_inline wrapper/decorator takes a function, which can be called either as wrapped in InlineCalculation or a simple function, depending on ‘store’ keyworded argument (True stands for InlineCalculation, False for simple function). The wrapped function has to adhere to the requirements by make_inline wrapper/decorator.

Usage example:

@optional_inline
def copy_inline(source=None):
  return {'copy': source.copy()}

Function copy_inline will be wrapped in InlineCalculation when invoked in following way:

copy_inline(source=node,store=True)

while it will be called as a simple function when invoked:

copy_inline(source=node)

In any way the copy_inline will return the same results.