I've been following the AWS blog post on using SageMaker Lifecycle Configurations for customizing SageMaker Studio. According to the post, the second use case involves the installation of custom packages on base kernel images. I successfully installed and enabled the Code Whisperer extension by configuring a lifecycle configuration script as the default for the Studio app. However, when I used the same script for the Kernel Gateway app instead of studio app, I encountered an error specifically when running the command:
jupyter serverextension enable amazon_codewhisperer_jupyterlab_ext
The error message I received was: "Is amazon_codewhisperer_jupyterlab_ext
importable?"
- Why am I encountering this error when trying to enable the extension for the Kernel Gateway app? 2)What steps can I take to resolve this error and successfully enable the Code Whisperer extension in the Kernel Gateway environment?
- Could you please confirm if the Lifecycle Configurations method (2nd use case) outlined in the post is solely for package installation, or can it also be used to automatically enable extensions like the Code Whisperer? If the latter is possible, are there any specific steps or considerations I should keep in mind while implementing this approach in Kernel Gateway environment?
LCC script used to install and enable code whisperer extension is:
#!/bin/bash
set -ux
echo Should already be running in user home directory, but just to check:
cd /home/sagemaker-user
echo Initialising conda to activate studio environment
conda init bash
echo restarting the shell
source ~/.bashrc
echo Activate studio environment just for installing extension
conda activate studio
pip install amazon-codewhisperer-jupyterlab-ext
jupyter serverextension enable amazon_codewhisperer_jupyterlab_ext
conda deactivate