netunicorn.base.pipeline.Pipeline¶
- class Pipeline(tasks=(), early_stopping=True, report_results=True, environment_definition=None)[source]¶
Bases:
ExecutionGraph
Pipeline is a class that takes a tuple of Tasks and executes them in order. Each element in the tuple should be either a Task or a tuple of Tasks. Pipeline will execute elements in order and return the combined result of all tasks. If element is a tuple of tasks, these tasks would be executed in parallel.
The result of pipeline execution would be one of the following:- Success: if all tasks succeed, then Success is returned- Failure: if any task fails, then Failure is returnedReturning object will always contain a Result object for each task executed.If early_stopping is set to True, then any task after first failed wouldn’t be executed.- Parameters:
tasks (
Collection
[Union
[Task
,TaskDispatcher
,Collection
[Union
[Task
,TaskDispatcher
]]]], default:()
) – tasks (ordered by stages) to be executedearly_stopping (
bool
, default:True
) – whether to stop executing tasks after first failurereport_results (
bool
, default:True
) – whether executor should connect core services to report pipeline results in the endenvironment_definition (
Optional
[EnvironmentDefinition
], default:None
) – environment definition for the pipeline
Attributes
Current last stage of the pipeline.
Execution Graph name.
Whether to stop executing tasks after a first failure.
Whether executor should connect core services to report execution results in the end.
Environment definition for the execution graph.
Graph of tasks and their order.
Disable graph validation.
Methods
Return a copy of the pipeline.
Draw execution graph using networkx library.
Validates execution graph according to the ExecutionGraph rules.
Add a task or list of tasks as a separate stage to the end of the pipeline.
- then(element)[source]¶
Add a task or list of tasks as a separate stage to the end of the pipeline.
- Parameters:
element (
Union
[Task
,TaskDispatcher
,Collection
[Union
[Task
,TaskDispatcher
]]]) – a task or tuple of tasks to be added- Returns:
Pipeline
– self
- draw(nx_layout_function=<function shell_layout>)[source]¶
Draw execution graph using networkx library.
- Parameters:
nx_layout_function (default:
<function shell_layout at 0x7fdfbd01c280>
) – networkx layout function to use for drawing (from networkx.drawing.layout)- Returns:
None
– None
- static is_execution_graph_valid(obj)[source]¶
Validates execution graph according to the ExecutionGraph rules.
- Returns:
bool
– True if execution graph is valid, raises an exception otherwise- Parameters:
obj (
ExecutionGraph
)
-
report_results:
bool
[source]¶ Whether executor should connect core services to report execution results in the end.
-
environment_definition:
EnvironmentDefinition
[source]¶ Environment definition for the execution graph.