导出所有气流变量 [英] Export all Airflow variables

查看:22
本文介绍了导出所有气流变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在从代码下载所有 Airflow 变量时遇到问题.
有机会从 UI 导出,但我还没有找到任何以编程方式进行导出的方法.

I have a problem with downloading all Airflow variables from the code.
There is an opportunity to export from UI, but i haven't found any way to do it programatically.

我发现只有 Variable.get('variable_name') 方法返回一个 Airflow 变量.没有获取 Airflow 变量列表的变体.

I discovered only Variable.get('variable_name') method which returns one Airflow variable. There is no variants of getting the list of Airflow variables.

在源代码中搜索也无济于事.你知道一些简单的方法吗?

Searching in the source code didn't help as well. Do you know some easy way?

提前致谢.

推荐答案

您可以使用 Airflow CLI 将变量导出到文件,然后从 Python 代码中读取.

You can use Airflow CLI to export variables to a file and then read it from your Python code.

airflow variables --export FILEPATH

您可以以编程方式使用 BashOperator 来实现这一点.

Programmatically you can use the BashOperator to achieve this.

这篇关于导出所有气流变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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