Skip to content

Conversation

@mndeshmu97
Copy link

Description

  • Post-startup script stored in SMD (SageMaker Distribution) enables the required customizations for SMUS applications.
  • This functionality is currently operational for JupyterLab apps.
  • We are extending this capability to CodeEditor apps.

Testing Done

  • Tested building the local image for these changes and tested on personal LL stack using BYOI
  • Verified script execution logs file generation at /var/log/apps after app launch

Issue #, if available:

Description of changes:
Adding /api/poststartup endpoint for the SageMaker Unified Studio user case that runs the post startup script.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

**Description**
- Post-startup script stored in SMD (SageMaker Distribution) enables the required customizations for SMUS applications.
- This functionality is currently operational for JupyterLab apps.
- We are extending this capability to CodeEditor apps.

**Testing Done**
- Tested building the local image for these changes and tested on personal LL stack using BYOI
- Verified script execution logs file generation at /var/log/apps after app launch
* Handles API requests to run the post-startup script in SMD.
*/
private async _handlePostStartupScriptInvocation(req: http.IncomingMessage, res: http.ServerResponse): Promise<void> {
const postStartupScripPath = '/etc/sagemaker-ui/sagemaker_ui_post_startup.sh'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

// Adding 0o755 to make script file executable
fs.chmodSync(postStartupScripPath, 0o755);

const subprocess = spawn('bash', [`${postStartupScripPath}`], { cwd: '/' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • This happens only in case of invalid executable path. In our case the script path should always be correct since we are providing it, even if it is incorrect we perform fileExist check which throws 500 error.
  • In case of invalid script execution command, the error gets caught and again the server throws 500 error.
  • I verified this by running the server locally.

Copy link
Contributor

@aws-asolidu aws-asolidu Mar 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do we handle errors thrown by the script itself?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This api just triggers the script execution. If there are errors while executing the script, they get logged in the log file.

@aws-asolidu aws-asolidu merged commit 310e702 into aws:feature/smus Mar 28, 2025
austinjang2 pushed a commit to austinjang2/sagemaker-code-editor that referenced this pull request Sep 11, 2025
Add SageMaker-UI poststartup endpoint patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants