-
Notifications
You must be signed in to change notification settings - Fork 33
Post startup script notifications extension for Code Editor #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
bharathGuntamadugu
left a comment
There was a problem hiding this 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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 | ||
| { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 @@ | |||
| { | |||
There was a problem hiding this comment.
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",
There was a problem hiding this comment.
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, { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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": { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
|
Shouldn't this be part of the post-startup script instead of it's own extension? #108 |
| case 'in-progress': | ||
| vscode.window.showInformationMessage(statusData.message); | ||
| break; | ||
| default: | ||
| vscode.window.showInformationMessage(statusData.message); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, { |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use outputchannel logging instead of console logs? https://github.com/aws/sagemaker-code-editor/pull/110/files#diff-2f5d009765a1a962b8260a8acaebfbc6b170c022c76407605985311b69d35afeR18
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? |
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
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
| case 'in-progress': | ||
| vscode.window.showInformationMessage(statusData.message); | ||
| break; | ||
| default: | ||
| vscode.window.showInformationMessage(statusData.message); |
There was a problem hiding this comment.
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. | |||
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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?
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:
Success case:

Error case (domain metadata fetch issue):

Unexpected error:

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