Recall & Review
beginner
What is the purpose of the PythonOperator in Airflow?
PythonOperator lets you run your own Python functions as tasks inside an Airflow workflow (DAG).
Click to reveal answer
beginner
How do you define a Python function to use with PythonOperator?
You write a normal Python function that contains the logic you want to run as a task.
Click to reveal answer
beginner
Which argument do you use to pass your Python function to PythonOperator?
You use the 'python_callable' argument to give PythonOperator your function.
Click to reveal answer
intermediate
Can PythonOperator pass parameters to your Python function? If yes, how?
Yes, by using 'op_args' for positional arguments or 'op_kwargs' for keyword arguments.
Click to reveal answer
intermediate
What happens if your Python function raises an error during execution in PythonOperator?
The task fails and Airflow marks it as failed, so you can see the error in the logs.
Click to reveal answer
Which argument is used to specify the Python function in PythonOperator?
✗ Incorrect
The 'python_callable' argument is the correct way to pass your Python function to PythonOperator.
How can you pass keyword arguments to the Python function in PythonOperator?
✗ Incorrect
'op_kwargs' is used to pass keyword arguments to the Python function.
What is the result if the Python function raises an exception during task execution?
✗ Incorrect
If an exception occurs, the task fails and Airflow marks it as failed.
Which Airflow component runs the PythonOperator task?
✗ Incorrect
The Executor runs the tasks including PythonOperator tasks.
Can PythonOperator be used to run shell commands directly?
✗ Incorrect
For shell commands, BashOperator is the right choice, not PythonOperator.
Explain how to create a PythonOperator task that runs a custom Python function with parameters.
Think about how you connect your function to the operator and pass data.
You got /4 concepts.
Describe what happens when a PythonOperator task fails due to an error in the Python function.
Consider Airflow's behavior on task failure.
You got /4 concepts.