Method to access query string in Voila notebook

I’m increasingly using Voila as a means to enable complex data analysis for a set of users at work. At the moment the typical interaction follows this path:

  • Capture a set of business identifiers from the user via IPython widgets
  • Load up a custom dataset based on those identifiers
  • Perform analysis as requested based on further user input (e.g. button presses)
    Ideally I would like to be able to bypass the first stage here by having identifiers passed into the Voila notebook as part of the URI. This would allow the notebook to ‘pre-populate’ based on calls from other related Voila notebooks, or even other systems.

In other web environments my go-to approach would be to embed the identifiers in the query string part of the URI. I’ve searched extensively for ways to access this information in a Voila context but I keep hitting dead ends. I’ve seen discussions of: parts of the URI being added to the environment variables (a bit like a CGI script), using “prelaunch hooks” to make the information available or using the javascript ‘kernel.execute’ method to pass the data back from the front end. None of these seem to work for me, for a variety of reasons - I’m guessing partly (or completely) to do with my own ignorance (for which I apologise).

Does anyone know of a reliable method of getting hold of the query string information in a Voila notebook? If so could you share some minimal code demonstrating how to make it work? I’d prefer something that works with ‘vanilla’ Voila but I can probably persuade my Jupyter sysadmin to help me out if server-side tweaks are required.

Many thanks

I don’t have specifics or what is the best current way to pass variables via the URI but I did come across these:

Thanks for the responses @fomightez - these links quickly lead me to conversations that I picked up in my prior research. That said the distinction between the spawner and the notebook is not one I had considered. Sorry to confess that I don’t know a huge amount about the spawner, but if that offered some route to feed the parameters into a notebook I’d be very happy to work with it as the starting point.

The picture that seems to be emerging is that there’s quite a bit of interest on the “notebook builder” side (i.e. others like me) to have this capability, and a decent amount of support from the Jupyter devs for this, but that no clear path has emerged to actually get it implemented. That might be a misreading of the dynamics of the discussions I have read - can anyone closer to it comment? I’m new to the community so trying to tread carefully!!

This looks to be code doing exactly what I want:

It needs Voila 0.2+.

1 Like