Workflow Tasks Graph¶
- class cloudify.workflows.tasks_graph.TaskDependencyGraph(workflow_context)[source]¶
Bases: object
A task graph builder
Parameters: workflow_context – A WorkflowContext instance (used for logging) - get_task(task_id)[source]¶
Get a task instance that was inserted to this graph by its id
Parameters: task_id – the task id Returns: a WorkflowTask instance for the requested task if found. None, otherwise.
- add_dependency(src_task, dst_task)[source]¶
Add a dependency between tasks. The source task will only be executed after the target task terminates. A task may depend on several tasks, in which case it will only be executed after all its ‘destination’ tasks terminate
Parameters: - src_task – The source task
- dst_task – The target task
- execute()[source]¶
Start executing the graph based on tasks and dependencies between them. Calling this method will block until one of the following occurs:
- all tasks terminated
- a task failed
- an unhandled exception is raised
- the execution is cancelled
Note: This method will return None unless the execution has been cancelled, in which case the return value will be api.EXECUTION_CANCELLED_RESULT. Callers of this method should check the return value and propagate the result in the latter case.
Also note that for the time being, if such a cancelling event occurs, the method might return even while there’s some operations still being executed.
- class cloudify.workflows.tasks_graph.forkjoin(*tasks)[source]¶
Bases: object
A simple wrapper for tasks. Used in conjunction with TaskSequence. Defined to make the code easier to read (instead of passing a list) see TaskSequence.add for more details
- class cloudify.workflows.tasks_graph.TaskSequence(graph)[source]¶
Bases: object
Helper class to add tasks in a sequential manner to a task dependency graph
Parameters: graph – The TaskDependencyGraph instance - add(*tasks)[source]¶
Add tasks to the sequence.
Parameters: tasks – Each task might be:
- A WorkflowTask instance, in which case, it will be added to the graph with a dependency between it and the task previously inserted into the sequence
- A forkjoin of tasks, in which case it will be treated as a “fork-join” task in the sequence, i.e. all the fork-join tasks will depend on the last task in the sequence (could be fork join) and the next added task will depend on all tasks in this fork-join task