Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
172 commits
Select commit Hold shift + click to select a range
9780838
Did practice and also did the homework for week 1
May 22, 2022
f90593c
Removed a non necessary file
May 22, 2022
4794610
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 May 25, 2022
d5d09c7
Practiced mlflow experiments and model creation and tracking
May 25, 2022
e08c18f
Practiced mlflow experiments and model creation and tracking
May 25, 2022
5f99a86
Practiced mlflow experiments and model creation and tracking
May 25, 2022
10f5a97
updated the notebook with reading and loading the model
May 27, 2022
f951086
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 May 28, 2022
a5dde76
Finished practicing the week of model management and model regitsry
May 28, 2022
988fd48
Finished week 2 homework
May 28, 2022
fd3636d
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 May 29, 2022
2b06583
Merge branch 'main' into DataTalksClub-main
Nakulbajaj101 Jun 1, 2022
f14df1a
Merge pull request #2 from Nakulbajaj101/DataTalksClub-main
Nakulbajaj101 Jun 1, 2022
abcc3a4
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Jun 5, 2022
40dee9d
Updated file so can pass data between tasks
Jun 5, 2022
983ad0a
resolved conflicts
Jun 5, 2022
5452dda
resolved more conflicts
Jun 5, 2022
3d65356
resolve conflicts
Jun 5, 2022
9eda63d
Merge pull request #3 from Nakulbajaj101/DataTalksClub-main
Nakulbajaj101 Jun 5, 2022
71c05d4
Practiced to spinup local deployment with prefect
Jun 5, 2022
cc5bf94
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Jun 5, 2022
dd4d65f
resolved conflicts with remote
Jun 5, 2022
6e91506
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Jun 6, 2022
9d0ec12
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Jun 7, 2022
1daa948
resolved conflicts
Jun 8, 2022
6e8594f
resolved conflicts
Jun 8, 2022
857f182
Merge pull request #5 from Nakulbajaj101/DataTalksClub-main-2
Nakulbajaj101 Jun 8, 2022
47f388f
resolved conflicts
Jun 8, 2022
d52d8dd
resolved conflicts
Jun 5, 2022
00a8a3f
resolved more conflicts
Jun 5, 2022
3c005fb
resolve conflicts
Jun 5, 2022
ffabafc
Merge pull request #7 from Nakulbajaj101/DataTalksClub-main-2
Nakulbajaj101 Jun 8, 2022
88f0f6a
Notes2 (#90)
froukje Jun 7, 2022
92f1241
Update homework.md
alexeygrigorev Jun 7, 2022
33ca953
Update homework.md
alexeygrigorev Jun 7, 2022
64cd2c9
resolve conflicts
Jun 8, 2022
c598510
resolve conflicts
Jun 8, 2022
26f1724
resolved conflicts
Jun 8, 2022
cd1ce52
Merge pull request #9 from Nakulbajaj101/DataTalksClub-main-3
Nakulbajaj101 Jun 8, 2022
4ee80d1
Did practice and also did the homework for week 1
May 22, 2022
f16a38c
Removed a non necessary file
May 22, 2022
e60558c
resolved conflicts
Jun 8, 2022
4e0dd0b
Practiced mlflow experiments and model creation and tracking
May 25, 2022
d79ac9d
Practiced mlflow experiments and model creation and tracking
May 25, 2022
611d2c4
updated the notebook with reading and loading the model
May 27, 2022
d2474ea
Finished practicing the week of model management and model regitsry
May 28, 2022
d127ed5
resolved conflicts
Jun 8, 2022
cc557df
Updated file so can pass data between tasks
Jun 5, 2022
f664c6c
resolved conflicts
Jun 5, 2022
94b4d42
resolved more conflicts
Jun 5, 2022
156141f
resolve conflicts
Jun 5, 2022
fc84690
Practiced to spinup local deployment with prefect
Jun 5, 2022
343c17e
resolved conflicts with remote
Jun 5, 2022
d2797dc
resolved conflicts
Jun 8, 2022
9ac3cd2
resolved conflicts
Jun 8, 2022
c2d68d8
resolved conflicts
Jun 8, 2022
fa2dc7d
resolved conflicts
Jun 5, 2022
0c904d0
resolved more conflicts
Jun 5, 2022
f6f74c0
resolve conflicts
Jun 5, 2022
a1d9a97
resolved conflicts
Jun 8, 2022
18ef7fd
resolved conflicts
Jun 8, 2022
bbfee51
resolved conflicts
Jun 8, 2022
be2debd
resolved conflicts
Nakulbajaj101 Jun 14, 2022
0ca0930
Merge pull request #11 from Nakulbajaj101/DataTalksClub-main-4
Nakulbajaj101 Jun 14, 2022
65a89fe
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Jun 14, 2022
e8e2110
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Jun 19, 2022
62a577c
Added practice files with hyperopt
Nakulbajaj101 Jun 20, 2022
963e687
logged model correctly to s3
Jun 20, 2022
5eeac0c
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Jun 20, 2022
e2442fc
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Jun 21, 2022
1014a2d
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Jun 22, 2022
fe6e53d
updated homework for week 4
Jun 22, 2022
b1fd103
Added bash scripts and capability to write to S3 bucket
Jun 23, 2022
6216986
practiced streaming prediction data usecase with aws lambda handler
Nakulbajaj101 Jun 27, 2022
57c1270
removed unnessary files
Nakulbajaj101 Jun 27, 2022
2eb66d0
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Jun 27, 2022
74cc83a
Added some streaming test task and practiced backfilling and scoring …
Nakulbajaj101 Jul 2, 2022
0c3ffb4
Resolved conflicts
Nakulbajaj101 Jul 2, 2022
2015f46
Merge pull request #13 from Nakulbajaj101/DataTalksClub-main-5
Nakulbajaj101 Jul 2, 2022
1f01c25
Resolve code conflicts
Nakulbajaj101 Jul 9, 2022
80ae9d7
Merge pull request #15 from Nakulbajaj101/DataTalksClub-main-6
Nakulbajaj101 Jul 9, 2022
2a9cf17
Practicing monitoring
Nakulbajaj101 Jul 11, 2022
ac3e685
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Jul 11, 2022
2beac15
Added file to send data to the service actively
Nakulbajaj101 Jul 11, 2022
5296754
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Jul 13, 2022
9cd573b
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Jul 17, 2022
a50e039
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Jul 18, 2022
eb2af60
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Jul 19, 2022
0d57347
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Jul 21, 2022
137f91e
did practice with lambda handler
Nakulbajaj101 Jul 23, 2022
049916a
Merge pull request #16 from Nakulbajaj101/week6-practice
Nakulbajaj101 Jul 23, 2022
d552ea4
practiced with localstack and lambda
Nakulbajaj101 Jul 23, 2022
f8b8058
Merge pull request #17 from Nakulbajaj101/week6-practice
Nakulbajaj101 Jul 23, 2022
419bcd2
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Jul 23, 2022
a0c46eb
added best practices to project
Nakulbajaj101 Jul 24, 2022
7036261
Learnt about best practices and added git pre commit hooks
Nakulbajaj101 Jul 24, 2022
607d921
Finished week 6 learnings
Nakulbajaj101 Jul 24, 2022
c62c0c5
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Jul 24, 2022
dfc1e26
Updated the homework for week 6
Nakulbajaj101 Jul 25, 2022
731c99f
updated files
Nakulbajaj101 Jul 25, 2022
b836736
updated the files in the repo
Nakulbajaj101 Jul 25, 2022
fb32dea
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Jul 27, 2022
00693c5
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Jul 31, 2022
b47e24b
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Aug 1, 2022
7bd51ed
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Aug 5, 2022
32cbcc8
Updated the code and practiced infrastructure as service
Nakulbajaj101 Aug 7, 2022
a759491
Added quality tests
Nakulbajaj101 Aug 11, 2022
113245f
Added quality tests
Nakulbajaj101 Aug 11, 2022
992d4f4
Added quality tests
Nakulbajaj101 Aug 11, 2022
1266502
Added quality tests
Nakulbajaj101 Aug 11, 2022
9af5a29
Added integration tests and updated github actions and added other pi…
Nakulbajaj101 Aug 11, 2022
5267663
Added integration tests and updated github actions and added other pi…
Nakulbajaj101 Aug 11, 2022
596796d
Added integration tests and updated github actions and added other pi…
Nakulbajaj101 Aug 11, 2022
5ff705b
updated the change directory
Nakulbajaj101 Aug 11, 2022
49730c9
fixed the docker compose file
Nakulbajaj101 Aug 11, 2022
6a30ae0
fixed the docker compose file and added 5 seconds time
Nakulbajaj101 Aug 11, 2022
7b7459f
Added model artifacts and also ensuring if tests fail then github wor…
Nakulbajaj101 Aug 11, 2022
a3c3f33
Added status of action to be performed
Nakulbajaj101 Aug 11, 2022
0eb8e1f
updated docker compose file to read path as per repo location
Nakulbajaj101 Aug 11, 2022
e090b68
Merge pull request #18 from Nakulbajaj101/feature/test-github-actions
Nakulbajaj101 Aug 11, 2022
ed36a17
Added terraform plan to make file and added more configuration to git…
Nakulbajaj101 Aug 13, 2022
5e4993c
removed profile from terraform provider
Nakulbajaj101 Aug 13, 2022
ff62e4b
Added deploy workflow
Nakulbajaj101 Aug 14, 2022
b77a8c1
Updated the output of bucket from name to id
Nakulbajaj101 Aug 14, 2022
e56250d
fixed the error of output for bucket
Nakulbajaj101 Aug 14, 2022
bc9a2fa
Updated the quality checks as it is failing unnecassarily
Nakulbajaj101 Aug 14, 2022
e6327a6
updated the build
Nakulbajaj101 Aug 14, 2022
bab13c9
Updated the piplock and pipfile
Nakulbajaj101 Aug 14, 2022
2c2ca41
updated the pipenv environment
Nakulbajaj101 Aug 14, 2022
cebd4a2
Merge pull request #20 from Nakulbajaj101/feature/added-deploy-github…
Nakulbajaj101 Aug 14, 2022
00da98d
updated the make script names and added comments
Nakulbajaj101 Aug 14, 2022
e1c87de
Merge pull request #21 from Nakulbajaj101/feature/added-deploy-github…
Nakulbajaj101 Aug 14, 2022
a131970
moved ecr login option earlier
Nakulbajaj101 Aug 14, 2022
1eda437
Updated pipenv version for stability reasons
Nakulbajaj101 Aug 14, 2022
5ac1bc5
Merge pull request #22 from Nakulbajaj101/feature/added-deploy-github…
Nakulbajaj101 Aug 14, 2022
e856d4d
Updated default region
Nakulbajaj101 Aug 14, 2022
4b13210
added a placeholder for notes
Nakulbajaj101 Aug 14, 2022
e1ad0ae
added a new readme for code-practice repo
Nakulbajaj101 Aug 14, 2022
ab22267
Merge pull request #23 from Nakulbajaj101/feature/added-deploy-github…
Nakulbajaj101 Aug 14, 2022
2b20525
Updated the bucket entry to dev bucket and also updated the terraform…
Nakulbajaj101 Aug 14, 2022
835d383
Merge pull request #24 from Nakulbajaj101/feature/added-deploy-github…
Nakulbajaj101 Aug 14, 2022
2de27c6
Updated the bucket entry to dev bucket and also updated the terraform…
Nakulbajaj101 Aug 14, 2022
f531abb
Merge pull request #25 from Nakulbajaj101/feature/added-deploy-github…
Nakulbajaj101 Aug 14, 2022
7adb7e3
Added the status badge
Nakulbajaj101 Aug 14, 2022
105d3ed
Merge pull request #26 from Nakulbajaj101/feature/added-deploy-github…
Nakulbajaj101 Aug 14, 2022
abe671e
updated the policy name as was same for stage and prod
Nakulbajaj101 Aug 14, 2022
58f2840
Merge pull request #27 from Nakulbajaj101/feature/added-deploy-github…
Nakulbajaj101 Aug 14, 2022
0a53b08
updated some values
Nakulbajaj101 Aug 14, 2022
c0b7da9
Merge pull request #28 from Nakulbajaj101/feature/added-deploy-github…
Nakulbajaj101 Aug 14, 2022
91abf5b
updated some values
Nakulbajaj101 Aug 14, 2022
8955470
Merge pull request #29 from Nakulbajaj101/feature/added-deploy-github…
Nakulbajaj101 Aug 14, 2022
bf796ee
fixed the output issue of gitub actions
Nakulbajaj101 Aug 14, 2022
864bc5e
Merge pull request #30 from Nakulbajaj101/feature/added-deploy-github…
Nakulbajaj101 Aug 14, 2022
7316d76
fixed the output issue of gitub actions
Nakulbajaj101 Aug 14, 2022
4af4dd3
Merge pull request #31 from Nakulbajaj101/feature/added-deploy-github…
Nakulbajaj101 Aug 14, 2022
4b3e681
Updated the acl of the bucket as well as ensured deploy only gets tri…
Nakulbajaj101 Aug 14, 2022
14fc9d6
Merge pull request #32 from Nakulbajaj101/feature/added-deploy-github…
Nakulbajaj101 Aug 14, 2022
c79f0bb
Updated the acl of the bucket as well as ensured deploy only gets tri…
Nakulbajaj101 Aug 14, 2022
84198cc
Updated the acl of the bucket as well as ensured deploy only gets tri…
Nakulbajaj101 Aug 14, 2022
8594b01
Merge pull request #33 from Nakulbajaj101/feature/added-deploy-github…
Nakulbajaj101 Aug 14, 2022
6a8a1fd
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Aug 26, 2022
4040dec
updated the readme
Nakulbajaj101 Aug 27, 2022
706839a
updated the stream name
Nakulbajaj101 Aug 27, 2022
95d4d27
Merge pull request #34 from Nakulbajaj101/develop/update-readme
Nakulbajaj101 Aug 27, 2022
4ca4f50
updated the stream name in readme
Nakulbajaj101 Aug 27, 2022
f8706da
resolved conflicts
Nakulbajaj101 Sep 19, 2022
a855fc4
Merge pull request #35 from Nakulbajaj101/task/update-repo
Nakulbajaj101 Sep 19, 2022
5ad84cc
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Sep 24, 2022
362ad62
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Nov 9, 2022
0aaa594
Merge branch 'DataTalksClub:main' into main
Nakulbajaj101 Apr 25, 2023
05d67c3
Updated the files
Nakulbajaj101 May 18, 2025
cd10e33
stopping the ci builds
Nakulbajaj101 May 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
207 changes: 118 additions & 89 deletions .github/workflows/cd-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,99 +1,128 @@
name: CD-Deploy
on:
push:
branches:
- 'develop'
# paths:
# - '06-best-practices/code/**'
# name: CD_DEPLOY
# on:
# push:
# branches:
# - 'main'
# paths:
# - '06-best-practices/code-practice/**'
# env:
# AWS_DEFAULT_REGION: 'us-east-2'
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# RUN_ID: '20c7e3f3b3584b769bf6cacd4643d43d'

jobs:
build-push-deploy:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: "eu-west-1"
- uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
# jobs:
# deploy:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Repo
# uses: actions/checkout@v2

# - name: Setup terraform
# uses: hashicorp/setup-terraform@v2
# with:
# terraform_version: 1.0.0
# terraform_wrapper: false

# Define the infrastructure
- name: TF plan
id: tf-plan
working-directory: '06-best-practices/code/infrastructure'
run: |
terraform init -backend-config="key=mlops-zoomcamp-prod.tfstate" -reconfigure && terraform plan -var-file=vars/prod.tfvars
# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
# aws-region: ${{ env.AWS_DEFAULT_REGION }}

# - name: Login to Amazon ECR
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v1

- name: TF Apply
id: tf-apply
working-directory: '06-best-practices/code/infrastructure'
if: ${{ steps.tf-plan.outcome }} == 'success'
run: |
terraform apply -auto-approve -var-file=vars/prod.tfvars
echo "::set-output name=ecr_repo::$(terraform output ecr_repo | xargs)"
echo "::set-output name=predictions_stream_name::$(terraform output predictions_stream_name | xargs)"
echo "::set-output name=model_bucket::$(terraform output model_bucket | xargs)"
echo "::set-output name=lambda_function::$(terraform output lambda_function | xargs)"
# - name: TF plan-stage
# id: tf-plan-stage
# working-directory: '06-best-practices/code-practice'
# run: make plan_stage

# Build-Push
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
# - name: TF apply-stage
# id: tf-apply-stage
# working-directory: '06-best-practices/code-practice/deploy'
# if: ${{ steps.tf-plan-stage.outcome }} == 'success'
# env:
# ENVIRONMENT: "stage"
# TEST_RUN: "False"
# run: |
# echo "Initialing terraform"
# terraform init -backend-config="key=mlops-zoomcamp-${{ env.ENVIRONMENT }}.tfstate" --reconfigure

- name: Build, tag, and push image to Amazon ECR
id: build-image-step
working-directory: "06-best-practices/code"
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ steps.tf-apply.outputs.ecr_repo }}
IMAGE_TAG: "latest" # ${{ github.sha }}
run: |
docker build -t ${ECR_REGISTRY}/${ECR_REPOSITORY}:${IMAGE_TAG} .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image_uri::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
# echo "Running terraform apply"
# TF_VAR_run_id=${{ env.RUN_ID }} TF_VAR_test_run=${{ env.TEST_RUN }} terraform apply -auto-approve -var-file="vars/${{ env.ENVIRONMENT }}.tfvars"

