การทำงานกับ DVC Remotes

CI/CD สำหรับ Machine Learning

Ravi Bhadauria

Machine Learning Engineer

ทำความเข้าใจ DVC Remotes

  • DVC Remotes: พื้นที่จัดเก็บข้อมูล
  • คล้าย Git remotes แต่สำหรับข้อมูล ที่แคชไว้
  • ประโยชน์ของการใช้ remotes
    • ซิงโครไนซ์ไฟล์และไดเรกทอรีขนาดใหญ่
    • จัดเก็บข้อมูลแบบรวมศูนย์หรือกระจาย
    • ประหยัดพื้นที่ในเครื่อง
  • ประเภท storage ที่รองรับ
    • Amazon S3, GCS, Google Drive
    • SSH, HTTP, ระบบไฟล์ในเครื่อง
CI/CD สำหรับ Machine Learning

การตั้งค่า Remotes

  • ตั้งค่า remote ด้วยคำสั่ง dvc remote add
  • สำหรับ 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
CI/CD สำหรับ Machine Learning

Local และ Default Remotes

  • Local remotes ใช้สำหรับการทดสอบอย่างรวดเร็ว
  • ใช้ไดเรกทอรีในระบบหรือ Network Attached Storage
dvc remote add mylocalremote /tmp/dvc
  • กำหนด default remote ด้วย flag -d
dvc remote add -d mylocalremote /tmp/dvc
  • Default remote จะถูกกำหนดในส่วน core ของ .dvc/config
[core]
remote = mylocalremote
CI/CD สำหรับ Machine Learning

การอัปโหลดและดึงข้อมูล

  • คำสั่งสำหรับโอนข้อมูล

    • Push ไปยัง remote: dvc push <target>
    • Pull จาก remote: dvc pull <target>
  • คล้ายกับ git push และ git pull

    • .dvc ถูกติดตามโดย Git ไม่ใช่ DVC
  • Target ระบุเป็นไฟล์เดี่ยวได้ เช่น dvc push data.csv
    • หรือ push ทั้ง cache ด้วย dvc push
  • ระบุ remote อื่นด้วย flag -r
dvc push -r myAWSremote data.csv
CI/CD สำหรับ Machine Learning

การติดตามการเปลี่ยนแปลงข้อมูล

  • แก้ไขไฟล์ข้อมูล แล้ว add การเปลี่ยนแปลงชุดข้อมูล
dvc add /path/to/data/datafile
  • Commit ไฟล์ .dvc ที่เปลี่ยนแปลงไปยัง Git
git add /path/to/datafile.dvc
git commit /path/to/datafile.dvc -m "Dataset updates"
  • Push metadata ไปยัง Git
git push origin main
  • อัปโหลดไฟล์ข้อมูลที่เปลี่ยนแปลง
dvc push
CI/CD สำหรับ Machine Learning

มาฝึกกันเถอะ!

CI/CD สำหรับ Machine Learning

Preparing Video For Download...