'Returns the task instance specified by task_id for this dag run
:param task_id: the task id'

@provide_session
def get_task_instance(self, task_id, session=None):

    TI = TaskInstance
    ti = session.query(TI).filter((TI.dag_id == self.dag_id), (TI.execution_date == self.execution_date), (TI.task_id == task_id)).first()
    return ti