# Deploy
- name: Get model artifacts
# The steps here are not suited for production.
# In practice, retrieving the latest model version or RUN_ID from a service like MLflow or DVC can also be integrated into a CI/CD pipeline.
# But due to the limited scope of this workshop, we would be keeping things simple.
# In practice, you would also have a separate training pipeline to write new model artifacts to your Model Bucket in Prod.
# echo "::set-output name=ride_prediction_lambda::$(terraform output ride_prediction_lambda)"
# echo "::set-output name=ride_prediction_bucket::$(terraform output ride_prediction_bucket)"
# echo "::set-output name=kinesis_source_stream::$(terraform output kinesis_source_stream_name)"
# echo "::set-output name=kinesis_output_stream::$(terraform output kinesis_output_stream_name)"
# echo "::set-output name=ecr_repo::$(terraform output ecr_repo)"
# echo "::set-output name=run_id::$(terraform output run_id)"

id: get-model-artifacts
working-directory: "06-best-practices/code"
env:
MODEL_BUCKET_DEV: "mlflow-models-alexey"
MODEL_BUCKET_PROD: ${{ steps.tf-apply.outputs.model_bucket }}
run: |
export RUN_ID=$(aws s3api list-objects-v2 --bucket ${MODEL_BUCKET_DEV} \
--query 'sort_by(Contents, &LastModified)[-1].Key' --output=text | cut -f2 -d/)
aws s3 sync s3://${MODEL_BUCKET_DEV} s3://${MODEL_BUCKET_PROD}
echo "::set-output name=run_id::${RUN_ID}"
# echo "Image name deployed is $(terraform output image_uri)"

