0
votes

I'm using kwargs['execution_date'] for getting the execution date of dag but it gives the time when the overall dag is invoked, but i need the time where a particular task is started and ended in airflow.

2

2 Answers

0
votes

As a sidenote, the context / kwargs do contain end_date & END_DATE (nodash-format), but not start_date

0
votes
from airflow.api.common.experimental import get_task_instance

execution_date = context['execution_date'] - timedelta(0)
task_instance = get_task_instance.get_task_instance(<dag_id>,<task_id>,execution_date)
start_date = task_instance.start_date
end_date = task_instance.end_date