aiida.calculations package#

Subpackages#

Submodules#

Generic CalcJob implementation where input file is a parametrized template file.

class aiida.calculations.templatereplacer.TemplatereplacerCalculation(*args: Any, **kwargs: Any)[源代码]#

基类:CalcJob

Simple stub of a plugin that can be used to replace some text in a given template. Can be used for many different codes, or as a starting point to develop a new plugin.

This simple plugin takes two node inputs, both of type Dict, with the labels ‘parameters’ and ‘template’

You can also add other SinglefileData nodes as input, that will be copied according to what is written in ‘template’ (see below).

  • parameters: a set of parameters that will be used for substitution.

  • template: can contain the following parameters:

    • input_file_template: a string with substitutions to be managed with the format() function of python, i.e. if you want to substitute a variable called ‘varname’, you write {varname} in the text. See http://www.python.org/dev/peps/pep-3101/ for more details. The replaced file will be the input file.

    • input_file_name: a string with the file name for the input. If it is not provided, no file will be created.

    • output_file_name: a string with the file name for the output. If it is not provided, no redirection will be done and the output will go in the scheduler output file.

    • cmdline_params: a list of strings, to be passed as command line parameters. Each one is substituted with the same rule of input_file_template. Optional

    • input_through_stdin: if True, the input file name is passed via stdin. Default is False if missing.

    • files_to_copy: if defined, a list of tuple pairs, with format (‘link_name’, ‘dest_rel_path’);

      for each tuple, an input link to this calculation is looked for, with link labeled ‘link_label’, and with file type ‘Singlefile’, and the content is copied to a remote file named ‘dest_rel_path’ Errors are raised in the input links are non-existent, or of the wrong type, or if there are unused input files.

    • retrieve_temporary_files: a list of relative filepaths, that if defined, will be retrieved and

      temporarily stored in an unstored FolderData node that will be available during the Parser.parser_with_retrieved call under the key specified by the Parser.retrieved_temporary_folder key

__abstractmethods__ = frozenset({})#
__annotations__ = {'CLASS_NAME': 'str', 'SINGLE_OUTPUT_LINKNAME': 'str', 'STATES': 'Optional[Sequence[Type[State]]]', '_STATES_MAP': 'Optional[Dict[Hashable, Type[State]]]', '__called': 'bool', '_auto_persist': 'Optional[Set[str]]', '_cleanups': 'Optional[List[Callable[[], None]]]', '_creation_time': 'Optional[float]', '_event_callbacks': 'Dict[Hashable, List[EVENT_CALLBACK_TYPE]]', '_interrupt_action': 'Optional[futures.CancellableAction]', '_killing': 'Optional[futures.CancellableAction]', '_node': 'Optional[orm.ProcessNode]', '_outputs': 'Dict[str, Any]', '_parsed_inputs': 'Optional[utils.AttributesFrozendict]', '_paused': 'Optional[persistence.SavableFuture]', '_pausing': 'Optional[futures.CancellableAction]', '_pre_paused_status': 'Optional[str]', '_state': 'Optional[State]', '_status': 'Optional[str]', '_uuid': 'Optional[uuid.UUID]', 'link_label_retrieved': 'str'}#
__module__ = 'aiida.calculations.templatereplacer'#
_abc_impl = <_abc._abc_data object>#
classmethod define(spec)[源代码]#

Define the process specification, including its inputs, outputs and known exit codes.

Ports are added to the metadata input namespace (inherited from the base Process), and a code input Port, a remote_folder output Port and retrieved folder output Port are added.

参数:

spec – the calculation job process spec to define.

prepare_for_submission(folder)[源代码]#

This is the routine to be called when you want to create the input files and related stuff with a plugin.

参数:

folder – a aiida.common.folders.Folder subclass where the plugin should put all its files.

Implementation of Transfer CalcJob.

class aiida.calculations.transfer.TransferCalculation(*args: Any, **kwargs: Any)[源代码]#

基类:CalcJob

Utility to copy files from different FolderData and RemoteData nodes into a single place.

