Skip to content

Commit df16bc4

Browse files
Update documentation for version 2.0
1 parent 7d0a15a commit df16bc4

File tree

6 files changed

+224
-4
lines changed

6 files changed

+224
-4
lines changed

Flow_Diagrams.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,24 @@
22

33
- [Training job with SSM](#training-job-with-ssm)
44
- [Training job with SSH](#training-job-with-ssh)
5+
- [Local IDE to SageMaker Studio to with SSH](#local-ide-to-sagemaker-studio-to-with-ssh)
56

67
#### Training job with SSM
78

89
This flow corresponds to the [Connecting to SageMaker training jobs with SSM](README.md#training) procedure.
910

10-
![Screenshot](images/Flow_Train_SSM.png)
11+
![Screenshot - Training job with SSM](images/Flow_Train_SSM.png)
1112

1213

1314
#### Training job with SSH
1415

1516
This flow corresponds to the [Remote code execution with PyCharm / VSCode over SSH](README.md#remote-interpreter) procedure.
1617

17-
![Screenshot](images/Flow_Train_SSH.png)
18+
![Screenshot - Training job with SSH](images/Flow_Train_SSH.png)
1819

20+
21+
#### Local IDE to SageMaker Studio to with SSH
22+
23+
This flow corresponds to the [Local IDE integration with SageMaker Studio over SSH for PyCharm / VSCode](README.md#studio) procedure.
24+
25+
![Screenshot - Local IDE to SageMaker Studio to with SSH](images/Flow_IDE.png)

images/Flow_IDE.png

255 KB
Loading

images/Flow_Train_SSH.png

9.93 KB
Loading

sagemaker_ssh_helper/sm-local-ssh-ide

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
# Commands:
4-
# connect <kernel_gateway_name> [--ssh-only] [--domain <domain-id>] [--user <profile-name>] [<extra_ssh_args>]
4+
# connect <kernel_gateway_name> [--ssh-only] [<extra_ssh_args>]
55
# run-command <command> <args...>
66
# TODO: create <kernel_gateway_name> [--recreate] --domain <domain> --user <profile-name> --image datascience-1.0 --instance ml.t3.medium
77
# TODO: list (all apps from all users and domains marked with '*' if can connect with SSH and with '!' if user don't match)

uml/Flow_IDE.puml

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
See https://pdf.plantuml.net/PlantUML_Language_Reference_Guide_en.pdf
2+
3+
@startuml
4+
actor Developer as dev
5+
participant "SageMaker SSH Helper \n library (local)" as sm_ssh_helper_local
6+
participant "Amazon SageMaker Studio" as sagemaker_studio
7+
participant "VPC \n private or managed" as vpc
8+
participant "SageMaker SSH Helper \n library (remote)" as sm_ssh_helper_remote
9+
participant "SSH server" as ssh
10+
participant "SSM agent" as ssm_agent
11+
participant "AWS Systems Manager \n (SSM)" as ssm
12+
participant "IAM" as iam
13+
14+
dev -> sagemaker_studio: Create kernel gateway app
15+
note left of dev
16+
Ex.:
17+
Data Science 2.0
18+
end note
19+
20+
sagemaker_studio -> vpc: Start containers
21+
activate vpc
22+
vpc -> vpc: Start kernel gateway
23+
note left vpc
24+
jupyter kernelgateway
25+
end note
26+
activate vpc
27+
28+
29+
dev -> vpc: Run life-cycle configuration
30+
note left of dev
31+
kernel-lc-config.sh
32+
end note
33+
34+
dev -> vpc: Alternatively, run IDE notebook
35+
note left of dev
36+
SageMaker_SSH_IDE.ipynb
37+
end note
38+
39+
40+
vpc -> sm_ssh_helper_remote: Setup IDE
41+
activate vpc
42+
43+
activate sm_ssh_helper_remote
44+
45+
sm_ssh_helper_remote -> sm_ssh_helper_remote: Print connect metadata
46+
47+
note left sm_ssh_helper_remote
48+
sm-ssh-ide
49+
get-metadata
50+
end note
51+
52+
sm_ssh_helper_remote --> dev:
53+
54+
note right dev
55+
App name: sagemaker-data-science-ml-m5-large-1234567890abcdef0
56+
User profile name: terry-whitlock
57+
Domain: d-egm0dexample
58+
end note
59+
60+
sm_ssh_helper_remote -> sm_ssh_helper_remote: Configure and \n install IDE libs
61+
note left sm_ssh_helper_remote
62+
sm-ssh-ide
63+
configure
64+
end note
65+
66+
67+
sm_ssh_helper_remote -> sm_ssh_helper_remote: Configure and \n install SSH libs
68+
activate sm_ssh_helper_remote
69+
note right sm_ssh_helper_remote
70+
sm-setup-ssh
71+
configure
72+
end note
73+
deactivate sm_ssh_helper_remote
74+
75+
76+
sm_ssh_helper_remote -> sm_ssh_helper_remote: Initialize SSM
77+
activate sm_ssh_helper_remote
78+
note left sm_ssh_helper_remote
79+
sm-ssh-ide
80+
init-ssm
81+
end note
82+
83+
note right sm_ssh_helper_remote
84+
sm-init-ssm
85+
end note
86+
sm_ssh_helper_remote -> ssm: Create activation
87+
sm_ssh_helper_remote -> ssm_agent: Register
88+
ssm_agent -> ssm:
89+
note right ssm_agent
90+
mi-01234567890abcdef
91+
end note
92+
ssm --> ssm_agent:
93+
deactivate sm_ssh_helper_remote
94+
95+
note left sm_ssh_helper_remote
96+
sm-ssh-ide
97+
start
98+
end note
99+
100+
sm_ssh_helper_remote -> sm_ssh_helper_remote: Save environment \n for remote shell
101+
note right sm_ssh_helper_remote
102+
sm-save-env
103+
end note
104+
105+
sm_ssh_helper_remote -> ssh: Start SSH server
106+
activate ssh
107+
108+
sm_ssh_helper_remote -> sm_ssh_helper_remote: Start VNC and \n Jupyter server
109+
110+
111+
sm_ssh_helper_remote -> ssm_agent: Start SSM agent
112+
note left sm_ssh_helper_remote
113+
sm-ssh-ide
114+
ssm-agent
115+
end note
116+
activate ssm_agent
117+
ssm_agent -> ssm: Go online
118+
119+
120+
note right dev
121+
sm-local-ssh-ide set-domain d-egm0dexample
122+
sm-local-ssh-ide set-user terry-whitlock
123+
end note
124+
125+
note right dev
126+
sm-local-ssh-ide connect sagemaker-data-science-ml-m5-large-1234567890abcdef0
127+
end note
128+
dev -> sm_ssh_helper_local: Connect
129+
sm_ssh_helper_local -> sm_ssh_helper_local: Get instance IDs
130+
sm_ssh_helper_local -> ssm: List and filter instances
131+
sm_ssh_helper_local -> sm_ssh_helper_local: Repeat until successful \n or timeout
132+
133+
note right sm_ssh_helper_local
134+
mi-01234567890abcdef, ...
135+
end note
136+
137+
activate sm_ssh_helper_local
138+
note right sm_ssh_helper_local
139+
sm-connect-ssh-proxy mi-01234567890abcdef
140+
end note
141+
sm_ssh_helper_local -> sm_ssh_helper_local: Generate SSH key pair
142+
sm_ssh_helper_local -> ssm: Copy SSH public key through S3
143+
144+
ssm -> iam: Check SendCommand \n permissions
145+
ssm -> ssm_agent: Run command
146+
ssm_agent -> ssm_agent: Copy key from S3
147+
sm_ssh_helper_local -> ssm: Start SSH session proxy \n over SSM
148+
149+
ssm -> iam: Check StartSession \n permissions
150+
151+
ssm -> ssm_agent: Start SSH session
152+
ssm_agent -> ssm_agent: Start SSH proxy tunnel
153+
ssm_agent --> sm_ssh_helper_local:
154+
sm_ssh_helper_local -> ssm_agent: Start SSH port forwarding \n over SSM proxy tunnel
155+
ssm_agent -> ssh: Start SSH proxy \n tunnel session
156+
activate ssh
157+
158+
159+
dev -> dev: Connect from IDE
160+
activate dev
161+
note right dev
162+
ssh sagemaker-studio
163+
end note
164+
dev -> ssh: Connect with SSH through forwarded SSH port
165+
ssh --> dev:
166+
167+
dev -> vpc: Run and debug code remotely with IDE
168+
deactivate dev
169+
170+
dev -> vpc: Open Jupyter \n in browser
171+
dev -> vpc: Connect with \n VNC client
172+
173+
...Development is in progress...
174+
175+
dev -> sm_ssh_helper_remote: Interrupt notebook kernel and stop services
176+
177+
note left sm_ssh_helper_remote
178+
sm-ssh-ide
179+
stop
180+
end note
181+
182+
sm_ssh_helper_remote -> ssm_agent: Stop SSM agent
183+
deactivate ssm_agent
184+
185+
sm_ssh_helper_remote -> ssh: Stop SSH server
186+
deactivate ssh
187+
188+
deactivate ssh
189+
190+
sm_ssh_helper_remote -> sm_ssh_helper_remote: Stop VNC and \n Jupyter server
191+
192+
deactivate vpc
193+
deactivate sm_ssh_helper_remote
194+
195+
dev -> vpc: Stop app
196+
197+
198+
199+
deactivate vpc
200+
201+
deactivate vpc
202+
deactivate sm_ssh_helper_local
203+
204+
@enduml

uml/Flow_Train_SSH.puml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ dev -> sagemaker: Create training job \n (fit estimator)
3838
note left of dev
3939
sourcedir.tar.gz
4040
end note
41+
sagemaker --> dev:
42+
note right of dev
43+
Job name: ssh-training-example-2023-07-25-03-18-04-490
44+
end note
4145

4246
sagemaker -> vpc: Start containers
4347
note left vpc
@@ -61,6 +65,11 @@ activate vpc
6165
activate sm_ssh_helper_remote
6266

6367
sm_ssh_helper_remote -> sm_ssh_helper_remote: Configure and \n install libs
68+
note left sm_ssh_helper_remote
69+
sm-setup-ssh
70+
configure
71+
end note
72+
6473
sm_ssh_helper_remote -> sm_ssh_helper_remote: Save environment \n for remote shell
6574
note left sm_ssh_helper_remote
6675
sm-save-env
@@ -95,7 +104,7 @@ sm-wait
95104
end note
96105

97106
note right dev
98-
sm-local-ssh-training connect <training_job_name>
107+
sm-local-ssh-training connect ssh-training-example-2023-07-25-03-18-04-490
99108
end note
100109
dev -> sm_ssh_helper_local: Connect
101110
sm_ssh_helper_local -> sm_ssh_helper_local: Get instance IDs

0 commit comments

Comments
 (0)