prisms_jobs.interface.torque¶
Misc functions for interfacing between torque and the prisms_jobs module
Functions
alter (jobid, arg) |
qalter a job. |
delete (jobid) |
qdel a PBS job. |
hold (jobid) |
qhold a job. |
job_id ([all, name]) |
Get job IDs |
job_rundir (jobid) |
Return the directory job was run in using qstat . |
job_status ([jobid]) |
Return job status using qstat |
read (job, qsubstr) |
Set Job object from string representing a PBS submit script. |
release (jobid) |
qrls a job. |
sub_string (job) |
Write Job as a string suitable for torque |
submit (substr[, write_submit_script]) |
Submit a job using qsub . |
-
prisms_jobs.interface.torque.
_getversion
()[source]¶ Returns the torque version as string or None if no
qstat
-
prisms_jobs.interface.torque.
_qstat
(jobid=None, username='bpuchala', full=False)[source]¶ Return the stdout of
qstat
minus the header lines.By default, ‘username’ is set to the current user. ‘full’ is the ‘-f’ option ‘jobid’ is a string or list of strings of job idsReturns: str – the text of qstat, minus the header lines
-
prisms_jobs.interface.torque.
alter
(jobid, arg)[source]¶ qalter
a job.Parameters: - jobid (str) – ID of job to alter
- arg (str) – ‘arg’ is a scontrol command option string. For instance, “-a 201403152300.19”
Returns: int –
qalter
returncode
-
prisms_jobs.interface.torque.
delete
(jobid)[source]¶ qdel
a PBS job.Parameters: jobid (str) – ID of job to delete Returns: int – qdel
returncode
-
prisms_jobs.interface.torque.
hold
(jobid)[source]¶ qhold
a job.Parameters: jobid (str) – ID of job to hold Returns: int – qhold
returncode
-
prisms_jobs.interface.torque.
job_id
(all=False, name=None)[source]¶ Get job IDs
Parameters: - all (bool) – If True, use
qstat
to query all user jobs. Else, check - environment variable for ID of current job. (PBS_JOBID) –
- name (str) – If all==True, use name to filter results.
Returns: One of str, List(str), or None – Returns a str if all==False and
PBS_JOBID
exists, a List(str) if all==True, else None.- all (bool) – If True, use
-
prisms_jobs.interface.torque.
job_rundir
(jobid)[source]¶ Return the directory job was run in using
qstat
.Parameters: jobid (str or List(str)) – IDs of jobs to get the run directory Returns: dict – A dict, with id:rundir pairs.
-
prisms_jobs.interface.torque.
job_status
(jobid=None)[source]¶ Return job status using
qstat
Parameters: jobid (None, str, or List(str)) – IDs of jobs to query for status. None for all user jobs. Returns: dict of dict – The outer dict uses jobid as key; the inner dict contains: ”name” Job name ”nodes” Number of nodes ”procs” Number of processors ”walltime” Walltime ”jobstatus” status (“Q”,”C”,”R”, etc.) ”qstatstr” result of squeue -f jobid
, None if not found”elapsedtime” None if not started, else seconds as int ”starttime” None if not started, else seconds since epoch as int ”completiontime” None if not completed, else seconds since epoch as int
-
prisms_jobs.interface.torque.
read
(job, qsubstr)[source]¶ Set Job object from string representing a PBS submit script.
- Will read many but not all valid PBS scripts.
- Will ignore any arguments not included in prisms_jobs.Job()’s attributes.
- Will add default optional arguments (i.e.
-A
,-a
,-l pmem=(.*)
,-l qos=(.*)
,-M
,-m
,-p
,"Auto:"
) if not found. - Will
exit()
if required arguments (-N
,-l walltime=(.*)
,-l nodes=(.*):ppn=(.*)
,-q
,cd $PBS_O_WORKDIR
) not found. - Will always include
-V
Parameters: qsubstr (str) – A submit script as a string
-
prisms_jobs.interface.torque.
release
(jobid)[source]¶ qrls
a job.Parameters: jobid (str) – ID of job to release Returns: int – qrls
returncode
-
prisms_jobs.interface.torque.
sub_string
(job)[source]¶ Write Job as a string suitable for torque
Parameters: job (prisms_jobs.Job instance) – Job to be submitted
-
prisms_jobs.interface.torque.
submit
(substr, write_submit_script=None)[source]¶ Submit a job using
qsub
.Parameters: - substr (str) – The submit script string
- write_submit_script (bool, optional) – If true, submit via file skipping
lines containing ‘#PBS -N’; otherwise, submit via commandline. If
not specified, uses
prisms_jobs.config['write_submit_script']
.
Returns: str – ID of submitted job
Raises: JobsError
– If a submission error occurs