- name: Update Lambda
env:
LAMBDA_FUNCTION: ${{ steps.tf-apply.outputs.lambda_function }}
PREDICTIONS_STREAM_NAME: ${{ steps.tf-apply.outputs.predictions_stream_name }}
MODEL_BUCKET: ${{ steps.tf-apply.outputs.model_bucket }}
RUN_ID: ${{ steps.get-model-artifacts.outputs.run_id }}
run: |
variables="{ \
PREDICTIONS_STREAM_NAME=$PREDICTIONS_STREAM_NAME, MODEL_BUCKET=$MODEL_BUCKET, RUN_ID=$RUN_ID \
}"
# - name: TF plan-prod
# id: tf-plan-prod
# working-directory: '06-best-practices/code-practice'
# if: ${{ steps.tf-apply-stage.outcome }} == 'success'
# run: make plan_prod

STATE=$(aws lambda get-function --function-name $LAMBDA_FUNCTION --region "eu-west-1" --query 'Configuration.LastUpdateStatus' --output text)
while [[ "$STATE" == "InProgress" ]]
do
echo "sleep 5sec ...."
sleep 5s
STATE=$(aws lambda get-function --function-name $LAMBDA_FUNCTION --region "eu-west-1" --query 'Configuration.LastUpdateStatus' --output text)
echo $STATE
done
# - name: TF apply-prod
# id: tf-apply-prod
# working-directory: '06-best-practices/code-practice/deploy'
# if: ${{ steps.tf-plan-prod.outcome }} == 'success'
# env:
# ENVIRONMENT: "prod"
# TEST_RUN: "False"
# run: |
# echo "Initialing terraform"
# terraform init -backend-config="key=mlops-zoomcamp-${{ env.ENVIRONMENT }}.tfstate" --reconfigure

