Skip to content

Commit fea5104

Browse files
committed
feat(smus): Add status validation for space operations
**Description** Added status checks for SageMaker space operations to prevent invalid actions. **fix done** 1. The stopSpace function now validates space status before attempting to stop, showing appropriate warning messages for spaces already in Stopped/Stopping states or currently Starting. 2. Also added status refresh before open remote connect **Testing Done** code debug
1 parent 1562c38 commit fea5104

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/core/src/awsService/sagemaker/commands.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ export async function stopSpace(
133133
ctx: vscode.ExtensionContext,
134134
sageMakerClient?: SagemakerClient
135135
) {
136+
await tryRefreshNode(node)
137+
if (node.getStatus() === 'Stopped' || node.getStatus() === 'Stopping') {
138+
void vscode.window.showWarningMessage('This space is already in Stopped/Stopping state')
139+
return
140+
} else if (node.getStatus() === 'Starting') {
141+
void vscode.window.showWarningMessage('This space is starting, please stop it later')
142+
return
143+
}
136144
const spaceName = node.spaceApp.SpaceName!
137145
const confirmed = await showConfirmationMessage({
138146
prompt: `You are about to stop this space. Any active resource will also be stopped. Are you sure you want to stop the space?`,
@@ -179,7 +187,7 @@ export async function openRemoteConnect(
179187
void vscode.window.showErrorMessage(ConnectFromRemoteWorkspaceMessage)
180188
return
181189
}
182-
190+
await tryRefreshNode(node)
183191
if (node.getStatus() === 'Stopped') {
184192
// In case of SMUS, we pass in a SM Client and for SM AI, it creates a new SM Client.
185193
const client = sageMakerClient ? sageMakerClient : new SagemakerClient(node.regionCode)

0 commit comments

Comments
 (0)