Skip to content

Commit

Permalink
Merge pull request #26 from eitansela/main
Browse files Browse the repository at this point in the history
Fix issue #22 - conda-env-kernel-image example is broken
  • Loading branch information
knaresh authored Nov 17, 2022
2 parents 7f8393f + 0853327 commit 4c0b75e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

examples/conda-env-kernel-image/.idea/conda-env-kernel-image.iml
examples/conda-env-kernel-image/.idea/inspectionProfiles/profiles_settings.xml
examples/conda-env-kernel-image/.idea/modules.xml
examples/conda-env-kernel-image/.idea/vcs.xml
2 changes: 1 addition & 1 deletion examples/conda-env-kernel-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM continuumio/miniconda3:4.9.2

COPY environment.yml .
RUN conda env create -f environment.yml
RUN conda env update -f environment.yml --prune
31 changes: 28 additions & 3 deletions examples/conda-env-kernel-image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The Conda environment must have the appropriate kernel package installed, for e.

### Building the image

Build the Docker image and push to Amazon ECR.
Build the Docker image.
```
# 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
REGION=<aws-region>
Expand All @@ -23,6 +23,31 @@ aws --region ${REGION} ecr create-repository --repository-name smstudio-custom
# Build and push the image
aws --region ${REGION} ecr get-login-password | docker login --username AWS --password-stdin ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom
docker build . -t ${IMAGE_NAME} -t ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}
```

### Local testing

Run the image locally to verify that the kernels in the image are visible to a Kernel Gateway.
```
docker run -it "$IMAGE_NAME" bash
```

Run the container with a KernelGateway to validate that the kernels are visible from the REST endpoint exposed to the host.

```
docker run -it -p 8888:8888 "$IMAGE_NAME" bash -c 'pip install jupyter_kernel_gateway && jupyter-kernelgateway --ip 0.0.0.0 --debug --port 8888'
```

Verify the Kernel Gateway is started successfully (e.g., *[KernelGatewayApp] Jupyter Kernel Gateway at http://0.0.0.0:8888* in the Docker logs) and validate that you can list the kernelspecs in the the running container

```
curl http://0.0.0.0:8888/api/kernelspecs
```


### Pushing the image
Push the Docker image to Amazon ECR
```
docker push ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAGE_NAME}
```

Expand Down Expand Up @@ -61,7 +86,7 @@ Create a Domain, providing the SageMaker Image and AppImageConfig in the Domain
aws --region ${REGION} sagemaker create-domain --cli-input-json file://create-domain-input.json
```

If you have an existing Domain, you can also use the `update-domain`
If you have an existing Domain, you can also use the `update-domain`. Replace the placeholder for Domain ID in `update-domain-input.json`

```bash
aws --region ${REGION} sagemaker update-domain --cli-input-json file://update-domain-input.json
Expand All @@ -82,7 +107,7 @@ docker push ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/smstudio-custom:${IMAG
```


Create new App Image Version.
Create new App Image Version
```
aws --region ${REGION} sagemaker create-image-version \
--image-name ${IMAGE_NAME} \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"KernelGatewayImageConfig": {
"KernelSpecs": [
{
"Name": "conda-env-myenv-py",
"Name": "python3",
"DisplayName": "Python [conda env: myenv]"
}
],
Expand Down
4 changes: 2 additions & 2 deletions examples/conda-env-kernel-image/environment.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: myenv
name: base
channels:
- conda-forge
dependencies:
- python=3.8
- python=3.9
- numpy
- awscli
- boto3
Expand Down

0 comments on commit 4c0b75e

Please sign in to comment.