如何在不复制我们的仓库的情况下在气流中运行 DBT [英] How to run DBT in airflow without copying our repo

查看:20
本文介绍了如何在不复制我们的仓库的情况下在气流中运行 DBT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将 DBT 与 GCP 和 BigQuery 用于 BigQuery 中的转换,并且安排我们每天 run dbt 的最简单方法似乎是 Airflow 中的 BashOperator.目前我们有两个独立的目录/github 项目,一个用于 DBT,另一个用于 Airflow.要安排 DBT 与 Airflow 一起运行,似乎我们的整个 DBT 项目需要嵌套在我们的 Airflow 项目中,这样我们就可以在 dbt run bash 命令中指向它?

We use DBT with GCP and BigQuery for transformations in BigQuery, and the simplest approach to scheduling our daily run dbt seems to be a BashOperator in Airflow. Currently we have two separate directories / github projects, one for DBT and another for Airflow. To schedule DBT to run with Airflow, it seems like our entire DBT project would need to be nested inside of our Airflow project, that way we can point to it for our dbt run bash command?

是否可以在不将 DBT 目录移动到 Airflow 目录中的情况下触发我们的 dbt rundbt test?使用 airflow-dbt 包,对于 dirdefault_args,也许可以在这里指向DBT项目的gibhub链接?

Is it possible to trigger our dbt run and dbt test without moving our DBT directory inside of our Airflow directory? With the airflow-dbt package, for the dir in the default_args, maybe it is possible to point to the gibhub link for the DBT project here?

推荐答案

我的建议是将 dbt 和 airflow 代码库分开.确实有更好的方法:

My advice would be to leave your dbt and airflow codebases separated. There is indeed a better way:

  1. 在一个简单的基于 Python 的镜像中对您的 dbt 项目进行 dockerise,您可以在其中复制代码库
  2. 将其推送到 DockerHub 或 ECR 或您正在使用的任何其他 docker 存储库
  3. 使用 DockerOperator 在您的气流 DAG 中使用您的 dbt 代码运行该 docker 镜像

我假设您在这里使用了气流 LocalExecutor 并且您想在运行气流的服务器上执行您的 dbt run 工作负载.如果情况并非如此,并且您有权访问 Kubernetes 集群,我建议您改用 KubernetesPodOperator.

I'm assuming that you use the airflow LocalExecutor here and that you want to execute your dbt run workload on the server where airflow is running. If that's not the case and that you have access to a Kubernetes cluster, I would suggest instead to use the KubernetesPodOperator.

这篇关于如何在不复制我们的仓库的情况下在气流中运行 DBT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