Module for the CalcJob process and related utilities.
Implementation of the CalcJob process.
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.
alias of aiida.orm.nodes.process.calculation.calcjob.CalcJobNode
alias of aiida.engine.processes.process_spec.CalcJobProcessSpec
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
spec – the calculation job process spec to define.
A mapping of the State constants to the corresponding state class.
Overrides the waiting state with the Calcjob specific version.
Cleanup the node by deleting the calulation job state.
This has to be done before calling the super because that will seal the node after we cannot change it
Return the options of the metadata that were specified when this process instance was launched.
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 the retrieved data by calling the parser plugin if it was defined in the inputs.
Parse the output of the scheduler if that functionality has been implemented for the plugin.
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
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 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
Module containing utilities and classes relating to job calculations running on systems that require transport.
A manager for CalcJob submitted to Computer instances.
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.
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.
Initialize self. See help(type(self)) for accurate signature.
list of weak references to the object (if defined)
Get or create a new JobLists instance for the given authinfo.
authinfo – the AuthInfo
a JobsList instance
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 that we are updating the job list from the remote resource.
This will automatically stop if there are no outstanding requests.
Get the current jobs list from the scheduler.
a mapping of job ids to JobInfo instances
Get all the jobs that are currently with scheduler.
the list of jobs with the scheduler
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
Return whether the states old and new are different.
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.
Get the minimum interval that should be respected between updates of the list.
the minimum interval
Get the timestamp of when the list was last updated as produced by time.time()
The last update point
Return the logger configured for this instance.
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.
Raise in the do_upload coroutine when an exception is raised in CalcJob.presubmit.
The waiting state for the CalcJob process.
process – The process this state belongs to
Launch a coroutine as a task, making sure to make it interruptable.
Override the execute coroutine of the base Waiting state.
Interrupt the Waiting state by calling interrupt on the transport task InterruptableFuture.
Return the Running state that will parse the CalcJob.
retrieved_temporary_folder – temporary folder used in retrieving that can be used during parsing.
Return the Waiting state that will retrieve the CalcJob.
Return the Waiting state that will stash the CalcJob.
Return the Waiting state that will submit the CalcJob.
Return the Waiting state that will update the CalcJob.
Return the Waiting state that will upload the CalcJob.
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
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
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
Return if the tasks was successfully completed
Transport task that will attempt to submit a job calculation.
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
cancellable (aiida.engine.utils.InterruptableFuture) – A cancel flag
True if the tasks was successfully completed, False otherwise
Transport task that will attempt to upload the files of a job calculation to the remote.
process – the job calculation