Skip to content

Commit a9ef779

Browse files
authored
Merge pull request #26 from absynthe/main
Created a script for disabling automatic start of notebook kernels
2 parents 3e6b81e + 9371bf6 commit a9ef779

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Lifecycle Configurations provide a mechanism to customize the Jupyter Server and
1212
* [install-autoshutdown-server-extension](scripts/install-autoshutdown-server-extension) (Recommended) - Installs only the server part of idle-kernel shutdown extension. No external dependencies to install, recommended to use in VPCOnly mode with restricted Internet connectivity. Idle timelimit has to be set using Life Cycle Configuration script.
1313
* [install-autoshutdown-extension](scripts/install-autoshutdown-extension) - Installs the auto idle-kernel shutdown extension on the Jupyter Server. This install allows users to set idle timeout limit using the UI. ***Note***: *The UI plugin is only compatible with JupyterLab v1.0. See [JupyterLab versioning](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-jl.html) for JupyterLab versions in SageMaker Studio.*
1414
* [install-lsp-features](scripts/install-lsp-features) - Installs coding assistance tools to enable features like auto-completion, linting, and hover suggestions in Studio JupyterLab v3+.
15+
* [disable-automatic-kernel-start](disable-automatic-kernel-start) - Disables automatic starting of kernel when opening notebooks. Only works with Studio JupyterLab v3.3+.
1516
* [install-pip-package-on-kernel](scripts/install-pip-package-on-kernel) - Installs a python package with pip on a Studio Kernel
1617
* [set-git-config](scripts/set-git-config) - This script sets the username and email address in Git config.
1718
* [set-git-credentials](scripts/set-git-credentials) - Adds the user's git credentials to Secret Manager and configures git to fetch the credentials from there when needed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This script configures page settings for your Jupyter Server in order to disable automatic startup of kernels on notebook access.
2+
3+
#!/bin/bash
4+
5+
set -eux
6+
7+
export AWS_SAGEMAKER_JUPYTERSERVER_IMAGE="${AWS_SAGEMAKER_JUPYTERSERVER_IMAGE:-'jupyter-server'}"
8+
if [ "$AWS_SAGEMAKER_JUPYTERSERVER_IMAGE" != "jupyter-server-3" ] ; then
9+
echo "SageMaker version '$AWS_SAGEMAKER_JUPYTERSERVER_IMAGE' does not match 'jupyter-server-3'"
10+
echo "Skipping install (which depends on JupyterLab v3)"
11+
exit 0
12+
fi
13+
14+
echo "Creating Jupyter page config."
15+
mkdir -p ~/.jupyter/labconfig
16+
touch ~/.jupyter/labconfig/page_config.json
17+
echo {\"notebookStartsKernel\": false} > ~/.jupyter/labconfig/page_config.json
18+
19+
# Restart Jupyter to make sure configuration is picked up
20+
echo "Restarting Jupyter server..."
21+
restart-jupyter-server

0 commit comments

Comments
 (0)