Airflow

Airflow

文档地址:https://airflow.apache.org/docs/apache-airflow/stable/index.html

动态任务
def taskList(task_conf,batch_size):
    task = BashOperator(
        task_id='',
        bash_command=bash_command,
        dag=main_dag
        )
    # 4 返回任务
    return task

list_task = []
for line in lines:
    list_task.append(taskList(line, batch_size))

start > list_task > end
命令
##所有任务置成功
airflow backfill **_dag -s 2022-01-01 -e 2022-05-12  -i -m --reset_dagruns -y -sd path

##单运行单个节点
airflow backfill **_dag -s 2022-01-01 -e 2022-05-12  -i --reset_dagruns -y -sd path -t hive2db_task 
自定义日期
def date_add(ds_nodash ,days):
    execution_date = datetime.strptime(ds_nodash ,'%Y%m%d')
    new_date = (execution_date + timedelta(days=days)).strftime('%Y%m%d')
    return str(new_date)

main_dag = DAG(
    dag_id=dag_id,
    default_args=default_args,
    description=dag_description,
    catchup=False,
    schedule_interval=schedule_interval,
    user_defined_macros={
        "date_add": date_add,
    }
)
'{{ date_add2(ds ,-2) }}'

posted @   Kotlin  阅读(178)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
Live2D
点击右上角即可分享
微信分享提示
西雅图
14:14发布
西雅图
14:14发布
4°
东南风
2级
空气质量
相对湿度
92%
今天
3°/12°
周四
4°/11°
周五
2°/10°