Skip to content

Job

Warning

This class is superseded by pyslurm.Job and will be removed in a future release.

pyslurm.job

Slurm Job Information.

find(name='', val='') method descriptor

Search for a property and associated value in the retrieved job data.

Parameters:

Name Type Description Default
name str

key string to search

''
val str

value string to match

''

Returns:

Type Description
list

List of IDs that match

find_id(jobid) method descriptor

Retrieve job ID data.

This method accepts both string and integer formats of the jobid. This works for single jobs and job arrays. It uses the internal helper _load_single_job to do slurm_load_job. If the job corresponding to the jobid does not exist, a ValueError will be raised.

Parameters:

Name Type Description Default
jobid str

Job id key string to search

required

Returns:

Type Description
list

List of dictionary of values for given job id

find_user(user) method descriptor

Retrieve a user's job data.

This method calls slurm_load_job_user to get all job_table records associated with a specific user.

Parameters:

Name Type Description Default
user str

User string to search

required

Returns:

Type Description
dict

Dictionary of values for all user's jobs

get() method descriptor

Get all slurm jobs information.

This method calls slurm_load_jobs to get job_table records for all jobs

Returns:

Type Description
dict

Data where key is the job name, each entry contains a dictionary of job attributes

ids() method descriptor

Return the job IDs from retrieved data.

Returns:

Type Description
dict

Dictionary of job IDs

lastBackfill() method descriptor

Get the time (epoch seconds) of last backfilling run.

Returns:

Type Description
int

Epoch seconds

lastUpdate() method descriptor

Get the time (epoch seconds) the job data was updated.

Returns:

Type Description
int

Epoch seconds

print_job_info_msg(oneLiner=0) method descriptor

Print the data structure describing all job step records.

Parameters:

Name Type Description Default
oneLiner int

Whether to print the data in one line or not

0

slurm_job_batch_script(jobid) method descriptor

Return the contents of the batch-script for a Job.

The string returned also includes all the "\n" characters (new-line).

Parameters:

Name Type Description Default
jobid Union[str, int]

ID of the Job for which the script should be retrieved.

required

Returns:

Type Description
str

The content of the batch script.

submit_batch_job(job_opts) method descriptor

Submit batch job.

Make sure options match sbatch command line opts and not struct member names.

Parameters:

Name Type Description Default
job_opts dict

Job information.

required

Returns:

Type Description
int

The job id of the submitted job.

wait_finished(jobid) method descriptor

Block until the job given by the jobid finishes.

This works for single jobs, as well as job arrays.

Parameters:

Name Type Description Default
jobid int

The job id of the slurm job. To reference a job with job array set, use the first/"master" jobid (the same as given by squeue)

required

Returns:

Type Description
int

The exit code of the slurm job.