Пример #1
0
 def _restore_unfinished_dag_run(self, session):
     dag_runs = DagRun.next_dagruns_to_examine(
         session, max_number=sys.maxsize).all()
     if not dag_runs or len(dag_runs) == 0:
         return
     for dag_run in dag_runs:
         self._reset_unfinished_task_state(dag_run)
         tasks = self._find_schedulable_tasks(dag_run, session)
         self._send_scheduling_task_events(tasks, SchedulingAction.START)
Пример #2
0
    def test_next_dagruns_to_examine_only_unpaused(self):
        """
        Check that "next_dagruns_to_examine" ignores runs from paused/inactive DAGs
        """

        dag = DAG(dag_id='test_dags', start_date=DEFAULT_DATE)
        DummyOperator(task_id='dummy', dag=dag, owner='airflow')

        session = settings.Session()
        orm_dag = DagModel(
            dag_id=dag.dag_id,
            has_task_concurrency_limits=False,
            next_dagrun=dag.start_date,
            next_dagrun_create_after=dag.following_schedule(DEFAULT_DATE),
            is_active=True,
        )
        session.add(orm_dag)
        session.flush()
        dr = dag.create_dagrun(
            run_type=DagRunType.SCHEDULED,
            state=State.RUNNING,
            execution_date=DEFAULT_DATE,
            start_date=DEFAULT_DATE,
            session=session,
        )

        runs = DagRun.next_dagruns_to_examine(session).all()

        assert runs == [dr]

        orm_dag.is_paused = True
        session.flush()

        runs = DagRun.next_dagruns_to_examine(session).all()
        assert runs == []

        session.rollback()
        session.close()
Пример #3
0
 def _get_next_dagruns_to_examine(self, state: DagRunState, session: Session):
     """Get Next DagRuns to Examine with retries"""
     return DagRun.next_dagruns_to_examine(state, session)