Managing Multiple AWS SageMaker Lifecycle Configurations

194 Views Asked by At

I've been exploring SageMaker Lifecycle Configurations, particularly in reference to the setting default LCC in the AWS documentation . According to the documentation, it's possible to attach multiple Lifecycle Configuration (LCC) scripts to a single source and set a default LCC for both the Jupyter Server app (Studio app) and the Kernel Gateway app.

In my scenario, I have set up an auto-shutdown-lcc as the default for the Studio app (Jupyter Server app). Additionally, I've created another LCC script called code-whisperer-lcc designed to automatically install and enable the Code Whisperer extension for the Studio app.

  1. if there are multiple LCC scripts, can we define the order in which these scripts are executed when launching the Studio app?
  2. If specifying the execution order is not possible, what would be the best practice for achieving this task without disrupting the functionality of the auto-shutdown-lcc script?
1

There are 1 best solutions below

0
On

The AWS SageMaker Lifecycle Configurations documentation clarifies that only one lifecycle configuration can be set as the default for each JupyterServer or KernelGateway application:

Although you can attach multiple lifecycle configuration scripts to a single resource, you can only set one default lifecycle configuration for each JupyterServer or KernelGateway application.

The word default is misleading here, it means that multiple lifecycle configuration scripts can be created and attached to your domain. However, when you are launching a studio app or a notebook instance, only one LCC can be attached. The create-app CLI command has a placeholder for a single LifecycleConfigArn not a list.

In light of this constraint, if you have multiple Lifecycle Configuration scripts and want to determine the order in which they are executed when launching the SageMaker Studio/Notebook, it's important to note that, due to the single default limitation, you cannot define a specific execution order for these scripts.

To achieve the desired execution sequence without disrupting the functionality of the "auto-shutdown-lcc" script, you have a couple of options. First, you can merge the functionalities of your various scripts into a single script. However, keep in mind that the merged script is subject to a time limit of 5 minutes, so ensure that the merged script doesn't exceed this time constraint. Otherwise use nohup and & to make the script run for longer.

Another approach is to create a shell script that downloads and executes the individual scripts in the desired order. The advantage of this second method is that it allows you to maintain and reuse the code you've already developed more easily.