Skip to content

Commit 23c70d6

Browse files
author
Naresh Kumar Kolloju
committed
Improve documentation to clarify How to update Image
**Description** Improves README by provding instruction on: * How to update the image with SageMaker studio * Clarifies why Role Arn is necessary * Add instruction on creating ECR Repo to every README
1 parent a0a0b16 commit 23c70d6

File tree

8 files changed

+282
-24
lines changed

8 files changed

+282
-24
lines changed

examples/conda-env-kernel-image/README.md

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,26 @@ Build the Docker image and push to Amazon ECR.
1414
# Modify these as required. The Docker registry endpoint can be tuned based on your current region from https://docs.aws.amazon.com/general/latest/gr/ecr.html#ecr-docker-endpoints
1515
REGION=<aws-region>
1616
ACCOUNT_ID=<aws-account-id>
17+
IMAGE_NAME=conda-env-kernel
1718
19+
# Create ECR Repository. Ignore if it exists. For simplcity, all examples in the repo
20+
# use same ECR repo with different image tags
21+
aws --region ${REGION} ecr create-repository --repository-name smstudio-custom
1822
1923
# Build and push the image
20-
IMAGE_NAME=conda-env-kernel
2124
aws --region ${REGION} ecr get-login-password | docker login --username AWS --password-stdin ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom
2225
docker build . -t ${IMAGE_NAME} -t ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}
2326
docker push ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}
2427
```
2528

2629
### Using with SageMaker Studio
27-
28-
Create a SageMaker Image (SMI) with the image in ECR.
30+
Create a SageMaker Image (SMI) with the image in ECR. Request parameter RoleArn value is used to get
31+
ECR image information when and Image version is created. After creating Image, create an Image Version during which
32+
SageMaker stores image metadata like SHA etc. Everytime an image is updated in ECR, a new image version should be created.
33+
See [Update Image](#updating-image-with-sageMaker-studio)
2934

3035
```bash
31-
# Role in your account to be used for SMI. Modify as required.
36+
# Role in your account to be used for SageMakerImage. Modify as required.
3237

3338
ROLE_ARN=arn:aws:iam::${ACCOUNT_ID}:role/RoleName
3439
aws --region ${REGION} sagemaker create-image \
@@ -62,4 +67,30 @@ If you have an existing Domain, you can also use the `update-domain`
6267
aws --region ${REGION} sagemaker update-domain --cli-input-json file://update-domain-input.json
6368
```
6469

65-
Create a User Profile, and start a Notebook using the SageMaker Studio launcher.
70+
Create a User Profile, and start a Notebook using the SageMaker Studio launcher.
71+
72+
### Update Image with SageMaker Studio
73+
If you found an issue with your image or want to update Image with new features, Use following steps
74+
75+
Re-Build and push the image to ECR
76+
77+
```
78+
# Build and push the image
79+
aws --region ${REGION} ecr get-login-password | docker login --username AWS --password-stdin ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom
80+
docker build . -t ${IMAGE_NAME} -t ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}
81+
docker push ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}
82+
```
83+
84+
85+
Create new App Image Version.
86+
```
87+
aws --region ${REGION} sagemaker create-image-version \
88+
--image-name ${IMAGE_NAME} \
89+
--base-image "${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}"
90+
91+
# Verify the image-version is created successfully. Do NOT proceed if image-version is in CREATE_FAILED state or in any other state apart from CREATED.
92+
aws --region ${REGION} sagemaker describe-image-version --image-name ${IMAGE_NAME}
93+
```
94+
95+
96+
Re-Create App in SageMaker studio.

examples/echo-kernel-image/README.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ Build the Docker image and push to Amazon ECR.
1111
# Modify these as required. The Docker registry endpoint can be tuned based on your current region from https://docs.aws.amazon.com/general/latest/gr/ecr.html#ecr-docker-endpoints
1212
REGION=<aws-region>
1313
ACCOUNT_ID=<account-id>
14+
IMAGE_NAME=custom-echo-kernel
1415
16+
# Create ECR Repository. Ignore if it exists. For simplcity, all examples in the repo
17+
# use same ECR repo with different image tags
18+
aws --region ${REGION} ecr create-repository --repository-name smstudio-custom
1519
1620
# Build the image
17-
IMAGE_NAME=custom-echo-kernel
1821
aws --region ${REGION} ecr get-login-password | docker login --username AWS --password-stdin ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom
1922
docker build . -t ${IMAGE_NAME} -t ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}
2023
```
@@ -25,7 +28,10 @@ docker push ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAG
2528

