Hi, i have a really anoying and yet pretty common (as it seems) issue with Interactive widgets and notebooks. I have two Widgets for which i want to run ALL the cells below ON CHANGE, and it works quite conveniently on my notebook using the following ‘hack’:
# re-runs all the cells below the current one using js.
display(Javascript('IPython.notebook.execute_cell_range
(IPython.notebook.get_selected_index()+1, IPython.notebook.ncells())'))
But the issue is that it does not work anymore, neither with voila nor with Jupyter Lab.
So my question is: How can i make a notebook which runs through voilà to rerun the cells below on widget value change ??
A workarround would be to wrap the concerned cells code inside functions in order to change the execution workflow, but that would be utterly stupid because results (tables, charts, etc) would then be displayed out of their markdown cells context…
It sounds like you made things work with a hack instead of learning and implementing the proper way to do what you’d like. It’s hard to advise you how to deal with your technical debt since you aren’t sharing your code. Plus, it sounds like it may be more than a few changes. I’d suggest looking at the Voila gallery and find an example similar to what you’d like to do and then refactor your code to match that. Or at least an example that has a some of the elements you’d like. ipywidgets has a lot of interactivity to connect changes. Since you mention markdown and plots, I can offer the example I have linked here that includes those two elements where I also refer to other resources used in development. Also I saw a really cool example related to content here, I think. This link launches one of them in Voila. If adjust the URL after launch so you replace voila/render/exp2_sim.ipynb
and everything after with tree, you can use the dashboard to see the code.
Potentially you could fix your issue with an extension in JupyterLab perhaps? This discussion looks pertinent.
A different, related issue: I’m not understanding why you are now concerned with Voila or JupyterLab? You can use the classic interface or specify your users use it?
Ok, let me be a bit more clear: What i want to achieve is a totally trivial use case but which does not seem to be handled properly in Jupyter: widgets interactivity + multi-cells workflows. Let’s consider the following notebook:
Now, whenever i change my customer and number of days backward, nothing gets recomputed automatically because all the workflow using the (customer, days_backward) variables couple is distributed across many code cells below, coming along with lots of important markdown anotations in between.
And FYI, i need voilà because i need to provide my users with a code-stripped version of the notebook and keep interactivity (hence the voila solution)