與 DVC remote 互動

Machine Learning 的 CI/CD

Ravi Bhadauria

Machine Learning Engineer

認識 DVC Remote

  • DVC Remote:資料儲存位置
  • 類似 Git remote,但用於「快取」資料
  • 使用 remote 的好處
    • 同步大型檔案與目錄
    • 集中或分散資料儲存
    • 節省本機空間
  • 支援的儲存型態
    • Amazon S3、GCS、Google Drive
    • SSH、HTTP、本機檔案系統
Machine Learning 的 CI/CD

設定 Remote

  • dvc remote add 指令設定 remote
  • 以 AWS 為例
dvc remote add myAWSremote s3://mybucket
  • 可用 dvc remote modify 自訂參數
dvc remote modify myAWSremote connect_timeout 300
  • .dvc/config 的變更
 ['remote "myAWSremote"']
     url = s3://mybucket
     connect_timeout = 300
Machine Learning 的 CI/CD

本機與預設 Remote

  • 本機 remote 適合快速原型開發
  • 可用系統目錄或網路附加儲存(NAS)
dvc remote add mylocalremote /tmp/dvc
  • -d 旗標設定預設 remote
dvc remote add -d mylocalremote /tmp/dvc
  • 預設 remote 會寫在 .dvc/configcore 區段
[core]
remote = mylocalremote
Machine Learning 的 CI/CD

上傳與取回資料

  • 傳輸資料的指令

    • 推送到 remote:dvc push <target>
    • 從 remote 拉取:dvc pull <target>
  • 類似 git pushgit pull

    • Git 追蹤的是 .dvc,不是 DVC
  • 目標可為單一檔案:dvc push data.csv
    • 或整個快取:dvc push
  • -r 旗標覆寫預設 remote
dvc push -r myAWSremote data.csv
Machine Learning 的 CI/CD

追蹤資料變更

  • 變更資料檔內容,然後加入資料集變更
dvc add /path/to/data/datafile
  • 將變更後的 .dvc 檔提交到 Git
git add /path/to/datafile.dvc
git commit /path/to/datafile.dvc -m "Dataset updates"
  • 將中繼資料推送到 Git
git push origin main
  • 上傳變更後的資料檔
dvc push
Machine Learning 的 CI/CD

一起來練習吧!

Machine Learning 的 CI/CD

Preparing Video For Download...