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

发布于 2025-01-22 14:44:51 字数 76 浏览 2 评论 0 原文

有CLI函数气流DAGS LIST ,它列出了当前环境中的所有DAG。 Python API中是否有类似的功能?

There is the CLI function airflow dags list which lists all DAGs in the current environment. Is there a similar function in the Python API?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那请放手 2025-01-29 14:44:51

是的。气流REST API具有 端点。

GET /dags

还有官方 python client api,以便您可以轻松地与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: %s\n" % e)

Yes. Airflow Rest API has List DAGs endpoint.

GET /dags

There is also official Python client for the API so you can use it with Python easily.
You can see example how to set it for 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: %s\n" % e)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文