Skip to content

Commit c879fe7

Browse files
jatinkulkarniJatin Kulkarni
andauthored
Adding Notification for Capacity Shutdown for 1.1 (#158)
* Adding Notification for Capacity Shutdown * Refactor notificationManager to remove commented notifications --------- Co-authored-by: Jatin Kulkarni <jatinspk@amazon.com>
1 parent 0d89df5 commit c879fe7

File tree

2 files changed

+575
-51
lines changed

2 files changed

+575
-51
lines changed

patches/sagemaker/sagemaker-extension-smus-support.diff

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Index: code-editor-src/extensions/sagemaker-extension/src/constant.ts
1+
Index: third-party-src/extensions/sagemaker-extension/src/constant.ts
22
===================================================================
3-
--- code-editor-src.orig/extensions/sagemaker-extension/src/constant.ts
4-
+++ code-editor-src/extensions/sagemaker-extension/src/constant.ts
3+
--- third-party-src.orig/extensions/sagemaker-extension/src/constant.ts
4+
+++ third-party-src/extensions/sagemaker-extension/src/constant.ts
55
@@ -27,6 +27,10 @@ export const FIVE_MINUTES_INTERVAL_MILLI
66

77
export const SAGEMAKER_METADATA_PATH = '/opt/ml/metadata/resource-metadata.json';
@@ -25,14 +25,10 @@ Index: code-editor-src/extensions/sagemaker-extension/src/constant.ts
2525
};
2626
export function isSSOMode(cookie: SagemakerCookie) {
2727
return (cookie.authMode === AUTH_MODE.SSO)
28-
@@ -69,4 +78,35 @@ export function getExpiryTime(cookie: Sa
29-
} else {
30-
return -1;
28+
@@ -71,6 +80,37 @@ export function getExpiryTime(cookie: Sa
3129
}
32-
-}
33-
\ No newline at end of file
34-
+}
35-
+
30+
}
31+
3632
+/**
3733
+ * Constructs the SMUS portal URL using domain, region, and project information
3834
+ * Returns null if not in SMUS environment or if required fields are missing
@@ -63,10 +59,21 @@ Index: code-editor-src/extensions/sagemaker-extension/src/constant.ts
6359
+
6460
+ return `https://${DataZoneDomainId}.sagemaker.${DataZoneDomainRegion}.on.aws/projects/${DataZoneProjectId}/overview`;
6561
+}
66-
Index: code-editor-src/extensions/sagemaker-extension/src/extension.ts
62+
+
63+
// Capacity Block notification constants - configurable via environment variables
64+
// Default values (in milliseconds)
65+
const DEFAULT_THIRTY_MINUTES_MILLIS = 30 * 60 * 1000;
66+
@@ -111,4 +151,4 @@ export interface CapacityBlockMetadata {
67+
68+
export interface SagemakerResourceInternalMetadata {
69+
CapacityBlock?: CapacityBlockMetadata;
70+
-}
71+
\ No newline at end of file
72+
+}
73+
Index: third-party-src/extensions/sagemaker-extension/src/extension.ts
6774
===================================================================
68-
--- code-editor-src.orig/extensions/sagemaker-extension/src/extension.ts
69-
+++ code-editor-src/extensions/sagemaker-extension/src/extension.ts
75+
--- third-party-src.orig/extensions/sagemaker-extension/src/extension.ts
76+
+++ third-party-src/extensions/sagemaker-extension/src/extension.ts
7077
@@ -11,7 +11,8 @@ import {
7178
WARNING_BUTTON_SAVE_AND_RENEW_SESSION,
7279
SagemakerCookie,
@@ -75,11 +82,11 @@ Index: code-editor-src/extensions/sagemaker-extension/src/extension.ts
7582
+ getExpiryTime,
7683
+ getSmusVscodePortalUrl
7784
} from "./constant";
78-
import * as console from "console";
85+
import { NotificationManager } from './notificationManager';
86+
import { createCapacityBlockNotificationConfig } from './capacityBlockWarning';
87+
@@ -26,6 +27,24 @@ let notificationManager: NotificationMan
88+
7989

80-
@@ -19,6 +20,24 @@ import * as console from "console";
81-
const PARSE_SAGEMAKER_COOKIE_COMMAND = 'sagemaker.parseCookies';
82-
const ENABLE_AUTO_UPDATE_COMMAND = 'workbench.extensions.action.enableAutoUpdate';
8390

8491
+// Global redirect URL for SMUS environment
8592
+let smusRedirectUrl: string | null = null;
@@ -102,7 +109,7 @@ Index: code-editor-src/extensions/sagemaker-extension/src/extension.ts
102109
function showWarningDialog() {
103110
vscode.commands.executeCommand(PARSE_SAGEMAKER_COOKIE_COMMAND).then(response => {
104111

105-
@@ -59,11 +78,12 @@ function showWarningDialog() {
112+
@@ -66,11 +85,12 @@ function showWarningDialog() {
106113
}
107114

108115
function signInError(sagemakerCookie: SagemakerCookie) {
@@ -116,7 +123,7 @@ Index: code-editor-src/extensions/sagemaker-extension/src/extension.ts
116123
}
117124
});
118125
}
119-
@@ -94,32 +114,21 @@ function saveWorkspace() {
126+
@@ -101,32 +121,21 @@ function saveWorkspace() {
120127
});
121128
}
122129
function renewSession(sagemakerCookie: SagemakerCookie) {
@@ -158,7 +165,7 @@ Index: code-editor-src/extensions/sagemaker-extension/src/extension.ts
158165
}
159166

160167
// Render warning message regarding auto upgrade disabled
161-
@@ -158,6 +167,9 @@ export function activate(context: vscode
168+
@@ -177,6 +186,9 @@ export function activate(context: vscode
162169
// TODO: log activation of extension
163170
console.log('Activating Sagemaker Extension...');
164171

@@ -168,15 +175,18 @@ Index: code-editor-src/extensions/sagemaker-extension/src/extension.ts
168175
// execute the get cookie command and save the data to cookies
169176
vscode.commands.executeCommand(PARSE_SAGEMAKER_COOKIE_COMMAND).then(r => {
170177

171-
@@ -170,3 +182,11 @@ export function activate(context: vscode
172-
// render warning message regarding auto upgrade disabled
173-
renderExtensionAutoUpgradeDisabledNotification();
178+
@@ -194,6 +206,14 @@ export function activate(context: vscode
174179
}
175-
+
176-
+/**
180+
181+
/**
177182
+ * Returns the appropriate redirect URL based on the environment
178183
+ * Uses SMUS URL if available, falls back to original redirect URL
179184
+ */
180185
+function getRedirectUrl(sagemakerCookie: SagemakerCookie): string {
181186
+ return smusRedirectUrl || sagemakerCookie.redirectURL;
182187
+}
188+
+
189+
+/**
190+
* Called when extension is deactivated
191+
*/
192+
export function deactivate(): void {

0 commit comments

Comments
 (0)