當前位置: 首頁>>代碼示例>>Python>>正文


Python State.SUCCESS屬性代碼示例

本文整理匯總了Python中airflow.utils.state.State.SUCCESS屬性的典型用法代碼示例。如果您正苦於以下問題:Python State.SUCCESS屬性的具體用法?Python State.SUCCESS怎麽用?Python State.SUCCESS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在airflow.utils.state.State的用法示例。


在下文中一共展示了State.SUCCESS屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setUp

# 需要導入模塊: from airflow.utils.state import State [as 別名]
# 或者: from airflow.utils.state.State import SUCCESS [as 別名]
def setUp(self):
        clear_db_runs()
        drs = _create_dagruns(self.dag1, self.execution_dates,
                              state=State.RUNNING,
                              run_type=DagRunType.SCHEDULED)
        for dr in drs:
            dr.dag = self.dag1
            dr.verify_integrity()

        drs = _create_dagruns(self.dag2,
                              [self.dag2.default_args['start_date']],
                              state=State.RUNNING,
                              run_type=DagRunType.SCHEDULED)

        for dr in drs:
            dr.dag = self.dag2
            dr.verify_integrity()

        drs = _create_dagruns(self.dag3,
                              self.dag3_execution_dates,
                              state=State.SUCCESS,
                              run_type=DagRunType.MANUAL)
        for dr in drs:
            dr.dag = self.dag3
            dr.verify_integrity() 
開發者ID:apache,項目名稱:airflow,代碼行數:27,代碼來源:test_mark_tasks.py

示例2: test_mark_tasks_future

# 需要導入模塊: from airflow.utils.state import State [as 別名]
# 或者: from airflow.utils.state.State import SUCCESS [as 別名]
def test_mark_tasks_future(self):
        # set one task to success towards end of scheduled dag runs
        snapshot = TestMarkTasks.snapshot_state(self.dag1, self.execution_dates)
        task = self.dag1.get_task("runme_1")
        altered = set_state(tasks=[task], execution_date=self.execution_dates[0],
                            upstream=False, downstream=False, future=True,
                            past=False, state=State.SUCCESS, commit=True)
        self.assertEqual(len(altered), 2)
        self.verify_state(self.dag1, [task.task_id], self.execution_dates, State.SUCCESS, snapshot)

        snapshot = TestMarkTasks.snapshot_state(self.dag3, self.dag3_execution_dates)
        task = self.dag3.get_task("run_this")
        altered = set_state(tasks=[task], execution_date=self.dag3_execution_dates[1],
                            upstream=False, downstream=False, future=True,
                            past=False, state=State.FAILED, commit=True)
        self.assertEqual(len(altered), 2)
        self.verify_state(self.dag3, [task.task_id], [self.dag3_execution_dates[0]], None, snapshot)
        self.verify_state(self.dag3, [task.task_id], self.dag3_execution_dates[1:], State.FAILED, snapshot) 
開發者ID:apache,項目名稱:airflow,代碼行數:20,代碼來源:test_mark_tasks.py

示例3: test_mark_tasks_past

# 需要導入模塊: from airflow.utils.state import State [as 別名]
# 或者: from airflow.utils.state.State import SUCCESS [as 別名]
def test_mark_tasks_past(self):
        # set one task to success towards end of scheduled dag runs
        snapshot = TestMarkTasks.snapshot_state(self.dag1, self.execution_dates)
        task = self.dag1.get_task("runme_1")
        altered = set_state(tasks=[task], execution_date=self.execution_dates[1],
                            upstream=False, downstream=False, future=False,
                            past=True, state=State.SUCCESS, commit=True)
        self.assertEqual(len(altered), 2)
        self.verify_state(self.dag1, [task.task_id], self.execution_dates, State.SUCCESS, snapshot)

        snapshot = TestMarkTasks.snapshot_state(self.dag3, self.dag3_execution_dates)
        task = self.dag3.get_task("run_this")
        altered = set_state(tasks=[task], execution_date=self.dag3_execution_dates[1],
                            upstream=False, downstream=False, future=False,
                            past=True, state=State.FAILED, commit=True)
        self.assertEqual(len(altered), 2)
        self.verify_state(self.dag3, [task.task_id], self.dag3_execution_dates[:2], State.FAILED, snapshot)
        self.verify_state(self.dag3, [task.task_id], [self.dag3_execution_dates[2]], None, snapshot) 
開發者ID:apache,項目名稱:airflow,代碼行數:20,代碼來源:test_mark_tasks.py

示例4: test_mark_tasks_subdag

