pipeline Module

pipeline Module

class panel.pipeline.Pipeline(stages=[], graph={}, **params)[source]

Bases: param.parameterized.Parameterized

A Pipeline represents a directed graph of stages, which each returns a panel object to render. A pipeline therefore represents a UI workflow of multiple linear or branching stages.

The Pipeline layout consists of a number of sub-components:

  • header:

    • title: The name of the current stage.

    • error: A field to display the error state.

    • network: A network diagram representing the pipeline.

    • buttons: All navigation buttons and selectors.

    • prev_button: The button to go to the previous stage.

    • prev_selector: The selector widget to select between previous branching stages.

    • next_button: The button to go to the previous stage

    • next_selector: The selector widget to select the next branching stages.

  • stage: The contents of the current pipeline stage.

By default any outputs of one stage annotated with the param.output decorator are fed into the next stage. Additionally, if the inherit_params parameter is set any parameters which are declared on both the previous and next stage are also inherited.

The stages are declared using the add_stage method and must each be given a unique name. By default any stages will simply be connected linearly, however an explicit graph can be declared using the define_graph method.

auto_advance = param.Boolean(bounds=(0, 1), default=False)

Whether to automatically advance if the ready parameter is True.

debug = param.Boolean(bounds=(0, 1), default=False)

Whether to raise errors, useful for debugging while building an application.

inherit_params = param.Boolean(bounds=(0, 1), default=True)

Whether parameters should be inherited between pipeline stages.

next_parameter = param.String()

Parameter name to watch to switch between different branching stages

ready_parameter = param.String()

Parameter name to watch to check whether a stage is ready.

show_header = param.Boolean(bounds=(0, 1), default=True)

Whether to show the header with the title, network diagram, and buttons.

next = param.Action()

previous = param.Action()

add_stage(name, stage, **kwargs)[source]

Adds a new, named stage to the Pipeline.

Parameters
  • name (str) – A string name for the Pipeline stage

  • stage (param.Parameterized) – A Parameterized object which represents the Pipeline stage.

  • **kwargs (dict) – Additional arguments declaring the behavior of the stage.

define_graph(graph, force=False)[source]

Declares a custom graph structure for the Pipeline overriding the default linear flow. The graph should be defined as an adjacency mapping.

Parameters

graph (dict) – Dictionary declaring the relationship between different pipeline stages. Should map from a single stage name to one or more stage names.

exception panel.pipeline.PipelineError[source]

Bases: RuntimeError

Custom error type which can be raised to display custom error message in a Pipeline.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

panel.pipeline.find_route(graph, current, target)[source]

Find a route to the target node from the current node.

panel.pipeline.get_root(graph)[source]

Search for the root not by finding nodes without inputs.

panel.pipeline.is_traversable(root, graph, stages)[source]

Check if the graph is fully traversable from the root node.

panel.pipeline.traverse(graph, v, visited)[source]

Traverse the graph from a node and mark visited vertices.