pyjob.task module

class pyjob.task.ClusterTask(*args, **kwargs)[source]

Bases: pyjob.task.Task

Abstract base class for executable cluster tasks

close()[source]

Close this ClusterTask after completion

get_array_bash_extension(jobsf, offset)[source]

Get the array job bash extension for the runscript

Parameters:
  • jobsf (str) – The file containing all scripts on a per-line basis
  • offset (int) – The offset to be applied to the JOB_ARRAY_INDEX
Returns:

A list of lines to be written to the runscript

Return type:

list

Raises:
class pyjob.task.Task(script, *args, **kwargs)[source]

Bases: abc.ABC

Abstract base class for executable tasks

add_script(script)[source]

Add further scripts to this Task

Parameters:script (Script, str, list, tuple) – Something representing one or more scripts
close()[source]

Abstract method to end Task

completed

Boolean to indicate Task completion

static get_time(minutes)[source]

Return runtime string with format hh:mm:ss to be used in Task

Parameters:minutes (int) – Integer with the number of minutes to allocate to runtime
Raises:PyJobError – Argument is not a positive integer
info

Abstract property to provide info about the Task

kill()[source]

Abstract method to forcefully terminate Task

lock()[source]

Lock this Task

log

The log file path

run()[source]

Start the execution of this Task

Raises:
script

The script file path

wait(interval=30, monitor_f=None, success_f=None)[source]

Method to wait for the completion of the current Task

Parameters:
  • interval (int, optional) – The interval to wait between checking (in seconds)
  • monitor_f (callable, optional) – A callable that is regularly invoked
  • success_f (callable, optional) – A callable to check for early termination of Task

Note

The success_f argument needs to accept a log file as input and return a bool.