toil.test.src.jobTest

Attributes

logger

Classes

JobTest

Tests the job class.

TrivialService

Abstract class used to define the interface to a service.

Functions

simpleJobFn(job, value)

fn1Test(string, outputFile)

Function appends the next character after the last character in the given

fn2Test(pStrings, s, outputFile)

Function concatenates the strings in pStrings and s, in that order, and writes the result to

trivialParent(job)

parent(job)

diamond(job)

child(job)

errorChild(job)

Module Contents

toil.test.src.jobTest.logger
class toil.test.src.jobTest.JobTest(methodName='runTest')[source]

Bases: toil.test.ToilTest

Tests the job class.

classmethod setUpClass()[source]

Hook method for setting up class fixture before running tests in the class.

testStatic()[source]

Create a DAG of jobs non-dynamically and run it. DAG is:

A -> F
\-------
B -> D  \
 \       \
  ------- C -> E

Follow on is marked by ->

testStatic2()[source]

Create a DAG of jobs non-dynamically and run it. DAG is:

A -> F
\-------
B -> D  \
 \       \
  ------- C -> E

Follow on is marked by ->

testTrivialDAGConsistency()[source]
testDAGConsistency()[source]
testSiblingDAGConsistency()[source]

Slightly more complex case. The stranded job’s predecessors are siblings instead of parent/child.

testDeadlockDetection()[source]

Randomly generate job graphs with various types of cycle in them and check they cause an exception properly. Also check that multiple roots causes a deadlock exception.

testNewCheckpointIsLeafVertexNonRootCase()[source]

Test for issue #1465: Detection of checkpoint jobs that are not leaf vertices identifies leaf vertices incorrectly

Test verification of new checkpoint jobs being leaf vertices, starting with the following baseline workflow:

Parent
  |
Child # Checkpoint=True
testNewCheckpointIsLeafVertexRootCase()[source]
Test for issue #1466: Detection of checkpoint jobs that are not leaf vertices

omits the workflow root job

Test verification of a new checkpoint job being leaf vertex, starting with a baseline workflow of a single, root job:

Root # Checkpoint=True
runNewCheckpointIsLeafVertexTest(createWorkflowFn)[source]

Test verification that a checkpoint job is a leaf vertex using both valid and invalid cases.

Parameters:

createWorkflowFn

function to create and new workflow and return a tuple of:

  1. the workflow root job

  2. a checkpoint job to test within the workflow

runCheckpointVertexTest(workflowRootJob, checkpointJob, checkpointJobService=None, checkpointJobChild=None, checkpointJobFollowOn=None, expectedException=None)[source]

Modifies the checkpoint job according to the given parameters then runs the workflow, checking for the expected exception, if any.

testEvaluatingRandomDAG()[source]

Randomly generate test input then check that the job graph can be run successfully, using the existence of promises to validate the run.

static getRandomEdge(nodeNumber)[source]
static makeRandomDAG(nodeNumber)[source]

Makes a random dag with “nodeNumber” nodes in which all nodes are connected. Return value is list of edges, each of form (a, b), where a and b are integers >= 0 < nodeNumber referring to nodes and the edge is from a to b.

static getAdjacencyList(nodeNumber, edges)[source]

Make adjacency list representation of edges

reachable(node, adjacencyList, followOnAdjacencyList=None)[source]

Find the set of nodes reachable from this node (including the node). Return is a set of integers.

addRandomFollowOnEdges(childAdjacencyList)[source]

Adds random follow on edges to the graph, represented as an adjacency list. The follow on edges are returned as a set and their augmented edges are added to the adjacency list.

makeJobGraph(nodeNumber, childEdges, followOnEdges, outPath, addServices=True)[source]

Converts a DAG into a job graph. childEdges and followOnEdges are the lists of child and followOn edges.

isAcyclic(adjacencyList)[source]

Returns true if there are any cycles in the graph, which is represented as an adjacency list.

toil.test.src.jobTest.simpleJobFn(job, value)[source]
toil.test.src.jobTest.fn1Test(string, outputFile)[source]

Function appends the next character after the last character in the given string to the string, writes the string to a file, and returns it. For example, if string is “AB”, we will write and return “ABC”.

toil.test.src.jobTest.fn2Test(pStrings, s, outputFile)[source]

Function concatenates the strings in pStrings and s, in that order, and writes the result to the output file. Returns s.

toil.test.src.jobTest.trivialParent(job)[source]
toil.test.src.jobTest.parent(job)[source]
toil.test.src.jobTest.diamond(job)[source]
toil.test.src.jobTest.child(job)[source]
toil.test.src.jobTest.errorChild(job)[source]
class toil.test.src.jobTest.TrivialService(message, *args, **kwargs)[source]

Bases: toil.job.Job.Service

Abstract class used to define the interface to a service.

Should be subclassed by the user to define services.

Is not executed as a job; runs within a ServiceHostJob.

message
start(job)[source]

Start the service.

Parameters:

job – The underlying host job that the service is being run in. Can be used to register deferred functions, or to access the fileStore for creating temporary files.

Returns:

An object describing how to access the service. The object must be pickleable and will be used by jobs to access the service (see toil.job.Job.addService()).

stop(job)[source]

Stops the service. Function can block until complete.

Parameters:

job – The underlying host job that the service is being run in. Can be used to register deferred functions, or to access the fileStore for creating temporary files.

check()[source]

Checks the service is still running.

Raises:

exceptions.RuntimeError – If the service failed, this will cause the service job to be labeled failed.

Returns:

True if the service is still running, else False. If False then the service job will be terminated, and considered a success. Important point: if the service job exits due to a failure, it should raise a RuntimeError, not return False!