2629
### Using with SageMaker Studio
2730

28-
Create a SageMaker Image with the image in ECR.
31+
Create a SageMaker Image (SMI) with the image in ECR. Request parameter RoleArn value is used to get
32+
ECR image information when and Image version is created. After creating Image, create an Image Version during which
33+
SageMaker stores image metadata like SHA etc. Everytime an image is updated in ECR, a new image version should be created.
34+
See [Update Image](#updating-image-with-sageMaker-studio)
2935

3036
```
3137
# Role in your account to be used for the SageMaker Image
@@ -60,4 +66,31 @@ If you have an existing Domain, you can also use the `update-domain`
6066

6167
```
6268
aws --region ${REGION} sagemaker update-domain --cli-input-json file://update-domain-input.json
63-
```
69+
```
70+
71+
### Update Image with SageMaker Studio
72+
If you found an issue with your image or want to update Image with new features, Use following steps
73+
74+
75+
Re-Build and push the image to ECR
76+
77+
```
78+
# Build and push the image
79+
aws --region ${REGION} ecr get-login-password | docker login --username AWS --password-stdin ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom
80+
docker build . -t ${IMAGE_NAME} -t ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}
81+
docker push ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}
82+
```
83+
84+
85+
Create new App Image Version.
86+
```
87+
aws --region ${REGION} sagemaker create-image-version \
88+
--image-name ${IMAGE_NAME} \
89+
--base-image "${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}"
90+
91+
# Verify the image-version is created successfully. Do NOT proceed if image-version is in CREATE_FAILED state or in any other state apart from CREATED.
92+
aws --region ${REGION} sagemaker describe-image-version --image-name ${IMAGE_NAME}
93+
```
94+
95+
96+
Re-Create App in SageMaker studio.

examples/jupyter-docker-stacks-julia-image/README.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ Build the Docker image and push to Amazon ECR.
1212
# Modify these as required. The Docker registry endpoint can be tuned based on your current region from https://docs.aws.amazon.com/general/latest/gr/ecr.html#ecr-docker-endpoints
1313
REGION=<aws-region>
1414
ACCOUNT_ID=<aws-account-id>
15+
IMAGE_NAME=julia-datascience
1516
17+
# Create ECR Repository. Ignore if it exists. For simplcity, all examples in the repo
18+
# use same ECR repo with different image tags
19+
aws --region ${REGION} ecr create-repository --repository-name smstudio-custom
1620
1721
# Build the image
18-
IMAGE_NAME=julia-datascience
1922
aws --region ${REGION} ecr get-login-password | docker login --username AWS --password-stdin ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom
2023
docker build . -t ${IMAGE_NAME} -t ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}
2124
```
@@ -26,7 +29,10 @@ docker push ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAG
2629

2730
### Using with SageMaker Studio
2831

29-
Create a SageMaker Image (SMI) with the image in ECR.
32+
Create a SageMaker Image (SMI) with the image in ECR. Request parameter RoleArn value is used to get
33+
ECR image information when and Image version is created. After creating Image, create an Image Version during which
34+
SageMaker stores image metadata like SHA etc. Everytime an image is updated in ECR, a new image version should be created.
35+
See [Update Image](#updating-image-with-sageMaker-studio)
3036

3137
```
3238
# Role in your account to be used for SMI. Modify as required.
@@ -65,4 +71,30 @@ If you have an existing Domain, you can also use the `update-domain`
6571
aws --region ${REGION} sagemaker update-domain --cli-input-json file://update-domain-input.json
6672
```
6773

68-
Now create a user, and start a Notebook using the SageMaker Studio launcher
74+
Now create a user, and start a Notebook using the SageMaker Studio launcher
75+
76+
### Update Image with SageMaker Studio
77+
If you found an issue with your image or want to update Image with new features, Use following steps
78+
79+
Re-Build and push the image to ECR
80+
81+
```
82+
# Build and push the image
83+
aws --region ${REGION} ecr get-login-password | docker login --username AWS --password-stdin ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom
84+
docker build . -t ${IMAGE_NAME} -t ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}
85+
docker push ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}
86+
```
87+
88+
89+
Create new App Image Version.
90+
```
91+
aws --region ${REGION} sagemaker create-image-version \
92+
--image-name ${IMAGE_NAME} \
93+
--base-image "${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}"
94+
95+
# Verify the image-version is created successfully. Do NOT proceed if image-version is in CREATE_FAILED state or in any other state apart from CREATED.
96+
aws --region ${REGION} sagemaker describe-image-version --image-name ${IMAGE_NAME}
97+
```
98+
99+
100+
Re-Create App in SageMaker studio.

examples/python-poetry-image/README.md

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,25 @@ Build the Docker image and push to Amazon ECR.
1111
# Modify these as required. The Docker registry endpoint can be tuned based on your current region from https://docs.aws.amazon.com/general/latest/gr/ecr.html#ecr-docker-endpoints
1212
REGION=<aws-region>
1313
ACCOUNT_ID=<account-id>
14+
IMAGE_NAME=custom-poetry-kernel
15+
16+
# Create ECR Repository. Ignore if it exists. For simplcity, all examples in the repo
17+
# use same ECR repo with different image tags
18+
aws --region ${REGION} ecr create-repository --repository-name smstudio-custom
1419
1520
# Build the image
16-
IMAGE_NAME=custom-poetry-kernel
1721
aws --region ${REGION} ecr get-login-password | docker login --username AWS --password-stdin ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom
1822
docker build . -t ${IMAGE_NAME} -t ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}
19-
```
2023
21-
```
2224
docker push ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}
2325
```
2426

