pipeline Module#

pipeline Module#

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

Bases: Viewer

A Pipeline represents a directed graph of stages, which each return 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, but an explicit graph can be declared using the define_graph method.

auto_advance = param.Boolean(allow_refs=False, default=False, label=’Auto advance’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30023a950>)

Whether to automatically advance if the ready parameter is True.

debug = param.Boolean(allow_refs=False, default=False, label=’Debug’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30005e890>)

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

inherit_params = param.Boolean(allow_refs=False, default=True, label=’Inherit params’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30044c590>)

Whether parameters should be inherited between pipeline stages.

next_parameter = param.String(allow_None=True, allow_refs=False, label=’Next parameter’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30044c050>)

Parameter name to watch to switch between different branching stages

ready_parameter = param.String(allow_None=True, allow_refs=False, label=’Ready parameter’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30023bf50>)

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

show_header = param.Boolean(allow_refs=False, default=True, label=’Show header’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x300358d50>)

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

next = param.Action(allow_refs=False, label=’Next’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30023be50>)

previous = param.Action(allow_refs=False, label=’Previous’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x30044c050>)

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.

servable(title: Optional[str] = None, location: bool | 'Location' = True, area: str = 'main', target: Optional[str] = None) → Viewable[source]#

Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.

Parameters:
  • title (str) – A string title to give the Document (if served as an app)

  • location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.

  • area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.

  • target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.

Return type:

The Panel object itself

show(title: Optional[str] = None, port: int = 0, address: Optional[str] = None, websocket_origin: Optional[str] = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) → threading.Thread | 'Server'[source]#

Starts a Bokeh server and displays the Viewable in a new tab.

Parameters:
  • title (str | None) – A string title to give the Document (if served as an app)

  • port (int (optional, default=0)) – Allows specifying a specific port

  • address (str) – The address the server should listen on for HTTP requests.

  • websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.

  • threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.

  • verbose (boolean (optional, default=True)) – Whether to print the address and port

  • open (boolean (optional, default=True)) – Whether to open the server in a new browser tab

  • location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.

Returns:

server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

Return type:

bokeh.server.Server or panel.io.server.StoppableThread