IT

DVC 설치 및 활용

미니스탑 2024. 7. 3. 16:35
  • DVC 테스트 구성

DVC 설치 명령어 사용

DVC 설치

OS : centos-7.3-64

Python 3.8 이상 지원

  • Python 3.9 설치

yum install gcc openssl-devel bzip2-devel libffi-devel -y
wget https://www.python.org/ftp/python/3.9.15/Python-3.9.15.tgz
tar -xvf Python-3.9.15.tgz
cd Python-3.9.15/
./configure --enable-optimizations
make altinstall

 

  • pip 설치

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

python get-pip.py

  • DVC 설치

pip install dvc[all]==2.6.4

  • DVC 설치 확인

dvc --version

 

DVC 구성

  • DVC 저장소 셋팅

mkdir dvc-sample

git init

dvc init

mkdir data

cd data

  • dvc 로 버전 tracking 할 data 를 생성

vi demo.csv

cd ..

dvc add data/demo.csv 

git add data/.gitignore data/demo.csv.dvc

# demo.csv.dvc 파일은 메타정보를 가진 파일

# git 에서는 demo.txt 파일이 아닌, demo.txt.dvc 파일만 관리

cat demo.csv.dvc

git commit -m "Add demo.csv.dvc"

  • ObjectStorage 연동

dvc remote add -d myremote s3://dvc-sample4

dvc remote modify myremote endpointurl https://kr.object.ncloudstorage.com

dvc remote modify myremote access_key_id 'xxxxxxxxxxxxxxxxxxx'

dvc remote modify myremote secret_access_key 'xxxxxxxxxxxxxxxxx'

 

  • dvc config을 git commit

git add .dvc/config

git commit -m "add remote storage"

 

  • dvc push

dvc push

 

  • 특정 버전으로 rollback

git log --oneline

git checkout e6c1942 data/demo.csv.dvc

vi data/demo.csv.dvc 

dvc checkout

cat data/demo.csv

 

  • 데이터 삭제되었거나 새로 받아야 하는 경우

DVC Pull