Skip to content

Sagemaker Studio - Code Editor Lifecycle config

0

I'm attempting to set up a Lifecycle config for the Code Editor app on the new Sagemaker Studio service. At the moment I just want to install some extensions, and have been following this guide. This states

You can retrieve the extension name from the URL of the extension in the Open VSX Registry. The extension name to use in the sagemaker-code-editor command should contain all text that follows https://open-vsx.org/extension/ in the URL. Replace all instances of a slash (/) with a period (.). For example, AmazonEMR/emr-tools should be AmazonEMR.emr-tools.

The following simple config script works no problem

#!/bin/bash
set -eux
sagemaker-code-editor --install-extension ms-python.pylint --extensions-dir /opt/amazon/sagemaker/sagemaker-code-editor-server-data/extensions

But the following returns an error stdbuf: failed to run command ‘/opt/ml/lifecycleconfig/lifecycle_script.sh’: No such file or directory when I start the space.

#!/bin/bash
set -eux
sagemaker-code-editor --install-extension ms-python.pylint --extensions-dir /opt/amazon/sagemaker/sagemaker-code-editor-server-data/extensions
sagemaker-code-editor --install-extension dracula-theme.theme-dracula --extensions-dir /opt/amazon/sagemaker/sagemaker-code-editor-server-data/extensions

Can anyone explain or help shed some light on what's going on? I've tried various iterations - even trying to install the Dracula extension alone causes the same issue. Running this through the Sagemaker UI.

asked 2 years ago2.5K views

2 Answers
2

Hello,

I understand that you are trying to set up a lifecycle configuration for the Code Editor app on the new Sagemaker Studio and would like to gather more information on the same.

Here, I would like to mention that I tried to replicate the scenario at my end; however, I was successfully able to install the extensions in my test environment, Sagemaker Studio Code Editor. I would request that you please go through the below steps that I followed on my end:

  1. Open the Amazon SageMaker console and navigate to “Lifecycle Configurations.“.

  2. On the Lifecycle Configuration page, navigate to Code Editor and try creating a new configuration with the below script.

#!/bin/bash
set -eux
sagemaker-code-editor —install-extension ms-python.pylint —extensions-dir /opt/amazon/sagemaker/sagemaker-code-editor-server-data/extensions
sagemaker-code-editor --install-extension dracula-theme.theme-dracula --extensions-dir /opt/amazon/sagemaker/sagemaker-code-editor-server-data/extensions
  1. Now navigate to Sagemaker Domain and go to Environment Variables to attach this script and make it the default.

  2. Now launch Sagemaker Studio.

  3. Then create a new code editor and try running the instance (please make sure the lifecycle script is shown under the lifecycle configuration dropdown).

Enter image description here

  1. Now I was successfully able to launch the code editor and see the extension from the left sidebar.

Enter image description here

Enter image description here

I would request that you please try this on your end and let us know how it goes for you.

If you have any difficulty or if you still run into issues, please reach out to AWS Support [1] (Sagemaker) along with your issue or use case in detail, and we would be happy to assist you further.

References:

=========

[1] Creating support cases and case management: https://docs.aws.amazon.com/awssupport/latest/user/case-management.html#creating-a-support-casehttps://docs.aws.amazon.com/awssupport/latest/user/case-management.html#creating-a-support-case

AWS

answered 2 years ago

EXPERT

reviewed 2 years ago

0

Just a possible alternative in case it's relevant, since the other answer isn't accepted yet... (but looks like a nice walkthrough!)

I am aware that customers running Windows computers have previously observed issues creating LCCs for (Linux-based) SageMaker Studio environments both through the AWS Console and their local text editors, due to CRLF vs LF line endings.

I notice the first line of your script is a shebang, so if you created it on Windows it's possible SageMaker is trying to run your script with the #!/bin/bash[CR] interpreter. Since that doesn't exist, I'd usually expect to result in an error along the lines of "bad interpreter: No such file or directory": Pretty close to what you've seen.

Not sure whether this past issue has been fixed already, or applies to your case, but if you're using Windows and still having issues with LCCs mysteriously breaking when they should work, I'd suggest maybe creating/uploading your LCCs from a Linux box via the CLI: Perhaps a SageMaker Notebook Instance outside your SM Domain?

AWS
EXPERT

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.