如何在Python中检索所有气流dag的列表?



有一个CLI函数airflow dags list,它列出了当前环境中的所有dag。Python API中是否有类似的函数?

是。气流休息API有列表dag端点。

GET /dags

该API还有官方的Python客户端,因此您可以轻松地将其与Python一起使用。您可以看到如何为get_dags设置它的示例:

with client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = dag_api.DAGApi(api_client)
limit = 100
offset = 0
order_by = "order_by_example"
tags = [
"tags_example",
]
only_active = True
try:
# List DAGs
api_response = api_instance.get_dags(limit=limit, offset=offset, order_by=order_by, tags=tags, only_active=only_active)
pprint(api_response)
except client.ApiException as e:
print("Exception when calling DAGApi->get_dags: %sn" % e)

最新更新