Skip to content

Commit 3d38adb

Browse files
committed
fix: Faster NBI LCConfigs for JLv3
Since our stacks now deploy notebook instances at JupyterLab v3, we should install labextensions via pip instead of the old CLI method. This substantially speeds up the NBI LCConfig run time, which was previously sometimes breaching the 5min limit.
1 parent 156c2f6 commit 3d38adb

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

.infrastructure/template.sam.yaml

+8-2
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,16 @@ Resources:
167167
#!/bin/bash
168168
set -e
169169

170-
# Install extension for ipywidgets interactivity:
170+
# Install extension for interactive canvas drawing:
171+
# ipywidgets is already present on al2-v2 NBIs. Pin versions to avoid reinstallations
171172
sudo -u ec2-user -i <<'EOF'
172173
source /home/ec2-user/anaconda3/bin/activate JupyterSystemEnv
173-
jupyter labextension install @jupyter-widgets/jupyterlab-manager ipycanvas
174+
JUPYTERSERVER_VER=`pip show jupyter-server | grep 'Version:' | sed 's/Version: //'`
175+
IPYWIDGETS_VER=`pip show ipywidgets | grep 'Version:' | sed 's/Version: //'`
176+
pip install \
177+
jupyter-server==$JUPYTERSERVER_VER \
178+
ipywidgets==$IPYWIDGETS_VER \
179+
ipycanvas
174180
source /home/ec2-user/anaconda3/bin/deactivate
175181
EOF
176182

.simple.cf.yaml

+9-3
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,23 @@ Resources:
3030
#!/bin/bash
3131
set -e
3232

33-
# Install extension for ipywidgets interactivity:
33+
# Install extension for interactive canvas drawing:
34+
# ipywidgets is already present on al2-v2 NBIs. Pin versions to avoid reinstallations
3435
sudo -u ec2-user -i <<'EOF'
3536
source /home/ec2-user/anaconda3/bin/activate JupyterSystemEnv
36-
jupyter labextension install @jupyter-widgets/jupyterlab-manager ipycanvas
37+
JUPYTERSERVER_VER=`pip show jupyter-server | grep 'Version:' | sed 's/Version: //'`
38+
IPYWIDGETS_VER=`pip show ipywidgets | grep 'Version:' | sed 's/Version: //'`
39+
pip install \
40+
jupyter-server==$JUPYTERSERVER_VER \
41+
ipywidgets==$IPYWIDGETS_VER \
42+
ipycanvas
3743
source /home/ec2-user/anaconda3/bin/deactivate
3844
EOF
3945

4046
NotebookInstance:
4147
Type: 'AWS::SageMaker::NotebookInstance'
4248
Properties:
43-
InstanceType: ml.t2.medium
49+
InstanceType: ml.t3.medium
4450
LifecycleConfigName: !GetAtt NotebookConfig.NotebookInstanceLifecycleConfigName
4551
# Otherwise it gets some garbage name by default:
4652
NotebookInstanceName: !Sub '${AWS::StackName}-Notebook'

0 commit comments

Comments
 (0)