from airflow.operators.bash import BashOperator import pendulum from airflow import DAG with DAG( dag_id="price_exception_dag", # 每月23日运行 schedule_interval="0 10 23 * *", start_date=pendulum.datetime(2023, 3, 17, tz="Asia/Shanghai"), catchup=True, description="建行每月价格异常检测脚本,默认检测本月与上月差异, 若对比上月与前月价格,设置year_month=\"202210\"(前月日期即可) 若输出样本存在与否,设置year_month=sample" ) as dag: t1 = BashOperator( task_id='price_evaluation', bash_command='python /opt/airflow/dags/repo/dags/jh/price/price_evaluation.py {{dag_run.conf["year_month"] if "year_month" in dag_run.conf}}', ) t2 = BashOperator( task_id='price_exception', bash_command='python /opt/airflow/dags/repo/dags/jh/price/price_exception.py {{dag_run.conf["year_month"] if "year_month" in dag_run.conf}}', ) t3 = BashOperator( task_id='no_price_community', bash_command='python /opt/airflow/dags/repo/dags/jh/price/no_price_community.py {{dag_run.conf["year_month"] if "year_month" in dag_run.conf}}', ) t4 = BashOperator( task_id='price_deviation', bash_command='python /opt/airflow/dags/repo/dags/jh/price/price_deviation.py {{dag_run.conf["year_month"] if "year_month" in dag_run.conf}}', ) t1 >> t2 >> t3 >> t4