EmailOperator and dependencies
Now that you've successfully defined the PythonOperators for your workflow, your manager would like to receive a copy of the parsed JSON file via email when the workflow completes. The previous tasks are still defined and the DAG process_sales_dag is configured. Please note that this task uses the older DAG definition method and is added for you.
Questo esercizio fa parte del corso
Introduction to Apache Airflow in Python
Istruzioni dell'esercizio
- Import the class to send emails.
- Define the Operator and add the appropriate arguments (
to,subject,files). - Set the task order so the tasks run sequentially (Pull the file, parse the file, then email your manager).
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
# Import the Operator
from ____ import ____
# Define the task
email_manager_task = ____(
task_id='email_manager',
____='[email protected]',
____='Latest sales JSON',
html_content='Attached is the latest sales JSON file as requested.',
____='parsedfile.json',
dag=process_sales_dag
)
# Set the order of tasks
pull_file_task ____ parse_file_task ____ email_manager_task