Skip to content

Commit

Permalink
update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ajithvcoder committed Nov 4, 2024
1 parent 916c661 commit b00a0aa
Showing 1 changed file with 28 additions and 33 deletions.
61 changes: 28 additions & 33 deletions .github/workflows/ec2-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,36 +138,36 @@ jobs:
# if torch.cuda.is_available():
# print(f'Device: {torch.cuda.get_device_name(0)}')"

# - name: Pull Docker image from ECR
# run: |
# docker pull ${{secrets.AWS_ECR_LOGIN_URI}}/${{ secrets.ECR_REPOSITORY_NAME }}:latest
# ls -a
- name: Pull Docker image from ECR
run: |
docker pull ${{secrets.AWS_ECR_LOGIN_URI}}/${{ secrets.ECR_REPOSITORY_NAME }}:latest
ls -a
# - name: Run DVC commands in container
# run: |
# mkdir -p model_storage
# docker run --gpus=all \
# -v "$(pwd)/model_storage:/workspace/model_storage" \
# -e AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \
# -e AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \
# -e AWS_DEFAULT_REGION=${{ secrets.AWS_REGION }} \
# ${{ secrets.AWS_ECR_LOGIN_URI }}/${{ secrets.ECR_REPOSITORY_NAME }}:latest \
# /bin/bash -c "
# dvc pull -r myremote && \
# mkdir -p model_storage && \
# dvc repro -f
# "

# # # Wait a moment to ensure the container has started
# # sleep 5

# ls model_storage/
- name: Run DVC commands in container
run: |
mkdir -p model_storage
docker run --gpus=all \
-v "$(pwd)/model_storage:/workspace/model_storage" \
-e AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \
-e AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \
-e AWS_DEFAULT_REGION=${{ secrets.AWS_REGION }} \
${{ secrets.AWS_ECR_LOGIN_URI }}/${{ secrets.ECR_REPOSITORY_NAME }}:latest \
/bin/bash -c "
dvc pull -r myremote && \
mkdir -p model_storage && \
dvc repro -f
"
# # Wait a moment to ensure the container has started
# sleep 5
ls model_storage/
# # # Print logs from the container
# # docker logs $CONTAINER_ID
# # Print logs from the container
# docker logs $CONTAINER_ID
# # # Stop the container after retrieving logs
# # docker stop $CONTAINER_ID
# # Stop the container after retrieving logs
# docker stop $CONTAINER_ID
- name: List files in folder
run: |
Expand All @@ -178,14 +178,11 @@ jobs:
sudo apt-get update
sudo apt-get install -y jq
# Note this is not proper method we need to use github actions to getch commit id
- name: Get latest commit ID from the repository
id: get_commit_id
env:
REPO_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: |
mkdir model_storage
touch model_storage/model_checkpoint.txt
repo="ajithvcoder/emlo4-session-08-ajithvcoder"
latest_commit=$(curl -s -H "Authorization: token $REPO_TOKEN" \
"https://api.github.com/repos/$repo/commits?per_page=1" | \
Expand All @@ -199,8 +196,7 @@ jobs:
- name: Read best checkpoint file name
id: read_checkpoint
run: |
# checkpoint_file=$(head -n 1 ./model_storage/best_model_checkpoint.txt)
checkpoint_file="model_storage/model_checkpoint.txt"
checkpoint_file=$(head -n 1 ./model_storage/best_model_checkpoint.txt)
echo "CHECKPOINT_FILE=$checkpoint_file" >> $GITHUB_ENV
- name: Upload checkpoint to S3
Expand All @@ -214,4 +210,3 @@ jobs:
- name: Clean previous images and containers
run: |
docker system prune -f

0 comments on commit b00a0aa

Please sign in to comment.