Skip to content

Conversation

@astitv-sh
Copy link

Issue #, if available:

Description of changes:
When the post startup script is executed, it can result in errors due to multiple reasons. At present, there is no functionality to surface these failure/success scenarios to inform the users and prompt them to take the necessary action.

This extension monitors the post-startup-status.json file generated during the course of the post startup script execution and shows pop-up notifications to users based on the status of the execution. The possible status set can be ['in-progress','error','success']. In case of errors, the potential cause is also written to the post-startup-status.json file which can be surfaced to the user.

Related post startup script changes PR: https://github.com/aws/private-sagemaker-distribution-staging/pull/237

Testing

The extension was tested for the different cases in Code Editor by manually executing the post startup script which writes to the post-startup-status.json file throughout its workflow. Based on the different test cases, the toast notification shown and the contents of the notification are as follows:

  1. Success case:
    Screenshot 2025-03-25 at 11 05 01 PM

  2. Error case (domain metadata fetch issue):
    Screenshot 2025-03-25 at 11 05 29 PM

  3. Unexpected error:
    Screenshot 2025-03-25 at 11 08 11 PM

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

Copy link

@bharathGuntamadugu bharathGuntamadugu left a comment

Choose a reason for hiding this comment

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

We also need this extensions to be part of vscode/build/npm/dirs.js to install the depencies correctly? Ref: #110

Choose a reason for hiding this comment

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

Curious why do we need this?

Copy link
Author

Choose a reason for hiding this comment

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

removed

// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{

Choose a reason for hiding this comment

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

Spacing seems off with more than tab spaces for all jsons.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed locally, not sure why shows up here.

@@ -0,0 +1,42 @@
{

Choose a reason for hiding this comment

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

See if we need to add publisher and license in this file? Have seen this in other extension (theme) we build

  "publisher": "sagemaker",
  "license": "MIT",

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

let previousStatus: string | undefined;
export function activate(context: vscode.ExtensionContext) {
try {
const watcher = chokidar.watch(STATUS_FILE, {

Choose a reason for hiding this comment

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

Spacing seems off here.

import * as chokidar from 'chokidar';

let previousStatus: string | undefined;
export function activate(context: vscode.ExtensionContext) {

Choose a reason for hiding this comment

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

We are only suppose to activate this SMUS and not for SM AI.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

@@ -0,0 +1 @@
export const STATUS_FILE = '/tmp/.post-startup-status.json'; No newline at end of file

Choose a reason for hiding this comment

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

nit: STATUS_FILE -> POST_START_UP_STATUS_FILE

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

import * as fs from 'fs';
import { STATUS_FILE } from './constant';
import { StatusFile } from './types';
import * as chokidar from 'chokidar';

Choose a reason for hiding this comment

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

Whats with chokidar package? Is this approved to be used?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, it is approved for use. It is also available internally as part of the internal package registry.

"vscode:prepublish": "npm run build-ext",
"build-ext": "node ../../node_modules/gulp/bin/gulp.js --gulpfile ../../build/gulpfile.extensions.js compile-extension:post-startup-notifications ./tsconfig.json"
},
"devDependencies": {

Choose a reason for hiding this comment

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

As we have dependencies here - my understanding is we need to have yarn.lock file to install these dependencies.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed


let previousStatus: string | undefined;
export function activate(context: vscode.ExtensionContext) {
try {

Choose a reason for hiding this comment

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

What happens if the file does not exits?

Copy link
Author

Choose a reason for hiding this comment

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

The extension monitors the path and handles both cases for when file is first created as well as changed

@aws-asolidu
Copy link
Contributor

Shouldn't this be part of the post-startup script instead of it's own extension? #108

Comment on lines 47 to 51
case 'in-progress':
vscode.window.showInformationMessage(statusData.message);
break;
default:
vscode.window.showInformationMessage(statusData.message);
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like in-progress case is not necessary.

Copy link
Author

Choose a reason for hiding this comment

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

In progress case is handled as per the equivalent plugin for JL. Can remove if my info is not up to date.

Copy link
Contributor

Choose a reason for hiding this comment

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

it has same logic as default case.

Choose a reason for hiding this comment

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

+1

can we say like to be more redable:

case 'in-progress':
default:
    vscode.window.showInformationMessage(statusData.message);

let previousStatus: string | undefined;
export function activate(context: vscode.ExtensionContext) {
try {
const watcher = chokidar.watch(STATUS_FILE, {
Copy link
Contributor

Choose a reason for hiding this comment

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

we should close the watcher on extension deactivate.

};

export function deactivate() {
console.log('Status monitor deactivated');
Copy link
Contributor

Choose a reason for hiding this comment

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

@astitv-sh
Copy link
Author

Shouldn't this be part of the post-startup script instead of it's own extension? #108

Post Startup writes the execution status logs to the post-startup-status.json log file. This extension monitors the log file to notify the user in real time.

@aws-asolidu
Copy link
Contributor

aws-asolidu commented Mar 27, 2025

Shouldn't this be part of the post-startup script instead of it's own extension? #108

Post Startup writes the execution status logs to the post-startup-status.json log file. This extension monitors the log file to notify the user in real time.

Why do we need a separate extension for each post-startup use-case?

Choose a reason for hiding this comment

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

Do we need this file? Its empty.

@@ -0,0 +1,3 @@
export const POST_START_UP_STATUS_FILE = '/tmp/.post-startup-status.json';
export const SAGEMAKER_UNIFIED_STUDIO_ENV_VALUE = 'SageMakerUnifiedStudio';
export const SAGEMAKER_UNIFIED_STUDIO_ENV_KEY = 'SERVICE_NAME'; No newline at end of file

Choose a reason for hiding this comment

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

nit: Wld rather name it SERVICE_NAME_ENV_KEY

Comment on lines 47 to 51
case 'in-progress':
vscode.window.showInformationMessage(statusData.message);
break;
default:
vscode.window.showInformationMessage(statusData.message);

Choose a reason for hiding this comment

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

+1

can we say like to be more redable:

case 'in-progress':
default:
    vscode.window.showInformationMessage(statusData.message);

@@ -0,0 +1,2 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.

Choose a reason for hiding this comment

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

You need to run yarn install from this folder to generate pacakge versions in the yarn.lock file

/** @type WebpackConfig */
const extensionConfig = {
target: 'node', // VS Code extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production')
Copy link

Choose a reason for hiding this comment

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

Nit: this spacing issue appears only in the PR or appears locally too?

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.

4 participants