voila-dashboards / voila

Voilà turns Jupyter notebooks into standalone web applications
https://voila.readthedocs.io
Other
5.31k stars 497 forks source link

voila.json file is not taken into account #1468

Closed djangoliv closed 1 month ago

djangoliv commented 1 month ago

The doc say: The easiest way to change these settings is to provide a file named voila.json in the same folder containing the notebooks.

But I notice that it is especially necessary to launch "voila" from the directory containing the voila.json file.

If you have the directory $HOME/app which contains index.ipynb and voila.json:

cd $HOME/app
voila index.ipynb   # works
cd /tmp
voila $HOME/app/index/ipynb  # doesn't work (the config file is not taken into account)

therefore the documentation is false. But, it would be better to correct the code so that the documentation becomes valid. Even better, an option to indicate where the configuration file is located at launch.

Regards

trungleduc commented 1 month ago

Thanks for reporting the issue. It's more of a documentation issue since the current behavior is consistent with other Jupyter applications. A PR fixing this is very welcome!

djangoliv commented 1 month ago

Thanks for your response @trungleduc .

I understand the point of view, but on the other hand I think it would really be better to consider the voila.json file if it is next to the notebook. It would allow

Here a screenshot with @voila-dashboards/jupyterlab-preview (the voila.json is not taken into account)

image

Here the voila launch in the directory (the voila.json is taken into account)

image

trungleduc commented 1 month ago

Hi @djangoliv, for the second point, I'm working on fixing https://github.com/voila-dashboards/voila/issues/1397 in https://github.com/voila-dashboards/voila/pull/1469 and supporting voila.json or voila.py in the preview extension is a by-product of this PR

djangoliv commented 1 month ago

ok thank you very much for these links and information.

But, in this case, we are going to read the configuration file which is located near the notebook ?

trungleduc commented 1 month ago

It will be the same behavior as voila, i.e. il will look for the config file in the current working directory and all jupyter paths

config_file_paths = [os.getcwd(), *jupyter_config_path()]
djangoliv commented 1 month ago

Thank you very much for all this time @trungleduc .

I still mention my use case which motivated me to open this issue to share.

I'm building a sort of app library. Several examples accessible from the same instance of jupyterlab (each example in its dedicated directory). Some of these examples depend on different templates (flex, voila-vuetify, ...) and/or different kernels.

Unfortunately, in the current state, I will not be able to keep a different configuration for each example in a simple way. I imagine I will have to overwrite the configuration file before running each example.

I will continue to look for a simple solution.

Regards

trungleduc commented 1 month ago

Both template and kernel can be set in the notebook's metadata, and voila will read the config in each notebook, e.g. https://voila.readthedocs.io/en/stable/customize.html#controlling-the-nbconvert-template