I’m building a branching pipeline and I’m seeing inconsistent behavior from the initial load and when I click on a network node. Am I setting something incorrectly or is this a bug?
Sample code and recipe below:
import param
import panel as pn
pn.extension()
class Start(param.Parameterized):
"""Initial start page for all workflows"""
stage_select = param.ObjectSelector(
default='New Project',
objects=['New Project', 'Existing Project'],
doc='selector to dictate the next page',
)
ready = param.Boolean(
default=True,
doc='trigger for moving to the next page',
)
button_width = param.Integer(
default=150,
bounds=(10, None),
doc='button width',
)
def on_click_new(self, event):
"""Callback for new project button"""
self.stage_select = 'New Project'
self.ready = True
def on_click_existing(self, event):
"""Callback for existing project button"""
self.stage_select = 'Existing Project'
self.ready = True
def panel(self):
"""Visualize this app"""
# construct new button and callback
new_button = pn.widgets.Button(
name='New Project',
width=self.button_width,
)
new_button.on_click(self.on_click_new)
# construct exist button and callback
existing_button = pn.widgets.Button(
name='Existing Project',
width=self.button_width,
)
existing_button.on_click(self.on_click_existing)
return pn.Column(
new_button,
existing_button,
)
class NewProject(param.Parameterized):
ready = param.Boolean(
default=True,
doc='trigger for moving to the next page',
)
def panel(self):
return pn.pane.Markdown('Placeholder Page')
class ExistingProject(param.Parameterized):
ready = param.Boolean(
default=True,
doc='trigger for moving to the next page',
)
def panel(self):
return pn.pane.Markdown('Placeholder Page')
def test_app():
"""Main application"""
# initialize an empty pipeline
dag = pn.pipeline.Pipeline()
# add the pages
dag.add_stage(
'Welcome',
Start,
ready_parameter='ready',
auto_advance=True,
next_parameter='stage_select',
)
dag.add_stage(
'New Project',
NewProject,
ready_parameter='ready',
auto_advance=True,
next_parameter='stage_select',
)
dag.add_stage(
'Existing Project',
ExistingProject,
ready_parameter='ready',
auto_advance=True,
)
# construct the network connectivity of pages
dag.define_graph(
{'Welcome': ('New Project', 'Existing Project'),
}
)
# display the app
return pn.Column(
dag.network,
dag.stage,
)
test_app()
Recipe:
- Load test_app
- Click on
Existing Project
- The app automatically moves toExisting Project
as it should - Click on the First network node to go back to the start page. Note that the Existing Project node is set with the ‘next’ state
- Click on the
New Project
button - this changes theNew Project
node state tonext
, but doesn’t automatically go there. To go there, now requires a second click on the button.
Basically, with the initial load, the auto_advance=True
allowed us to move to the Existing Project
page with a single click, but when you go back to the first node, the functionality changes and requires two clicks.
Panel 0.9.5