anaconda / nb_conda_kernels

Package for managing conda environment-based kernels inside of Jupyter
BSD 3-Clause "New" or "Revised" License
601 stars 70 forks source link

[Bug] wrong jupyter_config.json in /opt/conda/envs/jupyter-notebook/etc/jupyter/jupyter_config.json creating a lot of Warning #223

Closed tarrade closed 8 months ago

tarrade commented 1 year ago

when created an conda env using the latest version of Miniconda:

conda version : 22.11.1
python version : 3.10.8.final.0

I am using:

nb_conda_kernels 2.3.1 jupyter_server 2.0.5 jupyterlab 3.5.2 python 3.10.8

and it create the following file:

/opt/conda/envs/jupyter-notebook/etc/jupyter/jupyter_config.json

with the following content:

{
  "JupyterApp": {
    "kernel_spec_manager_class": "nb_conda_kernels.CondaKernelSpecManager"
  }
}

This file is created a lot of warning and I need to remove it manually every time I create an env to avoid a huge list of Warning

[W 2022-12-26 12:15:00.899 MathJaxExtension] Config option kernel_spec_manager_class not recognized by MathJaxExtension. [W 2022-12-26 12:15:00.900 MathJaxExtension] Config option kernel_spec_manager_class not recognized by MathJaxExtension. [W 2022-12-26 12:15:00.904 MathJaxExtension] Config option kernel_spec_manager_class not recognized by MathJaxExtension. [W 2022-12-26 12:15:00.909 LabApp] Config option kernel_spec_manager_class not recognized by LabApp. [W 2022-12-26 12:15:00.913 LabApp] Config option kernel_spec_manager_class not recognized by LabApp. [W 2022-12-26 12:15:00.920 LabApp] Config option kernel_spec_manager_class not recognized by LabApp. [W 2022-12-26 12:15:00.924 NotebookApp] Config option kernel_spec_manager_class not recognized by NotebookApp. [W 2022-12-26 12:15:00.927 NotebookApp] Config option kernel_spec_manager_class not recognized by NotebookApp. [W 2022-12-26 12:15:00.932 NotebookApp] Config option kernel_spec_manager_class not recognized by NotebookApp.

I am using the following configuration for jupyter lab:

c.ServerApp.kernel_spec_manager_class = (
    "nb_conda_kernels.manager.CondaKernelSpecManager"
)

I guess nb_conda_kernels is creating this filejupyter_config.json and since this package was not updated for quite some time this could be due to some recent update.

Thanks

tarrade commented 1 year ago

Any suggestion, comment on this ?

kevin-bates commented 1 year ago

Hi @tarrade. I believe this is due to the application reference of JupyterApp in the configuration file. JupyterApp is a common base class used by many Jupyter-based applications - most of which don't have a kernel_spec_manager_class configurable attribute. As a result, warnings are logged when applications (and extensions) that don't have kernel_spec_manager_class are loaded.

Since it appears you're trying to use this with Lab (via JupyterServer), try updating that configuration entry to reference ServerApp (which derives from JupyterApp) and you should see the warnings go away.

It seems like the installation of nb_conda_kernels that creates that configuration file entry needs to be cognizant of the specific "application class name" to use or add individual entries for each (e.g., one relative to ServerApp, another relative to NotebookApp, etc.).

tarrade commented 1 year ago

Hi @kevin-bates,

yes what you wrote is correct. By default it is working but triggering quite some warning that took me a while to understand. Removing the configuration file was the only way to remove the warning which is risky in a production setup.

I need to check if adding dependency on the version of jupyter_server/notebook could be an option.