airflow.models.dagrun¶
Module Contents¶
- 
class airflow.models.dagrun.DagRun[source]¶
- Bases: - airflow.models.base.Base,- airflow.utils.log.logging_mixin.LoggingMixin- DagRun describes an instance of a Dag. It can be created by the scheduler (for regular runs) or by an external trigger - 
refresh_from_db(self, session=None)[source]¶
- Reloads the current dagrun from the database - Parameters
- session – database session 
 
 - 
static find(dag_id=None, run_id=None, execution_date=None, state=None, external_trigger=None, no_backfills=False, session=None)[source]¶
- Returns a set of dag runs for the given search criteria. - Parameters
- run_id (str) – defines the the run id for this dag run 
- execution_date (datetime.datetime) – the execution date 
- state (str) – the state of the dag run 
- external_trigger (bool) – whether this dag run is externally triggered 
- no_backfills (bool) – return no backfills (True), return all (False). Defaults to False 
- session (sqlalchemy.orm.session.Session) – database session 
 
 
 - 
get_task_instances(self, state=None, session=None)[source]¶
- Returns the task instances for this dag run 
 - 
get_task_instance(self, task_id, session=None)[source]¶
- Returns the task instance specified by task_id for this dag run - Parameters
- task_id – the task id 
 
 - 
get_previous_scheduled_dagrun(self, session=None)[source]¶
- The previous, SCHEDULED DagRun, if there is one 
 - 
update_state(self, session=None)[source]¶
- Determines the overall state of the DagRun based on the state of its TaskInstances. - Returns
- ready_tis: the tis that can be scheduled in the current loop 
- Rtype ready_tis
- list[airflow.models.TaskInstance] 
 
 - 
_emit_true_scheduling_delay_stats_for_finished_state(self, finished_tis)[source]¶
- This is a helper method to emit the true scheduling delay stats, which is defined as the time when the first task in DAG starts minus the expected DAG run datetime. This method will be used in the update_state method when the state of the DagRun is updated to a completed status (either success or failure). The method will find the first started task within the DAG and calculate the expected DagRun start time (based on dag.execution_date & dag.schedule_interval), and minus these two values to get the delay. The emitted data may contains outlier (e.g. when the first task was cleared, so the second task’s start_date will be used), but we can get rid of the the outliers on the stats side through the dashboards tooling built. Note, the stat will only be emitted if the DagRun is a scheduler triggered one (i.e. external_trigger is False). 
 - 
verify_integrity(self, session=None)[source]¶
- Verifies the DagRun by checking for removed tasks or tasks that are not in the database yet. It will set state to removed or add the task if required. 
 
-