aws lambda update-function-configuration --function-name $LAMBDA_FUNCTION \
--environment "Variables=${variables}"
# echo "Running terraform apply"
# TF_VAR_run_id=${{ env.RUN_ID }} TF_VAR_test_run=${{ env.TEST_RUN }} terraform apply -auto-approve -var-file="vars/${{ env.ENVIRONMENT }}.tfvars"

# echo "::set-output name=ride_prediction_lambda::$(terraform output ride_prediction_lambda)"
# echo "::set-output name=ride_prediction_bucket::$(terraform output ride_prediction_bucket)"
# echo "::set-output name=kinesis_source_stream::$(terraform output kinesis_source_stream_name)"
# echo "::set-output name=kinesis_output_stream::$(terraform output kinesis_output_stream_name)"
# echo "Image name deployed is $(terraform output image_uri)"
# echo "::set-output name=ecr_repo::$(terraform output ecr_repo)"
# echo "::set-output name=run_id::$(terraform output run_id)"

# - name: Build, tag and push image stage
# working-directory: '06-best-practices/code-practice'
# env:
# REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# REPOSITORY: ${{ steps.tf-apply-stage.outputs.ecr_repo }}
# IMAGE_TAG: "latest"
# TEST_RUN: "False"
# run: |
# docker build --build-arg STREAM_NAME_ARG=${{ steps.tf-apply-stage.outputs.kinesis_output_stream }} --build-arg RUN_ID_ARG=${{ steps.tf-apply-stage.outputs.run_id }} --build-arg TEST_RUN_ARG=${{ env.TEST_RUN }} --build-arg MODEL_BUCKET_ARG=${{ steps.tf-apply-stage.outputs.ride_prediction_bucket }} -t ${REGISTRY}/${{ env.REPOSITORY }}:${IMAGE_TAG} .
# docker push ${REGISTRY}/${{ env.REPOSITORY }}:${IMAGE_TAG}

