Skip to content

Commit

Permalink
Merge pull request #195 from consideRatio/conda-env-filter
Browse files Browse the repository at this point in the history
Let base-image recognize jupyter_notebook_config.py, and configure nb_conda_kernels to not register a kernel again
  • Loading branch information
scottyhq authored Mar 18, 2021
2 parents 55b6910 + c6a7e7a commit a1a014a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
12 changes: 11 additions & 1 deletion base-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ ENTRYPOINT ["/srv/start"]
# Only run these if used as a base image
# ----------------------
ONBUILD USER root
# hardcode for now
# FIXME (?): user and home folder is hardcoded for now
# FIXME (?): this line breaks the cache of all steps below
ONBUILD COPY --chown=jovyan:jovyan . /home/jovyan

ONBUILD RUN echo "Checking for 'binder' or '.binder' subfolder" \
Expand All @@ -82,6 +83,15 @@ ONBUILD RUN echo "Checking for 'apt.txt'..." \
&& rm -rf /var/lib/apt/lists/* \
; fi

# Copy jupyter_notebook_config.py to /etc/jupyter
ONBUILD RUN echo "Checking for 'jupyter_notebook_config.py'..." \
; [ -d binder ] && cd binder \
; [ -d .binder ] && cd .binder \
; if test -f "jupyter_notebook_config.py" ; then \
mkdir -p /etc/jupyter \
&& cp jupyter_notebook_config.py /etc/jupyter \
; fi

ONBUILD USER ${NB_USER}

# Create "notebook" conda environment and dask labextensions
Expand Down
5 changes: 5 additions & 0 deletions ml-notebook/jupyter_notebook_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import os

# Configure nb_conda_kernels to avoid registering jupyter kernels in our conda
# environment again.
c.CondaKernelSpecManager.env_filter = f'.*envs/{os.environ["CONDA_ENV"]}.*'
5 changes: 5 additions & 0 deletions pangeo-notebook/jupyter_notebook_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import os

# Configure nb_conda_kernels to avoid registering jupyter kernels in our conda
# environment again.
c.CondaKernelSpecManager.env_filter = f'.*envs/{os.environ["CONDA_ENV"]}.*'

0 comments on commit a1a014a

Please sign in to comment.