Engineering/MLOps
[MLOps] 03 Data Management & DVC
iamzieun
2023. 1. 20. 17:47
Data management
Problem
- ML model을 개발하다보면, raw data를 조금씩 바꿔가면서(feature engineering) 여러 버전의 데이터를 생성하게 됩니다.
- 그런데 이렇게 데이터를 바꿔가며 실험하다보면 어떤 데이터가 어떤 feature engineering을 통해 도출된 데이터인지 기억하기 어려워집니다.
Solution
- 일반적인 software을 개발할 때에도 source code는 지속해서 수정되기에, Git + GitHub, GitLab, Bitbucket을 통해 버전 관리 및 협업을 진행합니다.
- ML 분야에서도 마찬가지로 Git + GitHub, GitLab, Bitbucket을 통해 버전 관리, 협업 등을 진행합니다.
- 하지만, GitHub, GitLab, Bitbucket 등의 git hosting server 는 대용량 데이터를 업로드, 다운로드하기에 적합하지 않습니다. 왜냐하면 이들은 애초에 소프트웨어용 소스코드만 가볍게 저장하고 다운받기 위할 목적으로 발전된 서비스이기 때문입니다. 따라서 ML 프로젝트에서 사용된 데이터는 구글 드라이브 등 대용량 저장소에 따로 저장하는 등의 임시적인 방식을 사용해왔습니다.
DVC: Data Version Control
- DVC의 특징
- 대부분의 외부 저장소(amazon s3, google drive 등)와 호환이 가능합니다.
- 대부분의 git hosting server(GitHub, GitLab, Bitbucket 등)와 연동이 가능합니다.
- Data Pipleline을 DAG로 관리합니다.
- cf. DAG (Directed Acyclic Graph)
DVC represents a pipeline internally as a graph where the nodes are stages and the edges are directed dependencies (e.g. A before B). And in order for DVC to run a pipeline, its topology should be acyclic — because executing cycles (e.g. A -> B -> C -> A …) would continue indefinitely.
DVC는 내부적으로 하나의 pipeline을 node가 stage인 directed graph로 나타낸다. DVC로 하여금 pipeline을 실행하게 하려면, 실행되는 cycle은 무제한으로 지속되어야 하므로 그것은 acyclic해야 한다.- directed graph: edge가 모두 directed edge인 graph
- acyclic graph: simple cycle을 포함하고 있지 않은 graph
- cf. DAG (Directed Acyclic Graph)
- Git과 유사한 인터페이스를 가지고 있습니다.
- DVC의 저장 방식
- DVC는 외부 저장소(Remote Data Storage) 및 git(Remote Code Storage)과 함께 동작합니다.
- 실제 데이터는 Remote Data Storage에 저장
- 데이터의 메타 데이터(.dvc)는 git(Remote Code Storage)에 저장→ git은 dvc 파일을 추적함으로써 버전 관리 진행
- DVC는 외부 저장소(Remote Data Storage) 및 git(Remote Code Storage)과 함께 동작합니다.