git init
python3 -m venv .sagemmakerv01 source .sagemmakerv01/bin/activate python3 -m pip install -r requirements.txt
export $(grep -v '^#' .env | xargs) echo $GITHUB_TOKEN git init git add . git commit -m "first commit" git branch -M main
git remote add origin https://$GITHUB_TOKEN@github.com/jesvin1/AWS_Sagemaker_Assignment_V01.git git push -u origin main
export AWS_DEFAULT_REGION=$(aws configure get region)
echo
echo "export AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION" >> ~/.bashrc echo "export DATA_BUCKET=$DATA_BUCKET" >> ~/.bashrc echo "export PIPELINE_BUCKET=$PIPELINE_BUCKET" >> ~/.bashrc
aws s3 mb "s3://${DATA_BUCKET}" --region $AWS_DEFAULT_REGION
aws s3api put-bucket-versioning --bucket "${DATA_BUCKET}" --versioning-configuration Status=Enabled --region $AWS_DEFAULT_REGION
wget /data https://raw.githubusercontent.com/manifoldailearning/mlops-with-aws-datascientists/main/Section-16-mlops-pipeline/dataset/abalone.csv mv abalone.csv ./data/
aws s3 mb "s3://${PIPELINE_BUCKET}" --region
- Create a Private Repository with repo name as
abalone
- Modify the `trainingjob.json` as follows:
- *Replace Account id with respective Account id*
- *Replace region with `us-east-1`
sed -i "s//${AWS_ACCOUNT_ID}/" model/trainingjob.json sed -i "s//${AWS_DEFAULT_REGION}/" model/trainingjob.json
cd model/
aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin 763104351884.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
docker build --build-arg REGION=$AWS_DEFAULT_REGION -f Dockerfile -t tf_model:1.0 .
cd ..
cd tests/unit_test/
mkdir -p model && \
mkdir -p output
docker run --rm --name 'my_model' \
-v "$PWD/model:/opt/ml/model" \
-v "$PWD/output:/opt/ml/output" \
-v "$PWD/input:/opt/ml/input" tf_model:1.0 train
- Prediction
docker run --rm --name 'my_model' \
-v "$PWD/model:/opt/ml/model" \
-v "$PWD/output:/opt/ml/output" \
-v "$PWD/input:/opt/ml/input" tf_model:1.0 test \
"[[4.400000000000000022e-01,3.449999999999999734e-01,1.000000000000000056e-01,3.659999999999999920e-01,1.219999999999999973e-01,9.049999999999999711e-02,1.199999999999999956e-01,0.000000000000000000e+00,1.000000000000000000e+00,0.000000000000000000e+00]]"
docker run --rm --name 'my_model' \
-p 8080:8080 \
-v "$PWD/model:/opt/ml/model" \
-v "$PWD/output:/opt/ml/output" \
-v "$PWD/input:/opt/ml/input" tf_model:1.0 serve
change the directory in new terminal to unit_test
python3 app_test.py
- Modify threshold value
cd .. cd system_test/ sed -i "s//3.1/" ./buildspec.yml