气流HttpSensor无法正常工作

时间:2017-10-01 09:44:21

标签: airflow apache-airflow

我正在尝试使用以下代码在Airflow中创建HttpSensor:

wait_to_launch = HttpSensor(
    task_id="wait-to-launch",
    endpoint='http://' + socket.gethostname() + ":8500/v1/kv/launch-cluster?raw",
    response_check=lambda response: True if 'oui'==response.content else False,
    dag=dag
)

但我一直收到这个错误:

Traceback (most recent call last):
  File "http_sensor_test.py", line 30, in <module>
    dag=dag
  File "/home/me/.local/lib/python2.7/site-packages/airflow/utils/decorators.py", line 86, in wrapper
    result = func(*args, **kwargs)
  File "/home/me/.local/lib/python2.7/site-packages/airflow/operators/sensors.py", line 663, in __init__
    self.hook = hooks.http_hook.HttpHook(method='GET', http_conn_id=http_conn_id)
  File "/home/me/.local/lib/python2.7/site-packages/airflow/utils/helpers.py", line 436, in __getattr__
    raise AttributeError
AttributeError

我错过了什么?

1 个答案:

答案 0 :(得分:1)

您遇到了一个已知问题,请参阅AIRFLOW-1030。修复已合并(#2180),但遗憾的是还没有发布的气流版本。该修复程序已标记为下一个版本(1.9.0),但可能需要几周/几个月才能完成。您可以使用此更改运行气流分组,或将HttpSensor的更新版本添加为自定义运算符(插件)。