Skip to content

Commit 03eb08a

Browse files
Publishing version 1.7.8
1 parent c6cdf12 commit 03eb08a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2793
-24
lines changed

.gitlab-ci.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Official language image. Look for the different tagged releases at:
2+
# https://hub.docker.com/r/library/python/tags/
3+
image: python:3.8
4+
5+
stages:
6+
- scan_source_code
7+
- test
8+
9+
scan_source_code:
10+
stage: scan_source_code
11+
script:
12+
- pip install bandit
13+
- bandit -r ./ --skip B603,B404,B101,B607 2>&1 | tee bandit.txt
14+
artifacts:
15+
paths:
16+
- bandit.txt
17+
18+
run_tests:
19+
stage: test
20+
resource_group: ssh-helper-tests
21+
script:
22+
# Smoke test - Python version
23+
- python --version
24+
# Check all running processes on the agent
25+
- hostname
26+
- ps xfa
27+
# Install AWS CLI
28+
- curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "/tmp/awscliv2.zip"
29+
- unzip -o -q -d /tmp/ /tmp/awscliv2.zip
30+
- /tmp/aws/install
31+
- aws --version
32+
- aws sts get-caller-identity
33+
- echo "AWS default region - $AWS_DEFAULT_REGION"
34+
- echo "AWS region - $AWS_REGION"
35+
- aws configure list
36+
# Install SSM plugin
37+
- curl "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_64bit/session-manager-plugin.deb" -o "session-manager-plugin.deb"
38+
- dpkg -i session-manager-plugin.deb
39+
- session-manager-plugin --version
40+
# Install the package
41+
- pip install '.[test]'
42+
# Run tests
43+
- echo "SageMaker role - $SAGEMAKER_ROLE"
44+
- echo "Kernel Gateway name - $KERNEL_GATEWAY_NAME"
45+
- echo "Extra args for pytest - $PYTEST_EXTRA_ARGS"
46+
- cd tests; pytest --junitxml=pytest_report.xml -m 'not manual' -o sagemaker_role=$SAGEMAKER_ROLE -o kernel_gateway_name=$KERNEL_GATEWAY_NAME $PYTEST_EXTRA_ARGS
47+
artifacts:
48+
when: always
49+
reports:
50+
junit: tests/pytest_report.xml

.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/sagemaker-ssh-helper.iml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CODE_OF_CONDUCT.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
## Code of Conduct
2-
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
3-
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
4-
[email protected] with any additional questions or comments.
2+
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
3+
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
4+
[email protected] with any additional questions or comments.

CONTRIBUTING.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,38 @@ documentation, we greatly value feedback and contributions from our community.
66
Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
77
information to effectively respond to your bug report or contribution.
88

9+
## Adding new features to the SageMaker SSH Helper
10+
11+
SageMaker SSH helper uses Test Driven Development (TDD) methodology to implement its features.
12+
13+
Before implementing new features, check [TODO](TODO) list. The contributors are either working already
14+
on these features or planning to implement them in the future.
15+
16+
To start development, install the library on your local machine:
17+
```shell
18+
pip install '.[test]'
19+
```
20+
21+
Make sure all tests are working:
22+
```shell
23+
cd tests
24+
pytest -m 'not manual' \
25+
-o sagemaker_role=arn:aws:iam::<<YOUR_ACCOUNT_ID>>:role/service-role/<<YOUR_AmazonSageMaker_ExecutionRole>> \
26+
-o kernel_gateway_name=<<YOUR_KERNEL_GATEWAY_NAME>>
27+
```
28+
*Tip:* You can pass your parameters either in command line or set it in `tests/pytest.ini`.
29+
30+
Check `tests/test_end_to_end.py` for automation of steps
31+
required for training / processing and inference:
32+
33+
1. `test_train_e2e()` - a simple training job
34+
2. `test_inference_e2e()` - a training job followed by deployment
35+
3. `test_inference_e2e_mms()` - a training job followed by deployment to a multi-model endpoint
36+
4. `test_processing_e2e()` - a Spark processing job
37+
5. `test_processing_framework_e2e()` - a PyTorch framework processing job
38+
39+
Then write a failing test, put code to make it pass, and make sure other tests are still working to avoid any regression.
40+
941
1042
## Reporting Bugs/Feature Requests
1143

Flows.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## Flow Diagrams
2+
3+
#### Training job
4+
5+
Also compare with the similar flow diagram for [IDE integration with SageMaker Studio](Flows_IDE.md).
6+
7+
The following diagram describes the flow of events for the training job use case:
8+
9+
![Screenshot](images/overall-flow.png)
10+
11+
1. Data Scientists (DS) starts a training job, with SSH Helper Lib as a dependency.
12+
2. The SageMaker Python SDK starts the job, sending the train.py script, and SSH Helper lib as code dependencies.
13+
3. Amazon SageMaker control plain starts the host and the container.
14+
4. The user script (train.py) starts running, starting SSH helper, which fetches AWS SSM agent and other packages
15+
from the Internet, and installs them.
16+
5. SSH Helper starts the SSM agent
17+
6. Through SSM, SSH Helper registers the container as an SSM `managed instance`, and tags it with the DS AWS user/role name.
18+
7. SSH Helper printouts the `managed instance` ID. The log is streamed to CloudWatch Logs.
19+
8. The DS manually/automatically tails the training job logs for the `managed instance` ID.
20+
21+
9-12. Optionally: The DS starts a process to copy over his SSH Public key to the container, needed to set up port forwarding via SSH (e.g., for remote debugging)
22+
23+
13. The DS uses the AWS SSM CLI to start a shell providing the managed instance ID as a parameter.
24+
Optionally, user starts SSM with SSH port forwarding with the helper command
25+
`sm-local-ssh-training connnect <<training_job_name>>`.
26+
14. AWS SSM IAM rules verify that the user is allowed to take this action and that the instance is tagged with the DS's AWS user/role name. Once verified, a session is created with the SSM Agent running in the container.
27+
15. The SSM agent generates a shell by spinning off a new bash shell process.
28+
Optionally, SSH port forwarding starts over SSM connection to let user connect to remote processes over TCP
29+
in both directions.

0 commit comments

Comments
 (0)