Pype¶
Pype class and supporting functions.
-
class
spype.core.pype.
Pype
(arg=None, name=None)[source]¶ Class to control the data flow between tasks.
Parameters: arg ( Union
[Task
,Wrap
,Pype
,str
,None
]) – A task, pype, or any hashable that has been registered as a pype. If hashable, a copy of the registered pype will be returned.-
add_callback
(callback, callback_type, tasks=None)[source]¶ Add a callback to all, or some, tasks in the pype. Return new Pype.
Parameters: - callback (<built-in function callable>) – The callable to attach to the tasks in the pype
- callback_type (
str
) –- The type of callback: supported types are:
- on_start, on_failure, on_success, and on_exception
- tasks (
Optional
[Sequence
[Task
]]) – A sequence of tasks to apply callback to, else apply to all tasks.
Returns: Return type: A copy of Pype
-
debug
(tasks=None, callback_type='on_start')[source]¶ Return of copy of Pype with debugging callbacks set.
Optionally, a list of tasks to set debug on can be defined to limit the breakpoints to only include those tasks. The callback where to debugger is called is also configurable.
Parameters: - tasks (
Optional
[Sequence
[Task
]]) – If not None a task or sequence of tasks to debug. If None debug all tasks. - callback_type – The callback to set debug function. Controls where in the execution cycle debugging tasks place
Returns: Return type: A copy of this pype.
- tasks (
-
iff
(predicate, inplace=False)[source]¶ Run data through the pype only if predicate evaluates to True.
Parameters: - predicate (
Callable
[[Any
],bool
]) – A callable that returns a boolean and takes the same inputs as the first task in the pype (excluding pype_input) - inplace – If True modify the pype in place, else return a pype with iff applied.
Returns: Return type: - predicate (
-
plot
(file_name=None, view=True)[source]¶ Plot the graph :type file_name:
Optional
[str
] :param file_name: The name of the graph viz file output. :type view:bool
:param view: If True display the graph network.Returns: Return type: Instance of graphviz.Digraph
-