The final destination for these files can be either the local repository (by creating a new FolderData node to store them) or in the remote computer (by leaving the files in a new remote folder saved in a RemoteData node).

Only files from the local computer and from remote folders in the same external computer can be moved at the same time with a single instance of this CalcJob.

The user needs to provide three inputs:

  • instructions: a dict node specifying which files to copy from which nodes.

  • source_nodes: a dict of nodes, each with a unique identifier label as its key.

  • metadata.computer: the computer that contains the remote files and will contain the final RemoteData node.

The instructions dict must have the retrieve_files flag. The CalcJob will create a new folder in the remote machine (RemoteData) and put all the files there and will either:

  1. leave them there (retrieve_files = False) or …

  2. retrieve all the files and store them locally in a FolderData (retrieve_files = True)

The instructions dict must also contain at least one list with specifications of which files to copy and from where. All these lists take tuples of 3 that have the following format:

( source_node_key, path_to_file_in_source, path_to_file_in_target)

where the source_node_key has to be the respective one used when providing the node in the source_nodes input nodes dictionary.

The two main lists to include are local_files (for files to be taken from FolderData nodes) and remote_files (for files to be taken from RemoteData nodes). Alternatively, files inside of RemoteData nodes can instead be put in the symlink_files list: the only difference is that files from the first list will be fully copied in the target RemoteData folder, whereas for the files in second list only a symlink to the original file will be created there. This will only affect the content of the final RemoteData target folder, but in both cases the full file will be copied back in the local target FolderData (if retrieve_files = True).

__abstractmethods__ = frozenset({})#
__annotations__ = {'CLASS_NAME': 'str', 'SINGLE_OUTPUT_LINKNAME': 'str', 'STATES': 'Optional[Sequence[Type[State]]]', '_STATES_MAP': 'Optional[Dict[Hashable, Type[State]]]', '__called': 'bool', '_auto_persist': 'Optional[Set[str]]', '_cleanups': 'Optional[List[Callable[[], None]]]', '_creation_time': 'Optional[float]', '_event_callbacks': 'Dict[Hashable, List[EVENT_CALLBACK_TYPE]]', '_interrupt_action': 'Optional[futures.CancellableAction]', '_killing': 'Optional[futures.CancellableAction]', '_node': 'Optional[orm.ProcessNode]', '_outputs': 'Dict[str, Any]', '_parsed_inputs': 'Optional[utils.AttributesFrozendict]', '_paused': 'Optional[persistence.SavableFuture]', '_pausing': 'Optional[futures.CancellableAction]', '_pre_paused_status': 'Optional[str]', '_state': 'Optional[State]', '_status': 'Optional[str]', '_uuid': 'Optional[uuid.UUID]', 'link_label_retrieved': 'str'}#
__module__ = 'aiida.calculations.transfer'#
_abc_impl = <_abc._abc_data object>#
classmethod define(spec)[源代码]#

Define the process specification, including its inputs, outputs and known exit codes.

Ports are added to the metadata input namespace (inherited from the base Process), and a code input Port, a remote_folder output Port and retrieved folder output Port are added.

参数:

spec – the calculation job process spec to define.

prepare_for_submission(folder)[源代码]#

Prepare the calculation for submission.

Convert the input nodes into the corresponding input files in the format that the code will expect. In addition, define and return a CalcInfo instance, which is a simple data structure that contains information for the engine, for example, on what files to copy to the remote machine, what files to retrieve once it has completed, specific scheduler settings and more.

参数:

folder – a temporary folder on the local file system.

返回:

the CalcInfo instance

aiida.calculations.transfer.check_node_type(list_name, node_label, node_object, node_type)[源代码]#

Common utility function to check the type of a node

aiida.calculations.transfer.validate_instructions(instructions, _)[源代码]#

Check that the instructions dict contains the necessary keywords

aiida.calculations.transfer.validate_transfer_inputs(inputs, _)[源代码]#

Check that the instructions dict and the source nodes are consistent