Module for the CalcJob process and related utilities.
aiida.engine.processes.calcjobs.
CalcJob
Bases: aiida.engine.processes.process.Process
aiida.engine.processes.process.Process
Implementation of the CalcJob process.
__abstractmethods__
__annotations__
__init__
Construct a CalcJob instance.
Construct the instance only if it is a sub class of CalcJob, otherwise raise InvalidOperation.
See documentation of aiida.engine.Process.
aiida.engine.Process
__module__
_abc_impl
_node_class
alias of aiida.orm.nodes.process.calculation.calcjob.CalcJobNode
aiida.orm.nodes.process.calculation.calcjob.CalcJobNode
_spec
_spec_class
alias of aiida.engine.processes.process_spec.CalcJobProcessSpec
aiida.engine.processes.process_spec.CalcJobProcessSpec
define
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.
get_state_classes
A mapping of the State constants to the corresponding state class.
Overrides the waiting state with the Calcjob specific version.
link_label_retrieved
on_terminated
Cleanup the node by deleting the calulation job state.
Note
This has to be done before calling the super because that will seal the node after we cannot change it
options
Return the options of the metadata that were specified when this process instance was launched.
options dictionary
parse
Parse a retrieved job calculation.
This is called once it’s finished waiting for the calculation to be finished and the data has been retrieved.
retrieved_temporary_folder – The path to the temporary folder
parse_retrieved_output
Parse the retrieved data by calling the parser plugin if it was defined in the inputs.
parse_scheduler_output
Parse the output of the scheduler if that functionality has been implemented for the plugin.
prepare_for_submission
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
presubmit
Prepares the calculation folder with all inputs, ready to be copied to the cluster.
folder – a SandboxFolder that can be used to write calculation input files and the scheduling script.
the CalcInfo object containing the information needed by the daemon to handle operations.
run
Run the calculation job.
This means invoking the presubmit and storing the temporary folder in the node’s repository. Then we move the process in the Wait state, waiting for the UPLOAD transport task to be started.
the Stop command if a dry run, int if the process has an exit status, Wait command if the calcjob is to be uploaded
spec_options
aiida.engine.processes.calcjobs.calcjob.
Module containing utilities and classes relating to job calculations running on systems that require transport.
aiida.engine.processes.calcjobs.manager.
JobManager
Bases: object
object
A manager for CalcJob submitted to Computer instances.
Computer
When a calculation job is submitted to a Computer, it actually uses a specific AuthInfo, which is a computer configured for a User. The JobManager maintains a mapping of JobsList instances for each authinfo that has active calculation jobs. These jobslist instances are then responsible for bundling scheduler updates for all the jobs they maintain (i.e. that all share the same authinfo) and update their status.
AuthInfo
User
JobsList
As long as a Runner will create a single JobManager instance and use that for its lifetime, the guarantees made by the JobsList about respecting the minimum polling interval of the scheduler will be maintained. Note, however, that since each Runner will create its own job manager, these guarantees only hold per runner.
Runner
__dict__
Initialize self. See help(type(self)) for accurate signature.
__weakref__
list of weak references to the object (if defined)
get_jobs_list
Get or create a new JobLists instance for the given authinfo.
authinfo – the AuthInfo
a JobsList instance
request_job_info_update
Get a future that will resolve to information about a given job.
This is a context manager so that if the user leaves the context the request is automatically cancelled.
Manager of calculation jobs submitted with a specific AuthInfo, i.e. computer configured for a specific user.
This container of active calculation jobs is used to update their status periodically in batches, ensuring that even when a lot of jobs are running, the scheduler update command is not triggered for each job individually.
In addition, the Computer for which the AuthInfo is configured, can define a minimum polling interval. This class will guarantee that the time between update calls to the scheduler is larger or equal to that minimum interval.
Note that since each instance operates on a specific authinfo, the guarantees of batching scheduler update calls and the limiting of number of calls per unit time, through the minimum polling interval, is only applicable for jobs launched with that particular authinfo. If multiple authinfo instances with the same computer, have active jobs these limitations are not respected between them, since there is no communication between JobsList instances. See the JobManager for example usage.
Construct an instance for the given authinfo and transport queue.
authinfo – The authinfo used to check the jobs list
transport_queue – A transport queue
last_updated – initialize the last updated timestamp
_ensure_updating
Ensure that we are updating the job list from the remote resource.
This will automatically stop if there are no outstanding requests.
_get_jobs_from_scheduler
Get the current jobs list from the scheduler.
a mapping of job ids to JobInfo instances
JobInfo
_get_jobs_with_scheduler
Get all the jobs that are currently with scheduler.
the list of jobs with the scheduler
list
_get_next_update_delay
Calculate when we are next allowed to poll the scheduler.
This delay is calculated as the minimum polling interval defined by the authentication info for this instance, minus time elapsed since the last update.
delay (in seconds) after which the scheduler may be polled again
_has_job_state_changed
Return whether the states old and new are different.
_update_job_info
Update all of the job information objects.
This will set the futures for all pending update requests where the corresponding job has a new status compared to the last update.
_update_requests_outstanding
get_minimum_update_interval
Get the minimum interval that should be respected between updates of the list.
the minimum interval
last_updated
Get the timestamp of when the list was last updated as produced by time.time()
The last update point
logger
Return the logger configured for this instance.
the logger
Request job info about a job when the job next changes state.
If the job is not found in the jobs list at the update, the future will resolve to None.
job_id – job identifier
future that will resolve to a JobInfo object when the job changes state
Transport tasks for calculation jobs.
aiida.engine.processes.calcjobs.tasks.
PreSubmitException
Bases: Exception
Exception
Raise in the do_upload coroutine when an exception is raised in CalcJob.presubmit.
Waiting
Bases: plumpy.process_states.Waiting
plumpy.process_states.Waiting
The waiting state for the CalcJob process.
process – The process this state belongs to
_launch_task
Launch a coroutine as a task, making sure to make it interruptable.
execute
Override the execute coroutine of the base Waiting state.
interrupt
Interrupt the Waiting state by calling interrupt on the transport task InterruptableFuture.
load_instance_state
Return the Running state that will parse the CalcJob.
retrieved_temporary_folder – temporary folder used in retrieving that can be used during parsing.
process
The process
retrieve
Return the Waiting state that will retrieve the CalcJob.
stash
Return the Waiting state that will stash the CalcJob.
submit
Return the Waiting state that will submit the CalcJob.
update
Return the Waiting state that will update the CalcJob.
upload
Return the Waiting state that will upload the CalcJob.
task_kill_job
Transport task that will attempt to kill a job calculation.
The task will first request a transport from the queue. Once the transport is yielded, the relevant execmanager function is called, wrapped in the exponential_backoff_retry coroutine, which, in case of a caught exception, will retry after an interval that increases exponentially with the number of retries, for a maximum number of retries. If all retries fail, the task will raise a TransportTaskException
node – the node that represents the job calculation
transport_queue – the TransportQueue from which to request a Transport
cancellable – the cancelled flag that will be queried to determine whether the task was cancelled
TransportTaskException if after the maximum number of retries the transport task still excepted
task_retrieve_job
Transport task that will attempt to retrieve all files of a completed job calculation.
retrieved_temporary_folder – the absolute path to a directory to store files
task_stash_job
Transport task that will optionally stash files of a completed job calculation on the remote.
cancellable (aiida.engine.utils.InterruptableFuture) – the cancelled flag that will be queried to determine whether the task was cancelled
aiida.engine.utils.InterruptableFuture
Return if the tasks was successfully completed
task_submit_job
Transport task that will attempt to submit a job calculation.
task_update_job
Transport task that will attempt to update the scheduler status of the job calculation.
node (aiida.orm.nodes.process.calculation.calcjob.CalcJobNode) – the node that represents the job calculation
job_manager (aiida.engine.processes.calcjobs.manager.JobManager) – The job manager
aiida.engine.processes.calcjobs.manager.JobManager
cancellable (aiida.engine.utils.InterruptableFuture) – A cancel flag
True if the tasks was successfully completed, False otherwise
task_upload_job
Transport task that will attempt to upload the files of a job calculation to the remote.
process – the job calculation