# 需要導入模塊: from airflow.utils.state import State [as 別名]
# 或者: from airflow.utils.state.State import SUCCESS [as 別名]
def test_mark_tasks_subdag(self):
        # set one task to success towards end of scheduled dag runs
        task = self.dag2.get_task("section-1")
        relatives = task.get_flat_relatives(upstream=False)
        task_ids = [t.task_id for t in relatives]
        task_ids.append(task.task_id)

        altered = set_state(tasks=[task], execution_date=self.execution_dates[0],
                            upstream=False, downstream=True, future=False,
                            past=False, state=State.SUCCESS, commit=True)
        self.assertEqual(len(altered), 14)

        # cannot use snapshot here as that will require drilling down the
        # the sub dag tree essentially recreating the same code as in the
        # tested logic.
        self.verify_state(self.dag2, task_ids, [self.execution_dates[0]],
                          State.SUCCESS, []) 
開發者ID:apache,項目名稱:airflow,代碼行數:19,代碼來源:test_mark_tasks.py

示例5: test_set_state_without_commit

# 需要導入模塊: from airflow.utils.state import State [as 別名]
# 或者: from airflow.utils.state.State import SUCCESS [as 別名]
def test_set_state_without_commit(self):
        date = self.execution_dates[0]
        dr = self._create_test_dag_run(State.RUNNING, date)
        self._set_default_task_instance_states(dr)

        will_be_altered = set_dag_run_state_to_running(self.dag1, date, commit=False)

        # None of the tasks will be altered.
        self.assertEqual(len(will_be_altered), 0)
        self._verify_dag_run_state(self.dag1, date, State.RUNNING)
        self._verify_task_instance_states_remain_default(dr)

        will_be_altered = set_dag_run_state_to_failed(self.dag1, date, commit=False)

        # Only the running task will be altered.
        self.assertEqual(len(will_be_altered), 1)
        self._verify_dag_run_state(self.dag1, date, State.RUNNING)
        self._verify_task_instance_states_remain_default(dr)

        will_be_altered = set_dag_run_state_to_success(self.dag1, date, commit=False)

        # All except the SUCCESS task should be altered.
        self.assertEqual(len(will_be_altered), 5)
        self._verify_dag_run_state(self.dag1, date, State.RUNNING)
        self._verify_task_instance_states_remain_default(dr) 
開發者ID:apache,項目名稱:airflow,代碼行數:27,代碼來源:test_mark_tasks.py

示例6: test_should_render_dag_with_task_instances

# 需要導入模塊: from airflow.utils.state import State [as 別名]
# 或者: from airflow.utils.state.State import SUCCESS [as 別名]
def test_should_render_dag_with_task_instances(self):
        dag = DAG(dag_id="DAG_ID")
        task_1 = BashOperator(dag=dag, start_date=START_DATE, task_id="first", bash_command="echo 1")
        task_2 = BashOperator(dag=dag, start_date=START_DATE, task_id="second", bash_command="echo 1")
        task_3 = PythonOperator(
            dag=dag, start_date=START_DATE, task_id="third", python_callable=mock.MagicMock()
        )
        task_1 >> task_2
        task_1 >> task_3
        tis = [
            TaskInstance(task_1, execution_date=START_DATE, state=State.SCHEDULED),
            TaskInstance(task_2, execution_date=START_DATE, state=State.SUCCESS),
            TaskInstance(task_3, execution_date=START_DATE, state=State.RUNNING),
        ]
        dot = dot_renderer.render_dag(dag, tis=tis)
        source = dot.source
        # Should render DAG title
        self.assertIn("label=DAG_ID", source)
        self.assertIn('first [color=black fillcolor=tan shape=rectangle style="filled,rounded"]', source)
        self.assertIn('second [color=white fillcolor=green shape=rectangle style="filled,rounded"]', source)
        self.assertIn('third [color=black fillcolor=lime shape=rectangle style="filled,rounded"]', source) 
開發者ID:apache,項目名稱:airflow,代碼行數:23,代碼來源:test_dot_renderer.py

示例7: test_image_pull_secrets_correctly_set

# 需要導入模塊: from airflow.utils.state import State [as 別名]
# 或者: from airflow.utils.state.State import SUCCESS [as 別名]
def test_image_pull_secrets_correctly_set(self, mock_client, monitor_mock, start_mock):
        from airflow.utils.state import State

        fake_pull_secrets = "fakeSecret"
        k = KubernetesPodOperator(
            namespace='default',
            image="ubuntu:16.04",
            cmds=["bash", "-cx"],
            arguments=["echo 10"],
            labels={"foo": "bar"},
            name="test",
            task_id="task",
            in_cluster=False,
            do_xcom_push=False,
            image_pull_secrets=fake_pull_secrets,
            cluster_context='default',
        )
        monitor_mock.return_value = (State.SUCCESS, None)
        context = self.create_context(k)
        k.execute(context=context)
        self.assertEqual(
            start_mock.call_args[0][0].spec.image_pull_secrets,
            [k8s.V1LocalObjectReference(name=fake_pull_secrets)]
        ) 
