Parameterization of Notebooks without using Papermill

Hello,

I am looking into the parameterization notebook viewer without the use of papermill entirely. The main goal is that I would like to have a set of parameters already listed in the notebook (similar to parameters cell), and without using papermill or any other package. I would like to run the notebook with new parameters and inject those to this new parameterized notebook all within the notebook viewer itself. Looking to see if there is anything out there in Jupyter, as I have not seen anything like this.

Had you seen this discussion?

The earlier version of it discussed above that post might interest you since you say you don’t want any other package needed. Or the one discussed here and demonstrated here.

Alternatively, since the notebook is just text-based json, you could write Python to parse your parameters listing cell and use the string.replace() method to substitute the text in the json file of your notebook. You can use nbconvert or jupytext to then run the modified notebook to have it rendered in final form.

Hi, thank you for linking that. It does seem it ties into something I would try to incorporate, but from my understanding, the user will still have to create the URI with the parameters and then extension itself will overwrite the cell for parameters. I am looking to see if there would be a way to inject new parameters (that the user defines) and then inject it into the URI, and not necessarily make the user have to define it.

Okay so moving on to a user interface to do what you first discussed…

If you code it correctly or guide the user through doing the steps via markdown documentation in your notebook, once the user defines the settings and pushes a button or runs the cell or triggers a script (whatever you set up), all the steps I describe could be done programmatically and then after the notebook is run you just make a link in markdown that they can click and the executed notebook opens. You could make it do just the generating if the URL or link or you could have it actually run the notebook with the injected parameters.

How fancy you make the user interface for it, is up to you. If you haven’t seen Voila, I’d suggest that. To see something along the lines of a Voila-backed interface in the notebook vs. pure app interface that lets user specify when they are ready to run code, go to https://github.com/fomightez/3Dscatter_plot-binder and click on launch binder. Once the session spins up, from the list of available demonstration notebooks, you’d select ’ 3D scatter plot using data in a file and Voila interface’. That will open a notebook version that is a little more detailed than the actual notebook version. You can see the app (‘streamlined’) version by going back to the list of demonstrations and selecting '‘streamlined 3D scatter plot in Voila interface’ or click the link in the explanation notebook. You’ll see it is the same code, you just use the URL to control whether it opens purely as an app, or as notebook that has widgets, too. How you ink to the app version in those examples is discussed here. It would be similar depending on where you deploy.

You, or others reading this exchange later, may also be interested in this discussion about a ‘control layer’. That seems to be sort of what you reply is about. In the linked case though they were using Papermill, but that point was tangential for most of that discussion.

1 Like