From 587015ddc84dfd306e4c2487c3aeb65ae280eab5 Mon Sep 17 00:00:00 2001 From: Niko Oliveira Date: Mon, 19 Aug 2024 11:35:25 -0700 Subject: [PATCH] Update the usage of credentials in the sagemaker test (#41595) The script run within the sagemaker job imports boto, but doesn't actually use it. This change drops the boto import and removes a lot of the credentials management code in the docker image that's built. This simplifies the system test. --- tests/system/providers/amazon/aws/example_sagemaker.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/system/providers/amazon/aws/example_sagemaker.py b/tests/system/providers/amazon/aws/example_sagemaker.py index cd291b79716b1..945bb1eca868d 100644 --- a/tests/system/providers/amazon/aws/example_sagemaker.py +++ b/tests/system/providers/amazon/aws/example_sagemaker.py @@ -77,7 +77,6 @@ # This script will be the entrypoint for the docker image which will handle preprocessing the raw data # NOTE: The following string must remain dedented as it is being written to a file. PREPROCESS_SCRIPT_TEMPLATE = """ -import boto3 import numpy as np import pandas as pd @@ -141,8 +140,6 @@ def _build_and_upload_docker_image(preprocess_script, repository_uri): f""" FROM public.ecr.aws/amazonlinux/amazonlinux COPY {preprocessing_script.name.split('/')[2]} /preprocessing.py - ADD credentials /credentials - ENV AWS_SHARED_CREDENTIALS_FILE=/credentials RUN yum install python3 pip -y RUN pip3 install boto3 pandas requests CMD [ "python3", "/preprocessing.py"] @@ -151,13 +148,12 @@ def _build_and_upload_docker_image(preprocess_script, repository_uri): dockerfile.flush() ecr_region = repository_uri.split(".")[3] + docker_build_and_push_commands = f""" - cp /root/.aws/credentials /tmp/credentials && # login to public ecr repo containing amazonlinux image (public login is always on us east 1) aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws && docker build --platform=linux/amd64 -f {dockerfile.name} -t {repository_uri} /tmp && - rm /tmp/credentials && # login again, this time to the private repo we created to hold that specific image aws ecr get-login-password --region {ecr_region} |