Voila: Specify (some) voila options through URL parameters

Created on 10 Apr 2019  路  13Comments  路  Source: voila-dashboards/voila

We could specify the template name through a URL parameter.

Feature Request

All 13 comments

(copypasted from a duplicated issue #299)

I've been getting a lot of questions from people asking how they can share Voila dashboards that can both remove the code and show the code depending on the notebook.

To follow up on this issue, it would be useful if one could pass options when Voila is being used as part of the Jupyter server (e.g. within Binder). Something like:

myhub.org/voila/pathtonotebook?parameter=value

and then this could control some of the behavior from within a running jupyter session. This could then be used to control whether code is hidden or not, e.g.:

myhub.org/voila/pathtonotebook?stripOutputs=true

or

myhub.org/voila/pathtonotebook?stripOutputs=false

That would definitely be useful indeed.

Perhaps there should also be a way to provide a spec of the options that can be controlled via the URL parameters (strip_sources, theme, template...) so that custom extensions can present the available values to the users.

These options could be requested from an endpoint (/options for instance) that could return something like this (inspired by the JupyterLab settings schema):

{
  "options": {
    "strip_sources": {
      "title": "Strip Sources",
      "description": "Show or hide input cells",
      "default": false,
      "type": "boolean"
    },
    "theme": {
      "title": "Theme",
      "description": "Theme",
      "default": "light",
      "enum": ["light", "dark"],
      "type": "string"
    },
    "template": {
      "title": "Template",
      "description": "Template name to be used by voila",
      "default": "default",
      "enum": ["default", "gridstack", "vuetify"],
      "type": "string"
    }
  }
}

Partially implemented by #414 and the other idea (parametrized templates) will be covered by #637

@jtpio @maartenbreddels as of today, is there a way to pass the equivalent of CLI option --strip_sources=False either in the URL as a query parameter or in the notebook metadata? Thanks!

No, but we could implement it similar to 3354ceb7c7b9bfc9ba12e89f87801c2424d10cdb but except with the default being 'NOTEBOOK' or 'NO' (for security)

No, but we could implement it similar to 3354ceb but except with the default being 'NOTEBOOK' or 'NO' (for security)

@maartenbreddels oh, yes, please!! I have a real-world use case for it, namely for sharing the slideshow (on Binder) that @cgusb and I presented at BIDS ImageXD 2021: https://github.com/cgusb/solidification-tracking

Why not on the command line btw? Why as a query parameter?

The command line is enough with a local setup, but I'm referring to the Jupyter server case (as @choldgraf pointed out in a previous comment). People clicking on our Binder badge can view, navigate, interact with the presentation (as you expect with a Voil脿 app) but, because the code isn't displayed, they miss out on the tutorial aspect of the presentation.

Is Binder actually picking up jupyter_config.json? Could it be that it's seeing:
https://github.com/maartenbreddels/voila-demo/blob/24afc749a3cffc91a555b200a9e39ef9d7bb9c7a/app.yaml#L5
?
I just forked your demo and I'm trying to run voila voila-vuetify.ipynb (without any CLI option) but it doesn't seem to pick up configuration from https://github.com/maartenbreddels/voila-demo/blob/master/jupyter_config.json :thinking:

https://github.com/maartenbreddels/voila-demo/blob/24afc749a3cffc91a555b200a9e39ef9d7bb9c7a/app.yaml#L5

that is for app engine I think.

voila voila-vuetify.ipynb

If you run voila standalone, rename the file to voila.json I think, but on mybinder it runs as a server extension. Hope that helps!

that is for app engine I think.

Right (since Binder infers or tries different things, e.g. requirements.txt vs environment.yml, I thought it could possibly parse and use whatever options are specified here and there).

but on mybinder it runs as a server extension.

Right, this is documented here: https://voila.readthedocs.io/en/stable/deploy.html?highlight=voila%20json#customizing-voila-on-binder

If you run voila standalone, rename the file to voila.json I think

It works indeed! Basically I was hitting this exact issue: https://github.com/voila-dashboards/voila/issues/826

Hope that helps!

For now, it definitely does, thank you so much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

choldgraf picture choldgraf  路  5Comments

johnjarmitage picture johnjarmitage  路  6Comments

mcornudella picture mcornudella  路  6Comments

Alexboiboi picture Alexboiboi  路  3Comments

laserman781 picture laserman781  路  3Comments