Introduction to Apache Airflow in Python
Mike Metzger
Data Engineer
from airflow.operators.python import PythonOperator
def printme(): print("This goes in the logs!")
python_task = PythonOperator( task_id='simple_print', python_callable=printme )
op_kwargs
dictionarydef sleep(length_of_time): time.sleep(length_of_time)
sleep_task = PythonOperator( task_id='sleep', python_callable=sleep, op_kwargs={'length_of_time': 5} )
airflow.operators
libraryfrom airflow.operators.email import EmailOperator
email_task = EmailOperator( task_id='email_sales_report', to='[email protected]', subject='Automated Sales Report', html_content='Attached is the latest sales report', files='latest_sales.xlsx' )
Introduction to Apache Airflow in Python