简体   繁体   English

Airflow 传感器操作员 - github PR

[英]Airflow Sensor Operator - github PR

Would it be possible to config an Airflow sensor (thinking maybe the @task.sensor decorator sensor) that could listen for a PR to be merged in a Github repo and trigger the DAG run based on that?是否可以配置一个 Airflow 传感器(可能是 @task.sensor 装饰器传感器)来侦听 PR 并合并到 Github 存储库中并基于它触发 DAG 运行? Ideally outside of using Github Actions.理想情况下不使用 Github 操作。

Airflow sensors are just python classes, they should have a method poke which return True when the thing you want to wait happens. Airflow 传感器只是 python 类,它们应该有一个方法poke ,当你想要等待的事情发生时返回 True。

To achieve what you want to do, you can use the library PyGithub , to get the state of the PR and return True when it is merged (and fail when it is closed).为了实现你想做的事情,你可以使用库PyGithub来获取 PR 的 state 并在合并时返回 True (并在关闭时失败)。

Here is the link to the doc, and the source code if there is something not documented. 是文档的链接,以及源代码(如果有未记录的内容)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM