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

__tablename__ = dag_run[source]
ID_PREFIX = scheduled__[source]
ID_FORMAT_PREFIX[source]
id[source]
dag_id[source]
execution_date[source]
start_date[source]
end_date[source]
_state[source]
run_id[source]
external_trigger[source]
conf[source]
dag[source]
__table_args__[source]
state[source]
is_backfill[source]
__repr__(self)[source]
get_state(self)[source]
set_state(self, state)[source]
classmethod id_for_date(cls, date, prefix=ID_FORMAT_PREFIX)[source]
refresh_from_db(self, session=None)[source]

Reloads the current dagrun from the database :param 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
  • dag_id (int, list) – the dag_id to find dag runs for

  • 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_dag(self)[source]

Returns the Dag associated with this DagRun.

Returns

DAG

get_previous_dagrun(self, state=None, session=None)[source]

The previous DagRun, if there is one

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

State

_emit_duration_stats_for_finished_state(self)[source]
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.

static get_run(session, dag_id, execution_date)[source]
Parameters
  • dag_id (unicode) – DAG ID

  • execution_date (datetime) – execution date

Returns

DagRun corresponding to the given dag_id and execution date if one exists. None otherwise.

Return type

airflow.models.DagRun

classmethod get_latest_runs(cls, session)[source]

Returns the latest DagRun for each DAG.

Was this entry helpful?