pipeline previous next button flow to previous after reaching end and going back one
ALL software version info
(this library, plus any other relevant software, e.g. bokeh, python, notebook, OS, browser, etc) panel 1.2.3
Description of expected behavior and the observed behavior
Click Next through a multistage pipeline, then click previous once reaching the end. Then previous again does not go to left one, it acts like next was pressed.
Complete, minimal, self-contained example code that reproduces the issue
# code goes here between backticks
import param
import panel as pn
pn.extension('katex')
pipeline = pn.pipeline.Pipeline()
class Stage1(param.Parameterized):
a = param.Integer(default=2, bounds=(0, 10))
b = param.Integer(default=3, bounds=(0, 10))
@param.output(('c', param.Integer), ('d', param.Integer))
def output(self):
return self.a * self.b, self.a ** self.b
@param.depends('a', 'b')
def view(self):
c, d = self.output()
c_out = pn.pane.LaTeX('${a} * {b} = {c}$'.format(
a=self.a, b=self.b, c=c), styles={'font-size': '2em'})
d_out = pn.pane.LaTeX('${a}^{{{b}}} = {d}$'.format(
a=self.a, b=self.b, d=d), styles={'font-size': '2em'})
return pn.Column(c_out, d_out, margin=(40, 10), styles={'background': '#f0f0f0'})
def panel(self):
return pn.Row(self.param, self.view,)
class Stage1B(param.Parameterized):
a = param.Integer()
@param.output(('c', param.Integer), ('d', param.Integer))
def output(self):
return self.a, 99
@param.depends('a')
def view(self):
c, d = self.output()
c_out = pn.pane.LaTeX('${a}$'.format(
a=self.a), styles={'font-size': '2em'})
d_out = pn.pane.LaTeX('${a} {d}$'.format(
a=self.a, d=d), styles={'font-size': '2em'})
return pn.Column(c_out, d_out, margin=(40, 10), styles={'background': '#f0f0f0'})
def panel(self):
return pn.Row(self.param, self.view,)
class Stage2(param.Parameterized):
c = param.Integer(default=6, bounds=(0, None))
exp = param.Number(default=0.1, bounds=(0, 3))
@param.depends('c', 'exp')
def view(self):
out = pn.pane.LaTeX('${%s}^{%s}={%.3f}$' % (self.c, self.exp, self.c**self.exp),
styles={'font-size': '2em'})
return pn.Column(out, margin=(40, 10), styles={'background': '#f0f0f0'})
def panel(self):
return pn.Row(self.param, self.view)
pipeline.add_stage('Stage 1', Stage1)
pipeline.add_stage('Stage1B', Stage1B)
pipeline.add_stage('Stage 2', Stage2)
pipeline.show()
Stack traceback and/or browser JavaScript console output
Screenshots or screencasts of the bug in action
- [ ] I may be interested in making a pull request to address this
I found that 2 stages work perfectly. However, here's the flow of what's happening: stage1 ->Next -> Stage 1B -> Next -> Stage2 (previous) ' (from previous)-'Stage 1B (previous) -> Stage2 (this is the unexpected behavior, and exceptions happening) ' (current stage )--------------------------'Stage2 (previous, go back show next line) ' (from previous) 'Stage 1B (previous) (shown next line stage1) stage 1 ->Next-> Stage 1B (No longer has previous option) -> Next -> Stage2 (No longer has previous option)
Once the unexpected behavior starts, it's also throwing exceptions from lower level code.
The Next button has more code handling in pipeline _next routine to handle ready_param and to then go to next stage. The Previous button does not look at ready_param, not sure if that's another issue, it also pops() from the route, so eventually going back twice from the very end isn't possible.
Thanks for the detailed writeup @ayoungs! Pipeline hasn't seen a lot of love since it was first added and it would be nice if we could clean it up a little bit. I'll schedule this for shortly after the 1.3.0 release.
I agree that this behaviour is a bit counter-intuitive. The expectation is that "Previous" will get you to the previous stage and "Next" to the next stage. It's not what happens, "Previous" will get you along the path you've followed.
Also like @ayoungs I've encountered exceptions when using these buttons.