The powerful data exploration & web app framework for Python.
—
Workflow pipeline system for building multi-step interactive applications with directed graph navigation. Enables complex multi-stage data processing workflows, wizards, and guided user experiences.
Core classes for defining and managing workflow pipelines with multiple stages and navigation.
class Pipeline:
"""
Directed graph of workflow stages for building multi-step applications.
A Pipeline represents a UI workflow of multiple linear or branching stages,
where each stage returns a Panel object to render.
Parameters:
- stages: Dictionary mapping stage names to stage functions or objects
- start: Name of the starting stage
- debug: Whether to show debugging information
- sizing_mode: How the pipeline should size itself
- **params: Additional parameters
Layout Components:
- header: Pipeline header with navigation controls
- title: Name of the current stage
- error: Error display field
- network: Network diagram of the pipeline graph
- buttons: Navigation buttons and selectors
- prev_button: Button to go to previous stage
- prev_selector: Selector for branching previous stages
- next_button: Button to go to next stage
- next_selector: Selector for branching next stages
"""
class PipelineError:
"""
Custom error type for displaying pipeline-specific error messages.
Raised within pipeline stages to display custom error messages
in the pipeline's error display area.
"""import panel as pn
def stage1():
return pn.Column(
"# Stage 1: Data Input",
pn.widgets.FileInput(accept='.csv'),
pn.widgets.Button(name="Next", button_type="primary")
)
def stage2():
return pn.Column(
"# Stage 2: Data Processing",
pn.pane.Markdown("Processing your data..."),
pn.widgets.Button(name="Next", button_type="primary")
)
def stage3():
return pn.Column(
"# Stage 3: Results",
pn.pane.Markdown("Your results are ready!"),
pn.widgets.Button(name="Download", button_type="success")
)
# Create linear pipeline
pipeline = pn.pipeline.Pipeline({
'input': stage1,
'process': stage2,
'results': stage3
}, start='input')
pipeline.servable()import panel as pn
def analysis_choice():
return pn.Column(
"# Choose Analysis Type",
pn.widgets.RadioButtonGroup(
name="Analysis",
options=['Statistical', 'Machine Learning', 'Visualization'],
value='Statistical'
)
)
def statistical_analysis():
return pn.pane.Markdown("# Statistical Analysis Results")
def ml_analysis():
return pn.pane.Markdown("# Machine Learning Results")
def visualization():
return pn.pane.Markdown("# Data Visualization")
# Create branching pipeline
pipeline = pn.pipeline.Pipeline({
'choice': (analysis_choice, ['stats', 'ml', 'viz']),
'stats': statistical_analysis,
'ml': ml_analysis,
'viz': visualization
}, start='choice')The pipeline system is essential for building complex multi-step applications, data processing workflows, configuration wizards, and any application requiring guided user experiences with branching logic.