2527
### Using it with SageMaker Studio
2628

27-
Create a SageMaker Image with the image in ECR.
29+
Create a SageMaker Image (SMI) with the image in ECR. Request parameter RoleArn value is used to get
30+
ECR image information when and Image version is created. After creating Image, create an Image Version during which
31+
SageMaker stores image metadata like SHA etc. Everytime an image is updated in ECR, a new image version should be created.
32+
See [Update Image](#updating-image-with-sageMaker-studio)
2833

2934
```
3035
# Role in your account to be used for the SageMaker Image
@@ -61,7 +66,33 @@ If you have an existing Domain, you can use the `update-domain` command.
6166
aws --region ${REGION} sagemaker update-domain --cli-input-json file://update-domain-input.json
6267
```
6368

69+
### Update Image with SageMaker Studio
70+
If you found an issue with your image or want to update Image with new features, Use following steps
71+
72+
Re-Build and push the image to ECR
73+
74+
```
75+
# Build and push the image
76+
aws --region ${REGION} ecr get-login-password | docker login --username AWS --password-stdin ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom
77+
docker build . -t ${IMAGE_NAME} -t ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}
78+
docker push ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}
79+
```
80+
81+
82+
Create new App Image Version.
83+
```
84+
aws --region ${REGION} sagemaker create-image-version \
85+
--image-name ${IMAGE_NAME} \
86+
--base-image "${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}"
87+
88+
# Verify the image-version is created successfully. Do NOT proceed if image-version is in CREATE_FAILED state or in any other state apart from CREATED.
89+
aws --region ${REGION} sagemaker describe-image-version --image-name ${IMAGE_NAME}
90+
```
91+
92+
93+
Re-Create App in SageMaker studio.
94+
6495
### Notes
6596

6697
* Since SageMaker Studio overrides `ENTRYPOINT` and `CMD` instructions (see [documentation](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-byoi-specs.html)), this sample disables the Poetry virtual environments as recommended in their [FAQ](https://python-poetry.org/docs/faq/#i-dont-want-poetry-to-manage-my-virtual-environments-can-i-disable-it).
67-
* Note that `ipykernel` must be installed on custom images for SageMaker Studio. If this package is not installed by default on the parent image, then it should be included in the `pyproject.toml` file.
98+
* Note that `ipykernel` must be installed on custom images for SageMaker Studio. If this package is not installed by default on the parent image, then it should be included in the `pyproject.toml` file.

examples/r-image/README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ Build the Docker image and push to Amazon ECR.
1616
REGION=<aws-region>
1717
ACCOUNT_ID=<account-id>
1818
19+
# Create ECR Repository. Ignore if it exists. For simplcity, all examples in the repo
20+
# use same ECR repo with different image tags
21+
aws --region ${REGION} ecr create-repository --repository-name smstudio-custom
22+
1923
2024
# Build the image
2125
IMAGE_NAME=custom-r
@@ -29,7 +33,10 @@ docker push ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAG
2933

3034
### Using with SageMaker Studio
3135

32-
Create a SageMaker Image with the image in ECR.
36+
Create a SageMaker Image (SMI) with the image in ECR. Request parameter RoleArn value is used to get
37+
ECR image information when and Image version is created. After creating Image, create an Image Version during which
38+
SageMaker stores image metadata like SHA etc. Everytime an image is updated in ECR, a new image version should be created.
39+
See [Update Image](#updating-image-with-sageMaker-studio)
3340

3441
```
3542
# Role in your account to be used for the SageMaker Image
@@ -64,4 +71,30 @@ If you have an existing Domain, you can also use the `update-domain`
6471

6572
```
6673
aws --region ${REGION} sagemaker update-domain --cli-input-json file://update-domain-input.json
67-
```
74+
```
75+
76+
### Update Image with SageMaker Studio
77+
If you found an issue with your image or want to update Image with new features, Use following steps
78+
79+
Re-Build and push the image to ECR
80+
81+
```
82+
# Build and push the image
83+
aws --region ${REGION} ecr get-login-password | docker login --username AWS --password-stdin ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom
84+
docker build . -t ${IMAGE_NAME} -t ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}
85+
docker push ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}
86+
```
87+
88+
89+
Create new App Image Version.
90+
```
91+
aws --region ${REGION} sagemaker create-image-version \
92+
--image-name ${IMAGE_NAME} \
93+
--base-image "${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}"
94+
95+
# Verify the image-version is created successfully. Do NOT proceed if image-version is in CREATE_FAILED state or in any other state apart from CREATED.
96+
aws --region ${REGION} sagemaker describe-image-version --image-name ${IMAGE_NAME}
97+
```
98+
99+
100+
Re-Create App in SageMaker studio.

examples/rapids-image/README.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Build the Docker image and push to Amazon ECR.
1414
REGION=<aws-region>
1515
ACCOUNT_ID=<account-id>
1616
17+
# Create ECR Repository. Ignore if it exists. For simplcity, all examples in the repo
18+
# use same ECR repo with different image tags
19+
aws --region ${REGION} ecr create-repository --repository-name smstudio-custom
20+
1721
1822
# Build the image
1923
IMAGE_NAME=custom-rapids
@@ -38,7 +42,10 @@ sm-docker build .
3842
```
3943

4044

41-
Create a SageMaker Image with the image in ECR.
45+
Create a SageMaker Image (SMI) with the image in ECR. Request parameter RoleArn value is used to get
46+
ECR image information when and Image version is created. After creating Image, create an Image Version during which
47+
SageMaker stores image metadata like SHA etc. Everytime an image is updated in ECR, a new image version should be created.
48+
See [Update Image](#updating-image-with-sageMaker-studio)
4249

4350
```
4451
# Role in your account to be used for the SageMaker Image
@@ -75,6 +82,32 @@ If you have an existing Domain, you can also use the `update-domain`
7582
aws --region ${REGION} sagemaker update-domain --cli-input-json file://update-domain-input.json
7683
```
7784

85+
### Update Image with SageMaker Studio
86+
If you found an issue with your image or want to update Image with new features, Use following steps
87+
88+
Re-Build and push the image to ECR
89+
90+
```
91+
# Build and push the image
92+
aws --region ${REGION} ecr get-login-password | docker login --username AWS --password-stdin ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom
93+
docker build . -t ${IMAGE_NAME} -t ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}
94+
docker push ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}
95+
```
96+
97+
98+
Create new App Image Version.
99+
```
100+
aws --region ${REGION} sagemaker create-image-version \
101+
--image-name ${IMAGE_NAME} \
102+
--base-image "${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}"
103+
104+
# Verify the image-version is created successfully. Do NOT proceed if image-version is in CREATE_FAILED state or in any other state apart from CREATED.
105+
aws --region ${REGION} sagemaker describe-image-version --image-name ${IMAGE_NAME}
106+
```
107+
108+
109+
Re-Create App in SageMaker studio.
110+
78111
### Note
79112

80113
- Please use the included `Python [conda env:rapids]' kernel within Studio

0 commit comments

Comments
 (0)