I tried to retrieve the date and time information, but instead of getting the specific task instance date and time, it returned the date and time of the entire DAG.
from airflow.models import DagRun
# Get time from the last executioned DAG
dag_runs = DagRun.find(dag_id)
dag_runs.sort(key=lambda x: x.execution_date, reverse=True)
dag_runs = [ n for n in dag_runs if n.state == "success" ]
print("Info of dag convert task instance: ", dag_runs[0].get_task_instance('converter'))
print("Info of dag convert instance's timestamp: ", dag_runs[0].get_task_instance('converter').execution_date)
New contributor
Ratandeep Sharma is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.