aiida.daemon package¶
Submodules¶
This file contains the main routines to submit, check and retrieve calculation results. These are general and contain only the main logic; where appropriate, the routines make reference to the suitable plugins for all plugin-specific operations.
-
aiida.daemon.execmanager.
retrieve_files_from_list
(calculation, transport, folder, retrieve_list)[source]¶ Retrieve all the files in the retrieve_list from the remote into the local folder instance through the transport. The entries in the retrieve_list can be of two types:
- a string
- a list
If it is a string, it represents the remote absolute filepath of the file. If the item is a list, the elements will correspond to the following:
- remotepath
- localpath
- depth
If the remotepath contains file patterns with wildcards, the localpath will be treated as the work directory of the folder and the depth integer determines upto what level of the original remotepath nesting the files will be copied.
Parameters: - transport – the Transport instance
- folder – a local Folder instance for the transport to store files into
- retrieve_list – the list of files to retrieve
-
aiida.daemon.execmanager.
submit_calc
(calc, authinfo, transport=None)[source]¶ Submit a calculation
Note: if no transport is passed, a new transport is opened and then closed within this function. If you want to use an already opened transport, pass it as further parameter. In this case, the transport has to be already open, and must coincide with the transport of the the computer defined by the authinfo.
Parameters: - calc – the calculation to submit (an instance of the aiida.orm.JobCalculation class)
- authinfo – the authinfo for this calculation.
- transport – if passed, must be an already opened transport. No checks are done on the consistency of the given transport with the transport of the computer defined in the authinfo.
-
aiida.daemon.execmanager.
submit_jobs_with_authinfo
(authinfo)[source]¶ Submit jobs in TOSUBMIT status belonging to user and machine as defined in the ‘dbauthinfo’ table.
-
aiida.daemon.execmanager.
update_jobs
()[source]¶ calls an update for each set of pairs (machine, aiidauser)
-
aiida.daemon.execmanager.
update_running_calcs_status
(authinfo)[source]¶ Update the states of calculations in WITHSCHEDULER status belonging to user and machine as defined in the ‘dbauthinfo’ table.
-
aiida.daemon.timestamps.
get_last_daemon_timestamp
(task_name, when='stop')[source]¶ Return the last time stored in the DB that the daemon executed the given task.
Parameters: - task_name – the task for which we want the information.
It has to be one of the keys of the
celery_tasks
dictionary. - when – can either be ‘start’ (to know when the task started) or ‘stop’ (to know when the task ended)
Returns: a datetime.datetime object. Return None if no information is found in the DB.
- task_name – the task for which we want the information.
It has to be one of the keys of the
-
aiida.daemon.timestamps.
get_most_recent_daemon_timestamp
()[source]¶ Try to detect any last timestamp left by the daemon, for instance to get a hint on whether the daemon is running or not.
Returns: a datetime.datetime object with the most recent time. Return None if no information is found in the DB.
-
aiida.daemon.timestamps.
set_daemon_timestamp
(task_name, when)[source]¶ Set in the DB the current time associated with the given task; this is used to store a timestamp to know when the daemon run for the last time.
Parameters: - task_name – the task for which we want to set the timestamp
It has to be one of the keys of the
aiida.backends.djsite.settings.settings.djcelery_tasks
dictionary. - when – can either be ‘start’ (to call when the task started) or ‘stop’ (to call when the task ended)
- task_name – the task for which we want to set the timestamp
It has to be one of the keys of the
-
aiida.daemon.workflowmanager.
advance_workflow
(w, step)[source]¶ The method tries to advance a step running its next method and handling possible errors.
If the method to advance is the Workflow
exit
method and there are no more steps RUNNING or in ERROR state then the workflow is set to FINISHED, otherwise an error is added to the report and the Workflow is flagged as ERROR.If the method is the
wf_default_call
this means the step had no next, and possibly is part of a branching. In this case the Workflow is not advanced but the method returns True to let the other steps kick in.Finally the methos tries to load the Workflow and execute the selected step, reporting the errors and the stack trace in the report in case of problems. Is no errors are reported the method returns True, in all the other cases the Workflow is set to ERROR state and the method returns False.
Parameters: - w – Workflow object to advance
- step – DbWorkflowStep to execute
Returns: True if the step has been executed, False otherwise
-
aiida.daemon.workflowmanager.
execute_steps
()[source]¶ This method loops on the RUNNING workflows and handled the execution of the steps until each workflow reaches an end (or gets stopped for errors).
In the loop for each RUNNING workflow the method loops also in each of its RUNNING steps, testing if all the calculation and subworkflows attached to the step are FINISHED. In this case the step is set as FINISHED and the workflow is advanced to the step’s next method present in the db with
advance_workflow
, otherwise if any step’s JobCalculation is found in NEW state the method will submit. If none of the previous conditions apply the step is flagged as ERROR and cannot proceed anymore, blocking the future execution of the step and, connected, the workflow.Finally, for each workflow the method tests if there are INITIALIZED steps to be launched, and in case reloads the workflow and execute the specific those steps. In case or error the step is flagged in ERROR state and the stack is reported in the workflow report.