On this page

pipeline Module#

pipeline Module#

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

Bases: panel.viewable.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(bounds=(0, 1), default=False, label=’Auto advance’)

Whether to automatically advance if the ready parameter is True.

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

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

inherit_params = param.Boolean(bounds=(0, 1), default=True, label=’Inherit params’)

Whether parameters should be inherited between pipeline stages.

next_parameter = param.String(allow_None=True, label=’Next parameter’)

Parameter name to watch to switch between different branching stages

ready_parameter = param.String(allow_None=True, label=’Ready parameter’)

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

show_header = param.Boolean(bounds=(0, 1), default=True, label=’Show header’)

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

next = param.Action(label=’Next’)

previous = param.Action(label=’Previous’)

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) Viewer#

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'#

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 threading.Thread