| :mod:`airflow.models.dagrun` |
| ============================ |
| |
| .. py:module:: airflow.models.dagrun |
| |
| |
| Module Contents |
| --------------- |
| |
| .. py:class:: DagRun |
| |
| Bases: :class:`airflow.models.base.Base`, :class:`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 |
| |
| .. attribute:: __tablename__ |
| :annotation: = dag_run |
| |
| |
| |
| .. attribute:: ID_PREFIX |
| :annotation: = scheduled__ |
| |
| |
| |
| .. attribute:: ID_FORMAT_PREFIX |
| |
| |
| |
| |
| .. attribute:: id |
| |
| |
| |
| |
| .. attribute:: dag_id |
| |
| |
| |
| |
| .. attribute:: execution_date |
| |
| |
| |
| |
| .. attribute:: start_date |
| |
| |
| |
| |
| .. attribute:: end_date |
| |
| |
| |
| |
| .. attribute:: _state |
| |
| |
| |
| |
| .. attribute:: run_id |
| |
| |
| |
| |
| .. attribute:: external_trigger |
| |
| |
| |
| |
| .. attribute:: conf |
| |
| |
| |
| |
| .. attribute:: dag |
| |
| |
| |
| |
| .. attribute:: __table_args__ |
| |
| |
| |
| |
| .. attribute:: state |
| |
| |
| |
| |
| .. attribute:: is_backfill |
| |
| |
| |
| |
| |
| .. method:: __repr__(self) |
| |
| |
| |
| |
| .. method:: get_state(self) |
| |
| |
| |
| |
| .. method:: set_state(self, state) |
| |
| |
| |
| |
| .. classmethod:: id_for_date(cls, date, prefix=ID_FORMAT_PREFIX) |
| |
| |
| |
| |
| .. method:: refresh_from_db(self, session=None) |
| |
| Reloads the current dagrun from the database |
| |
| :param session: database session |
| |
| |
| |
| |
| .. staticmethod:: find(dag_id=None, run_id=None, execution_date=None, state=None, external_trigger=None, no_backfills=False, session=None) |
| |
| Returns a set of dag runs for the given search criteria. |
| |
| :param dag_id: the dag_id to find dag runs for |
| :type dag_id: int, list |
| :param run_id: defines the the run id for this dag run |
| :type run_id: str |
| :param execution_date: the execution date |
| :type execution_date: datetime.datetime |
| :param state: the state of the dag run |
| :type state: str |
| :param external_trigger: whether this dag run is externally triggered |
| :type external_trigger: bool |
| :param no_backfills: return no backfills (True), return all (False). |
| Defaults to False |
| :type no_backfills: bool |
| :param session: database session |
| :type session: sqlalchemy.orm.session.Session |
| |
| |
| |
| |
| .. method:: get_task_instances(self, state=None, session=None) |
| |
| Returns the task instances for this dag run |
| |
| |
| |
| |
| .. method:: get_task_instance(self, task_id, session=None) |
| |
| Returns the task instance specified by task_id for this dag run |
| |
| :param task_id: the task id |
| |
| |
| |
| |
| .. method:: get_dag(self) |
| |
| Returns the Dag associated with this DagRun. |
| |
| :return: DAG |
| |
| |
| |
| |
| .. method:: get_previous_dagrun(self, state=None, session=None) |
| |
| The previous DagRun, if there is one |
| |
| |
| |
| |
| .. method:: get_previous_scheduled_dagrun(self, session=None) |
| |
| The previous, SCHEDULED DagRun, if there is one |
| |
| |
| |
| |
| .. method:: update_state(self, session=None) |
| |
| Determines the overall state of the DagRun based on the state |
| of its TaskInstances. |
| |
| :return: ready_tis: the tis that can be scheduled in the current loop |
| :rtype ready_tis: list[airflow.models.TaskInstance] |
| |
| |
| |
| |
| .. method:: _get_ready_tis(self, scheduleable_tasks, finished_tasks, session) |
| |
| |
| |
| |
| .. method:: _are_premature_tis(self, unfinished_tasks, finished_tasks, session) |
| |
| |
| |
| |
| .. method:: _emit_duration_stats_for_finished_state(self) |
| |
| |
| |
| |
| .. method:: verify_integrity(self, session=None) |
| |
| 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. |
| |
| |
| |
| |
| .. staticmethod:: get_run(session, dag_id, execution_date) |
| |
| :param dag_id: DAG ID |
| :type dag_id: unicode |
| :param execution_date: execution date |
| :type execution_date: datetime |
| :return: DagRun corresponding to the given dag_id and execution date |
| if one exists. None otherwise. |
| :rtype: airflow.models.DagRun |
| |
| |
| |
| |
| .. classmethod:: get_latest_runs(cls, session) |
| |
| Returns the latest DagRun for each DAG. |
| |
| |
| |
| |