開發者ID:apache,項目名稱:airflow,代碼行數:26,代碼來源:test_kubernetes_pod.py

示例8: test_mark_non_runnable_task_as_success

# 需要導入模塊: from airflow.utils.state import State [as 別名]
# 或者: from airflow.utils.state.State import SUCCESS [as 別名]
def test_mark_non_runnable_task_as_success(self):
        """
        test that running task with mark_success param update task state
        as SUCCESS without running task despite it fails dependency checks.
        """
        non_runnable_state = (
            set(State.task_states) - RUNNABLE_STATES - set(State.SUCCESS)).pop()
        dag = models.DAG(dag_id='test_mark_non_runnable_task_as_success')
        task = DummyOperator(
            task_id='test_mark_non_runnable_task_as_success_op',
            dag=dag,
            pool='test_pool',
            owner='airflow',
            start_date=timezone.datetime(2016, 2, 1, 0, 0, 0))
        ti = TI(
            task=task, execution_date=timezone.utcnow(), state=non_runnable_state)
        # TI.run() will sync from DB before validating deps.
        with create_session() as session:
            session.add(ti)
            session.commit()
        ti.run(mark_success=True)
        self.assertEqual(ti.state, State.SUCCESS) 
開發者ID:apache,項目名稱:airflow,代碼行數:24,代碼來源:test_taskinstance.py

示例9: test_run_pooling_task_with_mark_success

# 需要導入模塊: from airflow.utils.state import State [as 別名]
# 或者: from airflow.utils.state.State import SUCCESS [as 別名]
def test_run_pooling_task_with_mark_success(self):
        """
        test that running task in an existing pool with mark_success param
        update task state as SUCCESS without running task
        despite it fails dependency checks.
        """
        dag = models.DAG(dag_id='test_run_pooling_task_with_mark_success')
        task = DummyOperator(
            task_id='test_run_pooling_task_with_mark_success_op',
            dag=dag,
            pool='test_pool',
            owner='airflow',
            start_date=timezone.datetime(2016, 2, 1, 0, 0, 0))
        ti = TI(
            task=task, execution_date=timezone.utcnow())
        ti.run(mark_success=True)
        self.assertEqual(ti.state, State.SUCCESS) 
開發者ID:apache,項目名稱:airflow,代碼行數:19,代碼來源:test_taskinstance.py

示例10: test_previous_ti

# 需要導入模塊: from airflow.utils.state import State [as 別名]
# 或者: from airflow.utils.state.State import SUCCESS [as 別名]
def test_previous_ti(self, _, schedule_interval, catchup) -> None:

        scenario = [State.SUCCESS, State.FAILED, State.SUCCESS]

        ti_list = self._test_previous_dates_setup(schedule_interval, catchup, scenario)

        self.assertIsNone(ti_list[0].get_previous_ti())

        self.assertEqual(
            ti_list[2].get_previous_ti().execution_date,
            ti_list[1].execution_date
        )

        self.assertNotEqual(
            ti_list[2].get_previous_ti().execution_date,
            ti_list[0].execution_date
        ) 
開發者ID:apache,項目名稱:airflow,代碼行數:19,代碼來源:test_taskinstance.py

示例11: test_previous_ti_success

# 需要導入模塊: from airflow.utils.state import State [as 別名]
# 或者: from airflow.utils.state.State import SUCCESS [as 別名]
def test_previous_ti_success(self, _, schedule_interval, catchup) -> None:

        scenario = [State.FAILED, State.SUCCESS, State.FAILED, State.SUCCESS]

        ti_list = self._test_previous_dates_setup(schedule_interval, catchup, scenario)

        self.assertIsNone(ti_list[0].get_previous_ti(state=State.SUCCESS))
        self.assertIsNone(ti_list[1].get_previous_ti(state=State.SUCCESS))

        self.assertEqual(
            ti_list[3].get_previous_ti(state=State.SUCCESS).execution_date,
            ti_list[1].execution_date
        )

        self.assertNotEqual(
            ti_list[3].get_previous_ti(state=State.SUCCESS).execution_date,
            ti_list[2].execution_date
        ) 
開發者ID:apache,項目名稱:airflow,代碼行數:20,代碼來源:test_taskinstance.py

示例12: test_previous_execution_date_success

