Hello world!

MLOps

TFX + airflow 연동

xyz1 2022. 7. 27. 09:12

[전체 overview]

 

Airflow란?

  1. 2015년도 Airbnb에서 배포. (language: Python)
  2. airflow는 복잡한(ex.DAG) workflow의 스케쥴링 및 실행을 관리하는 솔루션
    • ex) User Interface를 통하여 schedule과 모니터링을 할 수 있음.
  3. airflow는 현재 가장 인기 있는 orchestration, 기준(github stars)

4. DAG(Directed Acyclic Graph)

  • Airflow는 파이프라인을 DAG 형태로 관리 할 수 있다.
  • 즉, 복잡한 workflow도 관리할 수 있다.

5.Batch processing(o),  streaming (x)

  • 메시지 애플리케이션 같은 streaming process에는 적합하지 않다. 오히려 kafka(low latency)에 적합하다.

6. 장단점

  • A(가장 높은 점수) ------- C(가장 낮은 점수)
  • Maturity: 프로젝트의 기간, commit과 버전 fix를 고려한 성숙도.
  • Popularity: Github stars를 기준으로 유명세
  • Simplicity: Onboarding과 솔루션 채택의 난이도.
  • Breadth: 전문성(?)

 

주의 사항

Airflow는 poetry를 지원하지 않는다.
따라서, 버전 충돌에 유의해야 한다.

TFX release: 1.8.1 (22.07.25기준)
Airflow release: 2.3.3 (22.07.25기준)

사용한 버전:

  1. TFX: 1.6.1
  2. Apache Beam: 2.39.0
  3. Airflow: 2.2.4
  4. Python: 3.7

python3.8로 시도해보려하면, package 설치에 에러가 발생(+ resolver로 인해 설치 시간이 엄청 길다.)


**정말 제대로 airflow를 사용하고자 한다면 아래의 개념 필요

  1. docker compose
  2. TFX - airflow API

3. Airflow 개념

 

 

DAG 등록

아래 그림은 TFX template 에 있는 pipeline에 관련된 코드를 수정하여 airflow 의 dags 폴더 하위로 옮겨 둔 것이다.

TFX template 에는 tfx.orchestration.LocalDagRunner()를 통해서 실행 시키지만,
airflow로 돌리기 위해서는 아래 그림처럼
tfx.orchestration.airflow.airflow_dag_runner.AirflowDagRunner()를 사용하면 된다.(이를 사용하기 위해 간단한 코드 수정들도 필요하다)

 

 

 

Appendix

Airflow vs others orchestration: https://www.datarevenue.com/en-blog/airflow-vs-luigi-vs-argo-vs-mlflow-vs-kubeflow

  1.  

'MLOps' 카테고리의 다른 글

tf.Example과 TFRecord  (0) 2022.07.27
TFX components  (0) 2022.07.27
TFX ML Metadata  (0) 2022.05.03
Protocol Buffers, Protobuf  (0) 2022.04.28
TFX Guide Local pipeline example  (0) 2022.04.25