我曾经使用 python 运算符创建任务并检索气流 1 中的执行,如下所示
def task(**kwargs):
date = kwargs['execution_date']
使用新的任务流 api 执行此操作的正确方法是什么?(可能错过了)
谢谢
您可以使用get_current_context
方法访问执行上下文:
from airflow.decorators import task
from airflow.operators.python import get_current_context
@task
def my_task():
context = get_current_context()
ti = context["ti"]
date = context["execution_date"]
文档在这里。试试看!
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句