Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Jupytext plugin on AWS Sagemaker

Jupytext allows you to save your notebook as a plain python or markdown file. One of the advantages is that you can do an easy git diff in merge requests.

How can you install the jupytext plugin on the jupyter/jupyterlab environment on AWS Sagemaker?

like image 942
Vincent Claes Avatar asked Mar 05 '26 00:03

Vincent Claes


1 Answers

to install jupytext in jupyter(lab) use the following script in your sagemaker on-start lifecycle config:

#!/bin/bash

set -e

echo "installing jupytext plugin into the jupyter(lab) environment"

sudo -u ec2-user -i <<EOF

# to install jupyter plugins, you need to select the jupyter environment
source /home/ec2-user/anaconda3/bin/activate /home/ec2-user/anaconda3/envs/JupyterSystemEnv

# install jupytext
pip install jupytext --upgrade
# As of Feb 2021, Sagemaker is using jupyterlab v 1.x for which Jupytext recommends the following version.
jupyter labextension install [email protected]

# allow jupyter to open and save notebooks as text files.
echo c.NotebookApp.contents_manager_class="jupytext.TextFileContentsManager" >> /home/ec2-user/.jupyter/jupyter_notebook_config.py

# restart jupyter to let the changes take effect.
sudo initctl restart jupyter-server --no-wait

EOF
like image 156
Vincent Claes Avatar answered Mar 07 '26 13:03

Vincent Claes