"""DAG for marking all sales as 'approved' in an accounting period.""" from datetime import datetime from airflow import DAG from airflow.operators.python import PythonOperator from lib.constants import ABACUS_STATE_STATUSES from lib.constants import DAG_ACCOUNTING_PERIOD_SALES_APPROVE_NAME from lib.utils.slack import slack_failure_callback from tasks.accounting_period_sales_approve.snowflake_truncate_temp_sales \ import truncate_temp_sales_task from tasks.accounting_period_sales_approve.update_abacus_state \ import update_abacus_state_task dag = DAG( DAG_ACCOUNTING_PERIOD_SALES_APPROVE_NAME, default_args={ 'provide_context': True, 'on_failure_callback': slack_failure_callback, }, description='Truncate temp snowflake table when all sales have been approved.', schedule_interval=None, start_date=datetime(2022, 1, 1) ) """ ###################################################################### ############################# OPERATORS ############################## ###################################################################### """ notify_failure_operator = PythonOperator( dag=dag, op_kwargs={'action_status': ABACUS_STATE_STATUSES.ERROR}, python_callable=update_abacus_state_task, task_id='notify_failure', trigger_rule='one_failed' ) notify_started_operator = PythonOperator( dag=dag, op_kwargs={'action_status': ABACUS_STATE_STATUSES.RUNNING}, python_callable=update_abacus_state_task, task_id='notify_started' ) notify_success_operator = PythonOperator( dag=dag, op_kwargs={'action_status': ABACUS_STATE_STATUSES.COMPLETE}, python_callable=update_abacus_state_task, task_id='notify_success', trigger_rule='none_failed' ) snowflake_truncate_temp_table_operator = PythonOperator( dag=dag, python_callable=truncate_temp_sales_task, task_id='truncate_snowflake_temp_table' ) """ ###################################################################### ################################ DAG ################################# ###################################################################### """ notify_started_operator >> \ snowflake_truncate_temp_table_operator >> \ notify_success_operator >> \ notify_failure_operator