【问题标题】:Can we edit the endpoints.py and add new functions to it in airflow?我们可以编辑 endpoints.py 并在气流中添加新功能吗?
【发布时间】:2020-01-30 09:45:22
【问题描述】:

我有新函数,我想通过 api/experimental/route_name 调用它们

我有以下功能并希望将其与气流集成,以便每当我调用 api/experimental/api_userDetail 时都会显示详细信息。

我已将函数包含在文件 [endpoints.py] 中。由于某种原因,它没有出现在服务器中并显示 404 错误。如果我能找到一些方法,那就太好了。

def returnFromVariable(key_name):
    return Variable.get(key_name,deserialize_json=True)

@api_experimental.route('/api_userDetail',methods=['GET'])
def userDetailApi():
    get_element_config_name="user_credential"
    return jsonify(returnFromVariable(get_element_config_name))```

The output is the data returned.

【问题讨论】:

  • 如何注册您的包裹?如果你使用 Blueprint,你必须先注册你的包。或者展示你的结构。
  • 我只是打开了文件并使用了实际由 Blueprint 处理的 api_experimental 装饰器。你能告诉我如何注册包吗?
  • 应该在你的主文件中调用你的包并使用 register_blueprint 来注册你的包。我看不出你是如何构建你的应用的,所以我猜不出来。
  • 感谢帮助其实我有气流的基本结构。我实际上在 site_package/airflow/www/api/experimental/endpoint.py 文件中添加了新功能。此文件在您下载气流时已提供。我希望这能解决一些问题。

标签: python api flask airflow


【解决方案1】:

实际上,这些东西奏效了。我有两个版本的气流,一个在 python2 上运行,另一个在 python3 上运行,所以我必须在 python3 中进行更改,这对我有用。我写的上面的东西有效。要添加新功能,只需转到 www/api/experimental,然后将 api 添加到文件中并重新启动网络服务器即可。

【讨论】:

    猜你喜欢
    • 2012-10-12
    • 1970-01-01
    • 2020-10-25
    • 2021-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-15
    • 1970-01-01
    相关资源
    最近更新 更多