# - name: Build, tag and push image prod
# working-directory: '06-best-practices/code-practice'
# env:
# REGISTRY: ${{ steps.login-ecr.outputs.registry }}
# REPOSITORY: ${{ steps.tf-apply-prod.outputs.ecr_repo }}
# IMAGE_TAG: "latest"
# TEST_RUN: "False"
# run: |
# docker build --build-arg STREAM_NAME_ARG=${{ steps.tf-apply-prod.outputs.kinesis_output_stream }} --build-arg RUN_ID_ARG=${{ steps.tf-apply-prod.outputs.run_id }} --build-arg TEST_RUN_ARG=${{ env.TEST_RUN }} --build-arg MODEL_BUCKET_ARG=${{ steps.tf-apply-prod.outputs.ride_prediction_bucket }} -t ${REGISTRY}/${{ env.REPOSITORY }}:${IMAGE_TAG} .
# docker push ${REGISTRY}/${{ env.REPOSITORY }}:${IMAGE_TAG}

# - name: Update bucket artifacts stage
# env:
# MODEL_BUCKET_DEV: "mlops-zoomcamp-nakul-dev"
# MODEL_BUCKET: ${{ steps.tf-apply-stage.outputs.ride_prediction_bucket }}
# run: |
# aws s3 sync s3://${{ env.MODEL_BUCKET_DEV }} s3://${{ env.MODEL_BUCKET }}

