paws.core.workflows package

Submodules

paws.core.workflows.WfManager module

class paws.core.workflows.WfManager.WfManager(op_manager=None, plugin_manager=None)[source]

Bases: object

Manager for paws Workflows. Stores a list of Workflow objects, performs operations on them. Keeps a reference to a PluginManager for access to PawsPlugins.

add_workflow(wf_name)[source]

Name and add a workflow.

If wf_name is not unique (i.e. a workflow with that name already exists), this method will overwrite the existing workflow with a new one.

Parameters:wf_name (str) – name to give to the new Workflow
Returns:wf – a reference to the new Workflow
Return type:Workflow
load_workflow(wf_name, wf_setup_dict)[source]

Load a workflow from a dict that specifies its parameters.

If wf_name is not unique, self.workflows[wf_name] is overwritten.

Parameters:
  • wf_name (str) – name to be given to the new workflow
  • wf_setup_dict (dict) – dict specifying workflow setup
locate_input(il)[source]

Return the data pointed to by a given InputLocator object.

n_workflows()[source]

Return the current number of Workflows

prepare_wf(wf, stk)[source]

For all of the operations in stack stk, load all inputs that are not workflow items.

run_workflow(wf_name, pool=None)[source]

Execute the workflow indicated by wf_name

stop_workflow(wf_name)[source]

Stop the workflow indicated by wf_name

paws.core.workflows.Workflow module

class paws.core.workflows.Workflow.Workflow[source]

Bases: paws.core.models.TreeModel.TreeModel

Workflow built from paws Operations, with TreeModel interface.

This and other paws classes are TreeModels mostly for graphical considerations, where these (pure python) TreeModels can interface with gui-based tree views by adding a relatively thin adapter, such as paws.qt.QTreeModel.QTreeModel.

add_operation(op_name, op)[source]

Name and add an Operation to the Workflow.

If op_name is not unique, this existing Operation is overwritten.

Parameters:op_name (str) – name to give to the new Operation
break_input(wf_input_name)[source]
break_output(wf_output_name)[source]
build_clone()[source]

Produce a clone of this Workflow.

build_tree(x)[source]

Return a dict describing a tree-like structure of this object.

This is a reimplemention of TreeModel.build_tree() to define this object’s child tree structure. For a Workflow, a dict is provided for each Operation, where the operation dict contains the results of calling self.build_tree(op.inputs) and self.build_tree(op.outputs).

classmethod clone()[source]
connect_input(wf_input_name, op_input_uris)[source]
connect_output(wf_output_name, op_output_uris)[source]
disable_op(opname)[source]
enable_op(opname)[source]
execution_stack()[source]

Determine order of execution and diagnostics for the Workflow.

Returns a tuple (list,dict). For any Operation that is not ready to execute, the dict gives information as to why it is not ready.

Returns:
  • stk (list) – List of lists of Operation names, where each list contains Operations whose dependencies are satisfied by the Operations above them.
  • diag (dict) – Gives diagnostic information for any Operations not ready to run. Keys are operation names, values are diagnostic info (strings).
get_outputs()[source]
static get_valid_wf_inputs(op_name, op)[source]

Get all valid uris referring to Operation data.

Returns the TreeModel uris of the Operation, its inputs and outputs dicts, and each of the data items in the inputs and outputs dicts.

get_wf_input_value(wf_input_name)[source]
get_wf_output(wf_output_name)[source]

Get all outputs in self.outputs[wf_output_name].

is_op_enabled(opname)[source]
is_op_ready(op_name, valid_wf_inputs)[source]

self.execution_stack() uses this to check if an Operation is ready

load_operation(op_name, op_setup_dict, op_manager)[source]

Load an Operation from a dict that specifies its parameters.

If op_name is not unique, the Operation is overwritten.

Parameters:
  • op_name (str) – name to be given to the new Operation
  • op_setup_dict (dict) – dict specifying Operation setup
locate_input(il)[source]
n_operations()[source]
op_enable_flags()[source]
static print_stack(stk)[source]
remove_operation(op_name)[source]

Remove an Operation by providing its name as op_name.

run()[source]

Execute the Workflow.

All of the operations in the Workflow that are ready will be executed in the order obtained from self.execution_stack()

set_input(wf_input_name, val, tp=None)[source]

Set a value for all inputs in self.inputs[wf_input_name].

set_op_enabled(opname, flag=True)[source]
set_op_input(op_name, input_name, val, tp=None)[source]

Set up the Operation input at op_input_uri.

This changes op.input_locator indicated by op_input_uri to refer to the new value val and type tp. For basic and runtime input types, the value is also loaded directly into op.inputs. For runtime inputs, the value is not stored in the input_locator, and this is on purpose, to prevent serializing those objects later.

Parameters:
  • op_name (str) – name of the Operation
  • input_name (str) – name of the input
  • val (object) – any object to set as the Operation input value
  • tp (str or int, optional) – the input type determines how the Workflow interprets the input value. For example, the input can be set to another Operation output, to be found at ‘process.outputs.out1’, or simply be set to the string ‘process.outputs.out1’, depending on the specified type. Valid types are any string in paws.core.operations.Operation.input_types, or any integer in paws.core.operations.Operation.valid_types. If not provided, the type is left at its previous setting.
set_op_item(op_name, item_uri, item_data)[source]

Subroutine for use with functools.partial for callbacks

setup_dict()[source]

Return a dict that describes the Workflow setup.

static stack_contains(itm, stk)[source]
static stack_size(stk)[source]
stop()[source]

Stop the Workflow.

If any long-running Operations in the Workflow are written to examine their _stop_flag periodically, all execution should exit relatively soon.

Module contents

paws.core.workflows.load_workflows(path_, pkg, cat_root='')[source]