skbio.workflow.Workflow#

class skbio.workflow.Workflow(state, short_circuit=True, debug=False, options=None, **kwargs)[source]#

Arbitrary workflow support structure.

Methods that are considered to be directly part of the workflow must be decorated with method. The workflow methods offer a mechanism to logically group functionality together, and are free to make subsequent calls to other methods.

All methods of a subclass of Workflow (those with and without the method decoration) can take advantage of the requires decorator to specify any option or state requirements for the decorated function.

Parameters:
stateobject

State can be anything or nothing. This is dependent on the workflow as in some cases, it is useful to preallocate state while in other workflows state may be ignored.

short_circuitbool

if True, enables ignoring function methods when a given item has failed

debugbool

Enable debug mode

optionsdict

runtime options, {‘option’:values}, that the requires decorator can interrogate.

kwargsdict

Additional arguments will be added as member variables to self. This is handy if additional contextual information is needed by a workflow method (e.g., a lookup table).

Methods

initialize_state(item)

Initialize state.

Special methods

__call__(iter_[, success_callback, ...])

Operate on all the data.

Special methods (inherited)

__eq__(value, /)

Return self==value.

__ge__(value, /)

Return self>=value.

__getstate__(/)

Helper for pickle.

__gt__(value, /)

Return self>value.

__hash__(/)

Return hash(self).

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__ne__(value, /)

Return self!=value.

__str__(/)

Return str(self).

Details

__call__(iter_, success_callback=None, fail_callback=None)[source]#

Operate on all the data.

This is the processing engine of the workflow. Callbacks are executed following applying all workflow methods to an item from iter_ (unless short_cicruit=True in which case method execution for an item is stopped if failed=True). Callbacks are provided self which allows them to examine any aspect of the workflow.

Parameters:
iter_iterator

The iterator containing the data to be processed.

success_callbackmethod, optional

Method to call on a successful item prior to yielding. By default, self.state is yielded.

fail_callbackmethod, optional

Method to call on a failed item prior to yielding. By default, failures are ignored.