# - name: Update bucket artifacts prod
# env:
# MODEL_BUCKET_DEV: "mlops-zoomcamp-nakul-dev"
# MODEL_BUCKET: ${{ steps.tf-apply-prod.outputs.ride_prediction_bucket }}
# run: |
# aws s3 sync s3://${{ env.MODEL_BUCKET_DEV }} s3://${{ env.MODEL_BUCKET }}
125 changes: 60 additions & 65 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,60 @@
name: CI-Tests
on:
pull_request:
branches:
- 'develop'
paths:
- '06-best-practices/code/**'

env:
AWS_DEFAULT_REGION: 'eu-west-1'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install dependencies
working-directory: "06-best-practices/code"
run: pip install pipenv && pipenv install --dev

- name: Run Unit tests
working-directory: "06-best-practices/code"
run: pipenv run pytest tests/

- name: Lint
working-directory: "06-best-practices/code"
run: pipenv run pylint --recursive=y .

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}

- name: Integration Test
working-directory: '06-best-practices/code/integraton-test'
run: |
. run.sh

tf-plan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}

- uses: hashicorp/setup-terraform@v2

- name: TF plan
id: plan
working-directory: '06-best-practices/code/infrastructure'
run: |
terraform init -backend-config="key=mlops-zoomcamp-prod.tfstate" --reconfigure && terraform plan --var-file vars/prod.tfvars
# name: CI_TESTS
# on:
# pull_request:
# branches:
# - main
# paths:
# - '06-best-practices/code-practice/**'
# env:
# AWS_DEFAULT_REGION: 'us-east-2'
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

# jobs:
# test:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Repo
# uses: actions/checkout@v2
# - name: Setup Python 3.9
# uses: actions/setup-python@v2
# with:
# python-version: 3.9

# - name: Install dependencies
# working-directory: '06-best-practices/code-practice'
# run: pip install pipenv==2022.8.5 && pipenv install --dev

# - name: Run Quality tests
# working-directory: '06-best-practices/code-practice'
# run: make quality_checks

# - name: Run Integration tests
# working-directory: '06-best-practices/code-practice'
# run: make integration_tests

# tf-plan:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout Repo
# uses: actions/checkout@v2

# - name: Setup terraform
# uses: hashicorp/setup-terraform@v2
# with:
# terraform_version: 1.0.0

# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
# aws-region: ${{ env.AWS_DEFAULT_REGION }}

# - name: TF plan-stage
# working-directory: '06-best-practices/code-practice'
# run: make plan_stage

# - name: TF plan-prod
# working-directory: '06-best-practices/code-practice'
# run: make plan_prod
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ data/

.venv
venv

.idea
**/artifacts/
**/models/
Expand Down
Loading