Installation & Setup¶
Prerequisites¶
- You must have Python installed.
- You must have
pipinstalled. - You must have Docker installed.
- You need VS Code.
AWS Prerequisites¶
-
You must have the AWS CLI installed and an AWS account with an access key and secret key stored in
~/.aws/credentials:- Create a new user:
aws iam create-user --user-name MyIAMUser -
Attach policies to this user:
<!-- - Create an IAM Role:aws iam attach-user-policy --user-name MyIAMUser --policy-arn arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryFullAccess aws iam attach-user-policy --user-name MyIAMUser --policy-arn arn:aws:iam::aws:policy/AmazonEC2ReadOnlyAccess aws iam attach-user-policy --user-name MyIAMUser --policy-arn arn:aws:iam::aws:policy/AmazonECS_FullAccess aws iam attach-user-policy --user-name MyIAMUser --policy-arn arn:aws:iam::aws:policy/AmazonS3FullAccess aws iam attach-user-policy --user-name MyIAMUser --policy-arn arn:aws:iam::aws:policy/AWSAppRunnerFullAccess aws iam attach-user-policy --user-name MyIAMUser --policy-arn arn:aws:iam::aws:policy/IAMFullAccess aws iam attach-user-policy --user-name MyIAMUser --policy-arn arn:aws:iam::aws:policy/IAMReadOnlyAccess- Attach policies to this role:aws iam create-role --role-name AppRunnerECRAccessRole \ --assume-role-policy-document '{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "build.apprunner.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }'bash aws iam attach-role-policy --role-name AppRunnerECRAccessRole --policy-arn arn:aws:iam::aws:policy/service-role/AWSAppRunnerServicePolicyForECRAccess aws iam attach-role-policy --role-name AppRunnerECRAccessRole --policy-arn arn:aws:iam::aws:policy/CloudWatchLogsFullAccess→
bash aws iam get-role --role-name AppRunnerECRAccessRole --query 'Role.Arn' --output text-
Create an access key:
bash aws iam create-access-key --user-name MyIAMUser -
Add the access key and secret key to the AWS CLI using the elements
AccessKeyIdandSecretAccessKeygenerated previously:bash aws configure --profile MyIAMUser
- Create a new user:
-
You need to create a S3 bucket:
aws s3api create-bucket --bucket dsba-mlops-project --region eu-west-3 --create-bucket-configuration LocationConstraint=eu-west-3 --profile MyIAMUser- Notes:
- You can chose a different bucket name but you will need to update the
.envfile mentioned at step 5 of the installation accordingly. - You can check that the bucket was created by running
aws s3 ls.
- You can chose a different bucket name but you will need to update the
- Notes:
Installation¶
-
Download the repository
- Go to mlops-project.
- Click on "Code", then "Download ZIP".
- Extract the ZIP file to your
~/Desktopfor easy access.
Or clone the repository using the following command:
cd Desktop git clone https://github.com/allisterk2703/mlops-project.git -
Open the project in VS Code
- Open the
mlops-projectfolder in VS Code. - Open a terminal in VS Code: Press
Control ^+Shift ⇧+<.
- Open the
-
Set up the virtual environment
Run the following commands in the terminal:
pip install hatch hatch env create hatch shell pip install -e . -
Set environment variables
To ensure the correct paths are recognized, add the following lines to your
~/.zshrcfile:echo 'export PYTHONPATH="$PYTHONPATH:$HOME/Desktop/dsba-platform/src"' >> ~/.zshrc echo 'export DSBA_MODELS_ROOT_PATH="$HOME/Desktop/dsba-platform/models"' >> ~/.zshrcThen, run the following command to apply the changes:
source ~/.zshrc -
Create a
.envfileAt the root of the project, create a
.envfile and add the following (using the AWS credentials and S3 bucket name you created earlier):AWS_ACCESS_KEY_ID=<YOUR_AWS_ACCESS_KEY_ID> AWS_SECRET_ACCESS_KEY=<YOUR_AWS_SECRET_ACCESS_KEY> AWS_REGION=<YOUR_AWS_REGION> S3_BUCKET_NAME=dsba-mlops-project