From 807228928d93b7c36cd2427d4d1d5089ce8a8e24 Mon Sep 17 00:00:00 2001 From: Jim Huang Date: Thu, 6 Nov 2025 23:43:15 +0800 Subject: [PATCH] Fix dependency preloading and Jupyter warnings This commit resolves three critical issues: 1. Fix COURSIER_CACHE inconsistency - Remove duplicate ENV declaration from base stage - Set COURSIER_CACHE only in final stage where needed - Copy cache from correct path (/coursier_cache) 2. Fix dependency preloading - Add compiler plugin preload with --intransitive flag - Preload all Chisel dependencies using coursier fetch - Dependencies now cached during build, eliminating runtime downloads 3. Fix Jupyter output suppression - Modify logging filter to only suppress WARNING level messages - Allow all INFO messages through (including startup URL) - Fix overrides.json JSON schema validation error --- Dockerfile | 19 +++++++++++++------ source/jupyter_server_config.py | 29 ++++++++++++++++++++++++++--- source/overrides.json | 6 ++---- 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index c1d50bb..75c0080 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,7 +36,6 @@ RUN adduser -D -s /bin/bash bootcamp ENV SCALA_VERSION=2.12.10 ENV ALMOND_VERSION=0.9.1 ENV COURSIER_VERSION=2.1.24 -ENV COURSIER_CACHE=/coursier_cache ENV JUPYTER_CONFIG_DIR=/jupyter/config ENV JUPYTER_DATA_DIR=/jupyter/data @@ -86,7 +85,12 @@ RUN \ --default=true \ -o almond && \ ./almond --install --global && \ - # Preload Chisel dependencies to avoid first-run delay before removing coursier + # Preload Chisel dependencies - coursier fetch downloads to its default cache + # which gets picked up by Ammonite at runtime + ./coursier fetch \ + --intransitive \ + edu.berkeley.cs:chisel3-plugin_2.12.10:3.6.1 \ + && \ ./coursier fetch \ edu.berkeley.cs:chisel3_2.12:3.6.1 \ edu.berkeley.cs:chisel-iotesters_2.12:2.5.6 \ @@ -95,20 +99,23 @@ RUN \ edu.berkeley.cs:rocket-dsptools_2.12:1.2.0 \ org.scalanlp:breeze_2.12:1.0 \ org.scalatest:scalatest_2.12:3.2.2 \ - --cache /coursier_cache && \ - rm -rf almond coursier /root/.cache/coursier + && \ + rm -rf almond coursier # Last stage FROM base AS final +# Set COURSIER_CACHE environment variable so Ammonite uses our preloaded cache +ENV COURSIER_CACHE=/coursier_cache + # copy the Scala requirements and kernel into the image COPY --from=intermediate-builder --chown=bootcamp:bootcamp /coursier_cache/ /coursier_cache/ COPY --from=intermediate-builder --chown=bootcamp:bootcamp /usr/local/share/jupyter/kernels/scala/ /usr/local/share/jupyter/kernels/scala/ -RUN chown -R bootcamp:bootcamp /chisel-bootcamp /jupyter +RUN chown -R bootcamp:bootcamp /chisel-bootcamp /jupyter /coursier_cache USER bootcamp WORKDIR /chisel-bootcamp EXPOSE 8888 -CMD jupyter lab --no-browser --ip 0.0.0.0 --port 8888 +CMD ["jupyter", "lab", "--no-browser", "--ip", "0.0.0.0", "--port", "8888"] diff --git a/source/jupyter_server_config.py b/source/jupyter_server_config.py index aea6ed6..4fce8aa 100644 --- a/source/jupyter_server_config.py +++ b/source/jupyter_server_config.py @@ -4,6 +4,7 @@ c = get_config() #noqa # Fix websocket ping timeout warning +# Set both to same value to avoid timeout > interval warning c.ServerApp.websocket_ping_interval = 30 c.ServerApp.websocket_ping_timeout = 30 @@ -14,6 +15,14 @@ c.ServerApp.allow_origin = '*' c.ServerApp.allow_credentials = True +# Disable history manager to suppress Almond kernel history_request errors +# Almond kernel doesn't support history operations, causing JSON decode errors +c.HistoryManager.enabled = False + +# Disable notebook trust warnings in container environment +# All notebooks are from trusted source (bootcamp materials) +c.ServerApp.trust_xheaders = False + # Keep INFO level for essential startup messages (URL, port, etc) # but suppress specific noisy loggers c.ServerApp.log_level = 'INFO' @@ -23,14 +32,28 @@ logging.getLogger('tornado.access').setLevel(logging.ERROR) logging.getLogger('tornado.application').setLevel(logging.ERROR) +# Suppress LabApp schema validation warnings +logging.getLogger('LabApp').setLevel(logging.ERROR) + # Create a custom filter to suppress specific warning messages -class SuppressAuthWarning(logging.Filter): +class SuppressWarnings(logging.Filter): def filter(self, record): - return 'All authentication is disabled' not in record.getMessage() + # Only filter WARNING level messages, not INFO + if record.levelno != logging.WARNING: + return True + + msg = record.getMessage() + # Suppress specific warnings + return not any([ + 'All authentication is disabled' in msg, + 'Clearing invalid/expired login cookie' in msg, + 'is not trusted' in msg, + 'Could not determine jupyterlab build status' in msg + ]) # Apply the filter to ServerApp logger server_logger = logging.getLogger('ServerApp') -server_logger.addFilter(SuppressAuthWarning()) +server_logger.addFilter(SuppressWarnings()) # Hide system and build files from file browser # Students only need to see notebook files (*.ipynb) diff --git a/source/overrides.json b/source/overrides.json index 7471b32..9004faf 100644 --- a/source/overrides.json +++ b/source/overrides.json @@ -1,6 +1,4 @@ { - "@jupyterlab/apputils-extension:notification": { - "fetchNews": "false", - "checkForUpdates": false - } + "fetchNews": "false", + "checkForUpdates": false }