Skip to content

DVC Sync for Prediction Data #40

DVC Sync for Prediction Data

DVC Sync for Prediction Data #40

Workflow file for this run

name: DVC Sync for Prediction Data
on:
schedule:
# UTC 기준 매시 55분에 실행 (한국 시간으로는 다음 시간 45분)
# 예측 스크립트가 50분에 실행된 후 충분한 시간을 두고 실행됩니다.
- cron: '55 * * * *'
workflow_dispatch: # 수동 실행을 위한 옵션
jobs:
dvc-sync:
runs-on: ubuntu-latest
steps:
- name: Connect to EC2 and run DVC commands
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST_ML }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_SSH_KEY }}
port: 22
script: |
# 프로젝트 디렉터리로 이동
cd ~/MLOps/MLOps
# Git 사용자 설정
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
# dvc s3 연결
dvc remote modify --local storage access_key_id ${{ secrets.DVC_ACCESS_KEY }}
dvc remote modify --local storage secret_access_key ${{ secrets.DVC_SECRET_KEY }}
# DVC로 데이터 버전 관리 및 푸시
echo "Versioning data with DVC..."
dvc add app/python_schedule/data/crowd_prediction
dvc push
# 변경된 .dvc 파일 git 커밋 및 푸시
git add app/python_schedule/data/crowd_prediction.dvc
# 변경 사항이 있을 때만 커밋
if ! git diff --quiet --cached; then
git commit -m "Update prediction data for $(date) [skip ci]"
git push origin main
else
echo "No changes in prediction data to commit."
fi
echo "DVC sync workflow completed successfully!"