Skip to content

Instantly share code, notes, and snippets.

View patrickbrus's full-sized avatar

patrickbrus

View GitHub Profile
CloudFormationElasticBeanstalkApplication:
Type: AWS::ElasticBeanstalk::Application
Properties:
ApplicationName: !Sub ${ElasticApplicationName}-app
CloudFormationElasticBeanstalkEvnironmentStaging:
Type: AWS::ElasticBeanstalk::Environment
Properties:
ApplicationName: !Ref CloudFormationElasticBeanstalkApplication
EnvironmentName: !Sub ${ElasticApplicationName}-env-staging
CodeBuildDockerBirdsClassifierImage:
Type: AWS::CodeBuild::Project
Properties:
Name: !Ref CodeBuildProjectName
ServiceRole: !Ref CodeBuildBirdsClassifierImageServiceRole
Artifacts:
Type: CODEPIPELINE
LogsConfig:
CloudWatchLogs:
Status: ENABLED
version: 0.2
phases:
pre_build:
commands:
- echo Build started on `date`
- echo List all available files
- ls -ll
- echo Delete current model folder and fetch new model from s3
- rm -rf model
#!/bin/bash
BUCKET_NAME=birds-classifier-model-bucket
AWS_ID=$(aws sts get-caller-identity --query Account --output text | cat)
AWS_REGION=$(aws configure get region)
echo "Creating bucket "
aws s3api create-bucket --acl public-read --bucket $BUCKET_NAME --create-bucket-configuration LocationConstraint=$AWS_REGION
echo "Enable versioning"
CloudFormationCodePipeline:
Type: AWS::CodePipeline::Pipeline
Properties:
Name: !Ref CodePipelineProjectName
RoleArn: !GetAtt BirdsClassifierCodePipelineServiceRole.Arn
Stages:
- Name: SourceStage
Actions:
- Name: SourceAction
ActionTypeId:
name: Docker Image CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
version: '3'
services:
deploy:
build:
context: .
dockerfile: Dockerfile
ports:
- '80:5000'
FROM python:3.9
WORKDIR /usr/src/app
# We copy just the requirements.txt first to leverage Docker cache
COPY ./requirements.txt ./
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
def load(dataset):
dataset.to_csv("final_dataset.csv", index=False)
load(df_final)
# Compute GDP by using GDP per capita and the Population columns
df_final["GDP"] = df_final["GDP per capita"] * df_final["Population"]
# Remove % sign of Population under 20 years old column and convert it to be of type float
def transform_col(col_val):
try:
return float(col_val.replace(" %", ""))
except: # value is NaN
return col_val