-
Notifications
You must be signed in to change notification settings - Fork 728
feat(sagemaker): add progress indicator during space remote connection process #8247
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
Changes from 4 commits
082028a
1bb13dc
dd403cd
c0aae34
93028a4
c125b21
c2df995
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -191,32 +191,69 @@ export async function openRemoteConnect( | |
| void vscode.window.showErrorMessage(ConnectFromRemoteWorkspaceMessage) | ||
| return | ||
| } | ||
| await tryRefreshNode(node) | ||
| if (node.getStatus() === 'Stopped') { | ||
| // In case of SMUS, we pass in a SM Client and for SM AI, it creates a new SM Client. | ||
| const client = sageMakerClient ? sageMakerClient : new SagemakerClient(node.regionCode) | ||
|
|
||
| try { | ||
| await client.startSpace(node.spaceApp.SpaceName!, node.spaceApp.DomainId!) | ||
| await tryRefreshNode(node) | ||
| const appType = node.spaceApp.SpaceSettingsSummary?.AppType | ||
| if (!appType) { | ||
| throw new ToolkitError('AppType is undefined for the selected space. Cannot start remote connection.', { | ||
| code: 'undefinedAppType', | ||
| }) | ||
| } | ||
| await client.waitForAppInService(node.spaceApp.DomainId!, node.spaceApp.SpaceName!, appType) | ||
| await tryRemoteConnection(node, ctx) | ||
| } catch (err: any) { | ||
| // Ignore InstanceTypeError since it means the user decided not to use an instanceType with more memory | ||
| if (err.code !== InstanceTypeError) { | ||
|
|
||
| const spaceName = node.spaceApp.SpaceName! | ||
|
|
||
| try { | ||
| await tryRefreshNode(node) | ||
|
|
||
| // for Stopped SM spaces - check instance type before showing progress | ||
| if (node.getStatus() === 'Stopped') { | ||
| // In case of SMUS, we pass in a SM Client and for SM AI, it creates a new SM Client. | ||
| const client = sageMakerClient ? sageMakerClient : new SagemakerClient(node.regionCode) | ||
|
|
||
| try { | ||
|
||
| await client.startSpace(spaceName, node.spaceApp.DomainId!) | ||
| await tryRefreshNode(node) | ||
| const appType = node.spaceApp.SpaceSettingsSummary?.AppType | ||
| if (!appType) { | ||
| throw new ToolkitError( | ||
| 'AppType is undefined for the selected space. Cannot start remote connection.', | ||
| { | ||
| code: 'undefinedAppType', | ||
| } | ||
| ) | ||
| } | ||
|
|
||
| // Only start showing progress after instance type validation | ||
| return await vscode.window.withProgress( | ||
| { | ||
| location: vscode.ProgressLocation.Notification, | ||
| cancellable: false, | ||
| title: `Connecting to ${spaceName}`, | ||
| }, | ||
| async (progress) => { | ||
| progress.report({ message: 'Starting the space.' }) | ||
| await client.waitForAppInService(node.spaceApp.DomainId!, spaceName, appType) | ||
| await tryRemoteConnection(node, ctx, progress) | ||
| } | ||
| ) | ||
| } catch (err: any) { | ||
| // Ignore InstanceTypeError since it means the user decided not to use an instanceType with more memory | ||
| // just return without showing progress | ||
| if (err.code === InstanceTypeError) { | ||
| return | ||
| } | ||
| throw new ToolkitError(`Remote connection failed: ${(err as Error).message}`, { | ||
| cause: err as Error, | ||
| code: err.code, | ||
| }) | ||
| } | ||
| } else if (node.getStatus() === 'Running') { | ||
| // For running spaces, show progress | ||
| return await vscode.window.withProgress( | ||
| { | ||
| location: vscode.ProgressLocation.Notification, | ||
| cancellable: false, | ||
| title: `Connecting to ${spaceName}`, | ||
| }, | ||
| async (progress) => { | ||
| await tryRemoteConnection(node, ctx, progress) | ||
| } | ||
| ) | ||
| } | ||
| } else if (node.getStatus() === 'Running') { | ||
| await tryRemoteConnection(node, ctx) | ||
| } catch (err: any) { | ||
| getLogger().error(`sm:openRemoteConnect: ${err}`) | ||
| throw err | ||
| } | ||
| } | ||
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 seems to be a nullable, are we sure all the functions below which use this field handle the null 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.
what will happen if this is null/undefined
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.
spaceName cannot be null because spaces must have names when created