diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5dcaadb --- /dev/null +++ b/.gitignore @@ -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 diff --git a/examples/conda-env-kernel-image/Dockerfile b/examples/conda-env-kernel-image/Dockerfile index 3e40c00..01ec540 100644 --- a/examples/conda-env-kernel-image/Dockerfile +++ b/examples/conda-env-kernel-image/Dockerfile @@ -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 diff --git a/examples/conda-env-kernel-image/README.md b/examples/conda-env-kernel-image/README.md index 1dadaff..0e28804 100644 --- a/examples/conda-env-kernel-image/README.md +++ b/examples/conda-env-kernel-image/README.md @@ -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= @@ -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} ``` @@ -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 @@ -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} \ diff --git a/examples/conda-env-kernel-image/app-image-config-input.json b/examples/conda-env-kernel-image/app-image-config-input.json index 284f2a0..cb4ed2a 100644 --- a/examples/conda-env-kernel-image/app-image-config-input.json +++ b/examples/conda-env-kernel-image/app-image-config-input.json @@ -3,7 +3,7 @@ "KernelGatewayImageConfig": { "KernelSpecs": [ { - "Name": "conda-env-myenv-py", + "Name": "python3", "DisplayName": "Python [conda env: myenv]" } ], diff --git a/examples/conda-env-kernel-image/environment.yml b/examples/conda-env-kernel-image/environment.yml index 3a0ab8e..e382920 100644 --- a/examples/conda-env-kernel-image/environment.yml +++ b/examples/conda-env-kernel-image/environment.yml @@ -1,8 +1,8 @@ -name: myenv +name: base channels: - conda-forge dependencies: - - python=3.8 + - python=3.9 - numpy - awscli - boto3