# 需要導入模塊: from airflow.utils.state import State [as 別名]
# 或者: from airflow.utils.state.State import SUCCESS [as 別名]
def test_previous_execution_date_success(self, _, schedule_interval, catchup) -> None:

        scenario = [State.FAILED, State.SUCCESS, State.FAILED, State.SUCCESS]

        ti_list = self._test_previous_dates_setup(schedule_interval, catchup, scenario)

        self.assertIsNone(ti_list[0].get_previous_execution_date(state=State.SUCCESS))
        self.assertIsNone(ti_list[1].get_previous_execution_date(state=State.SUCCESS))
        self.assertEqual(
            ti_list[3].get_previous_execution_date(state=State.SUCCESS),
            ti_list[1].execution_date
        )
        self.assertNotEqual(
            ti_list[3].get_previous_execution_date(state=State.SUCCESS),
            ti_list[2].execution_date
        ) 
開發者ID:apache,項目名稱:airflow,代碼行數:18,代碼來源:test_taskinstance.py

示例13: test_previous_start_date_success

# 需要導入模塊: from airflow.utils.state import State [as 別名]
# 或者: from airflow.utils.state.State import SUCCESS [as 別名]
def test_previous_start_date_success(self, _, schedule_interval, catchup) -> None:

        scenario = [State.FAILED, State.SUCCESS, State.FAILED, State.SUCCESS]

        ti_list = self._test_previous_dates_setup(schedule_interval, catchup, scenario)

        self.assertIsNone(ti_list[0].get_previous_start_date(state=State.SUCCESS))
        self.assertIsNone(ti_list[1].get_previous_start_date(state=State.SUCCESS))
        self.assertEqual(
            ti_list[3].get_previous_start_date(state=State.SUCCESS),
            ti_list[1].start_date,
        )
        self.assertNotEqual(
            ti_list[3].get_previous_start_date(state=State.SUCCESS),
            ti_list[2].start_date,
        ) 
開發者ID:apache,項目名稱:airflow,代碼行數:18,代碼來源:test_taskinstance.py

示例14: test_depends_on_past

# 需要導入模塊: from airflow.utils.state import State [as 別名]
# 或者: from airflow.utils.state.State import SUCCESS [as 別名]
def test_depends_on_past(self, prev_ti_state, is_ti_success):
        dag_id = 'test_depends_on_past'

        dag = self.dagbag.get_dag(dag_id)
        task = dag.tasks[0]

        self.create_dag_run(dag, execution_date=timezone.datetime(2016, 1, 1, 0, 0, 0))
        self.create_dag_run(dag, execution_date=timezone.datetime(2016, 1, 2, 0, 0, 0))

        prev_ti = TI(task, timezone.datetime(2016, 1, 1, 0, 0, 0))
        ti = TI(task, timezone.datetime(2016, 1, 2, 0, 0, 0))

        prev_ti.set_state(prev_ti_state)
        ti.set_state(State.QUEUED)
        ti.run()
        self.assertEqual(ti.state == State.SUCCESS, is_ti_success) 
開發者ID:apache,項目名稱:airflow,代碼行數:18,代碼來源:test_dagrun.py

示例15: test_wait_for_downstream

# 需要導入模塊: from airflow.utils.state import State [as 別名]
# 或者: from airflow.utils.state.State import SUCCESS [as 別名]
def test_wait_for_downstream(self, prev_ti_state, is_ti_success):
        dag_id = 'test_wait_for_downstream'
        dag = self.dagbag.get_dag(dag_id)
        upstream, downstream = dag.tasks

        # For ti.set_state() to work, the DagRun has to exist,
        # Otherwise ti.previous_ti returns an unpersisted TI
        self.create_dag_run(dag, execution_date=timezone.datetime(2016, 1, 1, 0, 0, 0))
        self.create_dag_run(dag, execution_date=timezone.datetime(2016, 1, 2, 0, 0, 0))

        prev_ti_downstream = TI(task=downstream, execution_date=timezone.datetime(2016, 1, 1, 0, 0, 0))
        ti = TI(task=upstream, execution_date=timezone.datetime(2016, 1, 2, 0, 0, 0))
        prev_ti = ti.get_previous_ti()
        prev_ti.set_state(State.SUCCESS)
        self.assertEqual(prev_ti.state, State.SUCCESS)

        prev_ti_downstream.set_state(prev_ti_state)
        ti.set_state(State.QUEUED)
        ti.run()
        self.assertEqual(ti.state == State.SUCCESS, is_ti_success) 
開發者ID:apache,項目名稱:airflow,代碼行數:22,代碼來源:test_dagrun.py


注:本文中的airflow.utils.state.State.SUCCESS屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。