cape.cfdx.queue: PBS and Slurm queue interface module

This module contains direct interface for functions like qsub and qstat. These methods provide an easy interface to command-line PBS utilities and also provide some access to the PBS information. For example, the method cape.queue.pqsub() writes a file "jobID.dat" with the PBS job number of the submitted job.

cape.cfdx.queue.pqjob(fname='jobID.dat')

Read the PBS job number from file

Call:
>>> pbs = cape.queue.pqjob()
>>> pbs = cape.queue.pqjob(fname="jobID.dat")
Inputs:
fname: str

Name of file to read containing PBS job number

Outputs:
pbs: int

PBS job ID number if possible or 0 if file could not be read

Versions:
  • 2014-12-27 @ddalle: First version

cape.cfdx.queue.pqsub(fname, fout='jobID.dat')

Submit a PBS script and save the job number in an fout file

Call:
>>> pbs = cape.queue.pqsub(fname, fout="jobID.dat")
Inputs:
fname: str

Name of PBS script to submit

fout: str

Name of output file to contain PBS job number

Outputs:
pbs: int or None

PBS job ID number if submission was successful

Versions:
  • 2014-10-06 @ddalle: Version 1.0

  • 2021-08-09 @ddalle: Version 1.1; allow non-int PBS IDs

cape.cfdx.queue.psbatch(fname, fout='jobID.dat')

Submit a PBS script and save the job number in an fout file

Call:
>>> pbs = cape.queue.psbatch(fname, fout="jobID.dat")
Inputs:
fname: str

Name of PBS script to submit

fout: str

Name of output file to contain PBS job number

Outputs:
pbs: int or None

PBS job ID number if submission was successful

Versions:
  • 2018-10-10 @ddalle: Version 1.0

  • 2021-08-09 @ddalle: Version 1.1; allow non-int job IDs

cape.cfdx.queue.qdel(jobID)

Delete a PBS job by number

Call:
>>> cape.queue.qdel(jobID)
Inputs:
pbs: int or list[int]

PBS job ID number if submission was successful

Versions:
  • 2014-12-26 @ddalle: First version

cape.cfdx.queue.qstat(u=None, J=None)

Call qstat and process information

Call:
>>> jobs = cape.queue.qstat(u=None)
>>> jobs = cape.queue.qstat(J=None)
Inputs:
u: str

User name, defaults to os.environ[USER]

J: int

Specific job ID for which to check

Outputs:
jobs: dict

Information on each job, jobs[jobID] for each submitted job

Versions:
  • 2014-10-06 @ddalle: First version

  • 2015-06-19 @ddalle: Added qstat -J option

cape.cfdx.queue.qsub(fname)

Submit a PBS script and return the job number

Call:
>>> pbs = cape.queue.qsub(fname)
Inputs:
fname: str

Name of PBS script to submit

Outputs:
pbs: int or None

PBS job ID number if submission was successful

Versions:
  • 2014-10-05 @ddalle: Version 1.0

  • 2021-08-09 @ddalle: Version 2.0
    • Support Python 3

    • Use full job ID (not just int) as a backup

cape.cfdx.queue.sbatch(fname)

Submit a Slurm script and return the job number

Call:
>>> pbs = cape.queue.sbatch(fname)
Inputs:
fname: str

Name of Slurm script to submit

Outputs:
pbs: int or None

Slurm job ID number if submission was successful

Versions:
  • 2014-10-05 @ddalle: First version

cape.cfdx.queue.scancel(jobID)

Delete a Slurm job by number

Call:
>>> cape.queue.scancel(jobID)
Inputs:
pbs: int or list[int]

PBS job ID number if submission was successful

Versions:
  • 2018-10-10 @ddalle: First version

cape.cfdx.queue.squeue(u=None, J=None)

Call qstat and process information

Call:
>>> jobs = cape.queue.squeue(u=None)
>>> jobs = cape.queue.squeue(J=None)
Inputs:
u: str

User name, defaults to os.environ[USER]

J: int

Specific job ID for which to check

Outputs:
jobs: dict

Information on each job, jobs[jobID] for each submitted job

Versions:
  • 2014-10-06 @ddalle: First version

  • 2015-06-19 @ddalle: Added qstat -J option