nb_conda_kernels icon indicating copy to clipboard operation
nb_conda_kernels copied to clipboard

Hiding conda environments

Open teoliphant opened this issue 6 years ago • 4 comments

Is there a way to hide conda environments so they are not visible or discoverable via the notebook?

A common practice is to setup one or more base conda environment and then expose other environments. It is desired to hide these base conda environments from users of the nb_conda_kernel extension. Is this possible?

teoliphant avatar Jul 30 '19 14:07 teoliphant

I'd like to see if there is something like this as well. I like having conda environments for my users picked up, but I create the kernel specs manually for site provided kernels and when I do that they're duplicated. I'm looking into this for the time being

jbaksta avatar Oct 09 '19 22:10 jbaksta

Documentation says there is Regex env_filter:

Configuration This package introduces two additional configuration options: env_filter: Regex to filter environment path matching it. Default: None (i.e. no filter)

It should be possible to setup a negative Regex, but I don't know where this setting (env_filter) is supposed to be located and how to edit it, eh. Something like this (selects text with strawberry or green, but rejects text with poison even if there's strawberry with it): https://regex101.com/r/PKmouO/3/

Zireael avatar Nov 16 '19 23:11 Zireael

There's a mini-guide here how to stop nb_conda_kernels spam https://github.com/jupyterhub/jupyterhub/issues/715#issuecomment-463756411, but it doesn't work for me.

I see double kernels of everything:

image

Tried setting filter like so:

c.NotebookApp.kernel_spec_manager_class = 'nb_conda_kernels.CondaKernelSpecManager'
c.CondaKernelSpecManager.env_filter = '(?:.*root.*|.*base.*)'

How do I either filter out [conda env:root] kernels from the list, or disable nb_conda_kernels entirely? I build my image in Docker, nb_conda_kernels gets installed as a dependency and doing conda uninstall nb_conda_kernels causes conda do do hour+ long rebuild.

Zireael avatar Nov 19 '19 02:11 Zireael

@Zireael So I found what's needed a bit ago, but never updated this issue. Anyways, for me the issue is solved by basically specifying the file system paths where the kernels are stored. Also, this is done in the $JUPYTER_PREFIX/etc/jupyter/jupyter_notebook_config.json file. Mine looks like the following:

{
  "NotebookApp": {
    "kernel_spec_manager_class": "nb_conda_kernels.CondaKernelSpecManager"
  },
  "CondaKernelSpecManager": {
    "env_filter": "/ncar/usr/jupyterhub/*|/glade/u/ssg/*"
   }
}

And that negated any kernels that I store under the directory trees of /ncar/usr/jupyterhub or /glade/u/ssg/ and my duplicates are now gone, but conda environments still are picked up for my users so they don't need to write kernel specs.

jbaksta avatar Nov 19 '19 14:11 jbaksta

closing this one as stale; there is an env_filter but I wouldn't be surprised if it needs improving

mcg1969 avatar Mar 06 '24 23:03 mcg1969