How to Solve NameError: name 'TaskInstance' is not defined -- airflow

Solution: Import the 'TaskInstance' module

# Add the following line to the top of your code
from airflow.models import TaskInstance

 

For more information:
airflow TaskInstance