openforis / sepal

Geographical Data Processing in the Cloud
https://sepal.io/
MIT License
207 stars 46 forks source link

set the default kernels of notebook when they are pulled to SEPAL #154

Open 12rambau opened 2 years ago

12rambau commented 2 years ago

issue

Now that venvs are automatically sets in SEPAL based on their requirements.txt file, the SEPAL apps are easier to maintain as we are not bound to the SEPAL configuration in our modules. Saving us from compatibility issues with big libs such as tensorflow.

We are still facing one problem. The notebooks need to point to the apropriate kernel and by default it's Python3.

first try

A first solution would be to manually set the kernel in ui.ipynb (or any file we use as entry point) before pushing to release. This is prone to error and make the development process more complicated.

Setting a default virtual environment for the entrypoint that is only available in SEPAL prevent to use the apps outisde of the SEPAL environment which could make developer reluctant.

Also the SEPAL environment doesn't allow users to create custom kernel (nobody have the writing rights on /usr/) meaning that before the first release of an app, the kernel we are pointing to will simply not exist => As Jupyter is to smart for its own good the file will be automatically saved with Python3 as a default kernel.

suggestion

this file moitor and update the venv of the apps set in var/, meaning that it embeds the following information:

Would it be possible to automatically modify the entry point to change the default kernel on pull ?

.ipynb files are just json files so what we want to change is :

root["metadata"]["kernelspec"]["display_name"] = <display name of the created kernel>
root["metadata"]["kernelspec"]["name"] = <kernel_name>

I'm happy to make a PR if you agree with this idea and if you can share the scructure of the input file

dfguerrerom commented 2 years ago

I have manually set the entry point in my notebooks to make the modules work, but it's true that the notebooks will embed a portion of code that will cause issues if the env is not set. I think that managing this from sepal is a nice idea ;).