airflow/models/dag.py
def handle_callback(self, dagrun, success=True, reason=None, session=None):
        """
        Triggers the appropriate callback depending on the value of success, namely the
        on_failure_callback or on_success_callback. This method gets the context of a
        single TaskInstance part of this DagRun and passes that to the callable along
        with a 'reason', primarily to differentiate DagRun failures.

        .. note: The logs end up in
            ``$AIRFLOW_HOME/logs/scheduler/latest/PROJECT/DAG_FILE.py.log``

        :param dagrun: DagRun object
        :param success: Flag to specify if failure or success callback should be called
        :param reason: Completion reason
        :param session: Database session
        """
        callback = self.on_success_callback if success else self.on_failure_callback
        if callback:
            self.log.info('Executing dag callback function: %s', callback)
            tis = dagrun.get_task_instances(session=session)
            ti = tis[-1]  # get first TaskInstance of DagRun
            ti.task = self.get_task(ti.task_id)
            context = ti.get_template_context(session=session)
            context.update({'reason': reason})
            try:
                callback(context)
            except Exception:
                self.log.exception("failed to invoke dag state update callback")
                Stats.incr("dag.callback_exceptions")

        Triggers the appropriate callback depending on the value of success, namely the
        on_failure_callback or on_success_callback. This method gets the context of a
        single TaskInstance part of this DagRun and passes that to the callable along
        with a 'reason', primarily to differentiate DagRun failures.

        .. note: The logs end up in
            ``$AIRFLOW_HOME/logs/scheduler/latest/PROJECT/DAG_FILE.py.log``

        :param dagrun: DagRun object
        :param success: Flag to specify if failure or success callback should be called
        :param reason: Completion reason
        :param session: Database session
        
Triggers the appropriate callback depending on the value of success, namely the
on_failure_callback or on_success_callback. This method gets the context of a
single TaskInstance part of this DagRun and passes that to the callable along
with a 'reason', primarily to differentiate DagRun failures.


Triggers the appropriate callback depending on the value of success namely the on_failure_callback or on_success_callback . This method gets the context of a single TaskInstance part of this DagRun and passes that to the callable along with a ' reason ' primarily to differentiate DagRun failures .
def handle_callback(self, dagrun, success=True, reason=None, session=None):
        callback = self.on_success_callback if success else self.on_failure_callback
        if callback:
            self.log.info('Executing dag callback function: %s', callback)
            tis = dagrun.get_task_instances(session=session)
            ti = tis[-1]  
            ti.task = self.get_task(ti.task_id)
            context = ti.get_template_context(session=session)
            context.update({'reason': reason})
            try:
                callback(context)
            except Exception:
                self.log.exception("failed to invoke dag state update callback")
                Stats.incr("dag.callback_exceptions")
def handle_callback ( self , dagrun , success = True , reason = None , session = None ) : callback = self . on_success_callback if success else self . on_failure_callback if callback : self . log . info ( 'Executing dag callback function: %s' , callback ) tis = dagrun . get_task_instances ( session = session ) ti = tis [ - 1 ] ti . task = self . get_task ( ti . task_id ) context = ti . get_template_context ( session = session ) context . update ( { 'reason' : reason } ) try : callback ( context ) except Exception : self . log . exception ( "failed to invoke dag state update callback" ) Stats . incr ( "dag.callback_exceptions" )
Triggers the appropriate callback depending on the value of success, namely the
on_failure_callback or on_success_callback.
Triggers the appropriate callback depending on the value of success namely the on_failure_callback or on_success_callback .
"""
        Triggers the appropriate callback depending on the value of success, namely the
        on_failure_callback or on_success_callback. This method gets the context of a
        single TaskInstance part of this DagRun and passes that to the callable along
        with a 'reason', primarily to differentiate DagRun failures.

        .. note: The logs end up in
            ``$AIRFLOW_HOME/logs/scheduler/latest/PROJECT/DAG_FILE.py.log``

        :param dagrun: DagRun object
        :param success: Flag to specify if failure or success callback should be called
        :param reason: Completion reason
        :param session: Database session
        """ # get first TaskInstance of DagRun
self
dagrun
None
success
Flag to specify if failure or success callback should be called
Flag to specify if failure or success callback should be called
reason
None
session
None