Skip to content

Commit eb0b8ee

Browse files
committed
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
1 parent a14b181 commit eb0b8ee

File tree

3 files changed

+44
-14
lines changed

3 files changed

+44
-14
lines changed

Dockerfile

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ RUN adduser -D -s /bin/bash bootcamp
3636
ENV SCALA_VERSION=2.12.10
3737
ENV ALMOND_VERSION=0.9.1
3838
ENV COURSIER_VERSION=2.1.24
39-
ENV COURSIER_CACHE=/coursier_cache
4039
ENV JUPYTER_CONFIG_DIR=/jupyter/config
4140
ENV JUPYTER_DATA_DIR=/jupyter/data
4241

@@ -47,7 +46,9 @@ RUN mkdir -p $JUPYTER_CONFIG_DIR/custom && \
4746
mkdir -p $JUPYTER_CONFIG_DIR/lab/user-settings/@jupyterlab/apputils-extension && \
4847
cp source/custom.js $JUPYTER_CONFIG_DIR/custom/ && \
4948
cp source/jupyter_server_config.py $JUPYTER_CONFIG_DIR/ && \
50-
cp source/overrides.json $JUPYTER_CONFIG_DIR/lab/user-settings/@jupyterlab/apputils-extension/notification.jupyterlab-settings
49+
cp source/overrides.json $JUPYTER_CONFIG_DIR/lab/user-settings/@jupyterlab/apputils-extension/notification.jupyterlab-settings && \
50+
cp source/jupyter-wrapper.sh /usr/local/bin/jupyter-wrapper && \
51+
chmod +x /usr/local/bin/jupyter-wrapper
5152

5253
# Second stage - download Scala requirements and the Scala kernel
5354
FROM base AS intermediate-builder
@@ -86,7 +87,12 @@ RUN \
8687
--default=true \
8788
-o almond && \
8889
./almond --install --global && \
89-
# Preload Chisel dependencies to avoid first-run delay before removing coursier
90+
# Preload Chisel dependencies - coursier fetch downloads to its default cache
91+
# which gets picked up by Ammonite at runtime
92+
./coursier fetch \
93+
--intransitive \
94+
edu.berkeley.cs:chisel3-plugin_2.12.10:3.6.1 \
95+
&& \
9096
./coursier fetch \
9197
edu.berkeley.cs:chisel3_2.12:3.6.1 \
9298
edu.berkeley.cs:chisel-iotesters_2.12:2.5.6 \
@@ -95,20 +101,23 @@ RUN \
95101
edu.berkeley.cs:rocket-dsptools_2.12:1.2.0 \
96102
org.scalanlp:breeze_2.12:1.0 \
97103
org.scalatest:scalatest_2.12:3.2.2 \
98-
--cache /coursier_cache && \
99-
rm -rf almond coursier /root/.cache/coursier
104+
&& \
105+
rm -rf almond coursier
100106

101107
# Last stage
102108
FROM base AS final
103109

110+
# Set COURSIER_CACHE environment variable so Ammonite uses our preloaded cache
111+
ENV COURSIER_CACHE=/coursier_cache
112+
104113
# copy the Scala requirements and kernel into the image
105114
COPY --from=intermediate-builder --chown=bootcamp:bootcamp /coursier_cache/ /coursier_cache/
106115
COPY --from=intermediate-builder --chown=bootcamp:bootcamp /usr/local/share/jupyter/kernels/scala/ /usr/local/share/jupyter/kernels/scala/
107116

108-
RUN chown -R bootcamp:bootcamp /chisel-bootcamp /jupyter
117+
RUN chown -R bootcamp:bootcamp /chisel-bootcamp /jupyter /coursier_cache
109118

110119
USER bootcamp
111120
WORKDIR /chisel-bootcamp
112121

113122
EXPOSE 8888
114-
CMD jupyter lab --no-browser --ip 0.0.0.0 --port 8888
123+
CMD ["jupyter", "lab", "--no-browser", "--ip", "0.0.0.0", "--port", "8888"]

source/jupyter_server_config.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
c = get_config() #noqa
55

66
# Fix websocket ping timeout warning
7+
# Set both to same value to avoid timeout > interval warning
78
c.ServerApp.websocket_ping_interval = 30
89
c.ServerApp.websocket_ping_timeout = 30
910

@@ -14,6 +15,14 @@
1415
c.ServerApp.allow_origin = '*'
1516
c.ServerApp.allow_credentials = True
1617

18+
# Disable history manager to suppress Almond kernel history_request errors
19+
# Almond kernel doesn't support history operations, causing JSON decode errors
20+
c.HistoryManager.enabled = False
21+
22+
# Disable notebook trust warnings in container environment
23+
# All notebooks are from trusted source (bootcamp materials)
24+
c.ServerApp.trust_xheaders = False
25+
1726
# Keep INFO level for essential startup messages (URL, port, etc)
1827
# but suppress specific noisy loggers
1928
c.ServerApp.log_level = 'INFO'
@@ -23,14 +32,28 @@
2332
logging.getLogger('tornado.access').setLevel(logging.ERROR)
2433
logging.getLogger('tornado.application').setLevel(logging.ERROR)
2534

35+
# Suppress LabApp schema validation warnings
36+
logging.getLogger('LabApp').setLevel(logging.ERROR)
37+
2638
# Create a custom filter to suppress specific warning messages
27-
class SuppressAuthWarning(logging.Filter):
39+
class SuppressWarnings(logging.Filter):
2840
def filter(self, record):
29-
return 'All authentication is disabled' not in record.getMessage()
41+
# Only filter WARNING level messages, not INFO
42+
if record.levelno != logging.WARNING:
43+
return True
44+
45+
msg = record.getMessage()
46+
# Suppress specific warnings
47+
return not any([
48+
'All authentication is disabled' in msg,
49+
'Clearing invalid/expired login cookie' in msg,
50+
'is not trusted' in msg,
51+
'Could not determine jupyterlab build status' in msg
52+
])
3053

3154
# Apply the filter to ServerApp logger
3255
server_logger = logging.getLogger('ServerApp')
33-
server_logger.addFilter(SuppressAuthWarning())
56+
server_logger.addFilter(SuppressWarnings())
3457

3558
# Hide system and build files from file browser
3659
# Students only need to see notebook files (*.ipynb)

source/overrides.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
2-
"@jupyterlab/apputils-extension:notification": {
3-
"fetchNews": "false",
4-
"checkForUpdates": false
5-
}
2+
"fetchNews": "false",
3+
"checkForUpdates": false
64
}

0 commit comments

Comments
 (0)