diff --git a/.gitignore b/.gitignore index c7b06dfe..5e76afbf 100644 --- a/.gitignore +++ b/.gitignore @@ -79,7 +79,6 @@ target/ # IPython profile_default/ -ipython_config.py # pyenv .python-version diff --git a/Dockerfile b/Dockerfile index f9ebfe0b..ed72ac0e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,11 +26,11 @@ RUN mamba env update -n base -f /tmp/environment.yml && \ pip uninstall -y torch torchvision && \ # Install PyTorch packages without cache - conditionally based on variant if [ "$PYTORCH_VARIANT" = "cpu" ]; then \ - echo "Installing CPU-only PyTorch" && \ - pip install --no-cache-dir --force-reinstall torch torchvision --index-url https://download.pytorch.org/whl/cpu; \ + echo "Installing CPU-only PyTorch" && \ + pip install --no-cache-dir --force-reinstall torch torchvision --index-url https://download.pytorch.org/whl/cpu; \ else \ - echo "Installing CUDA-enabled PyTorch" && \ - pip install --no-cache-dir --force-reinstall torch torchvision; \ + echo "Installing CUDA-enabled PyTorch" && \ + pip install --no-cache-dir --force-reinstall torch torchvision; \ fi && \ # Clean up all package caches to reduce image size mamba clean --all -f -y && \ @@ -63,6 +63,17 @@ RUN apt-get update && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* +# System-wide Jupyter Server config +COPY docker/jupyter_server_config.py /opt/conda/etc/jupyter/ + +# Jupyter Lab settings +RUN mkdir -p /opt/conda/share/jupyter/lab/settings +COPY docker/overrides.json /opt/conda/share/jupyter/lab/settings/ + +# System-wide IPython profile config +RUN mkdir -p /opt/conda/etc/ipython +COPY docker/ipython_config.py /opt/conda/etc/ipython/ + # Switch back to the default notebook user USER ${NB_UID} @@ -72,9 +83,6 @@ COPY --from=builder ${CONDA_DIR} ${CONDA_DIR} # Copy home directory with configurations COPY --from=builder --chown=${NB_UID}:${NB_GID} /home/${NB_USER} /home/${NB_USER} -# Prepare IPython configuration -COPY --chown=${NB_UID}:${NB_GID} binder/ipython_config.py ${HOME}/.ipython/profile_default/ - # Set the working directory to user's home (repository will be cloned here by Renku) WORKDIR /home/${NB_USER} diff --git a/binder/ipython_config.py b/binder/ipython_config.py index a1e1b5f2..23616722 100644 --- a/binder/ipython_config.py +++ b/binder/ipython_config.py @@ -34,7 +34,9 @@ ## lines of code to run at IPython startup. # Default: [] -# c.InteractiveShellApp.exec_lines = [] +c.InteractiveShellApp.exec_lines = [ + "from typing import Any, Callable, Dict, List, Optional, Tuple, Union" +] ## A list of dotted module names of IPython extensions to load. # Default: [] diff --git a/docker/ipython_config.py b/docker/ipython_config.py new file mode 100644 index 00000000..387c234b --- /dev/null +++ b/docker/ipython_config.py @@ -0,0 +1,10 @@ +# Configuration file for ipython. +c = get_config() # noqa # type: ignore + +# Automatically load testsuite extension +c.InteractiveShellApp.extensions = ["tutorial.tests.testsuite"] + +# Automatically import some modules +c.InteractiveShellApp.exec_lines = [ + "from typing import Any, Callable, Dict, List, Optional, Tuple, Union" +] diff --git a/docker/jupyter_server_config.py b/docker/jupyter_server_config.py new file mode 100644 index 00000000..b6b30d14 --- /dev/null +++ b/docker/jupyter_server_config.py @@ -0,0 +1,6 @@ +# Configuration file for jupyter server. + +c = get_config() # noqa # type: ignore + +# Allow serving files/folders beginning with a dot +c.ContentsManager.allow_hidden = True diff --git a/docker/overrides.json b/docker/overrides.json new file mode 100644 index 00000000..244ba287 --- /dev/null +++ b/docker/overrides.json @@ -0,0 +1,5 @@ +{ + "@jupyterlab/filebrowser-extension:browser": { + "showHiddenFiles": true + } +}