当前位置: 首页>>代码示例>>Python>>正文


Python DagRun.dag_id方法代码示例

本文整理汇总了Python中airflow.models.DagRun.dag_id方法的典型用法代码示例。如果您正苦于以下问题:Python DagRun.dag_id方法的具体用法?Python DagRun.dag_id怎么用?Python DagRun.dag_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在airflow.models.DagRun的用法示例。


在下文中一共展示了DagRun.dag_id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_success_dag_never_run

# 需要导入模块: from airflow.models import DagRun [as 别名]
# 或者: from airflow.models.DagRun import dag_id [as 别名]
def test_success_dag_never_run(self):
        endpoint = "success"
        dag_id = "example_bash_operator"
        form = dict(
            task_id="run_this_last",
            dag_id=dag_id,
            execution_date=self.EXAMPLE_DAG_DEFAULT_DATE,
            upstream="false",
            downstream="false",
            future="false",
            past="false",
            origin="/graph?dag_id=example_bash_operator",
        )
        clear_db_runs()
        resp = self.client.post('success', data=form, follow_redirects=True)
        self.check_content_in_response(
            f"Cannot make {endpoint}, seem that dag {dag_id} has never run", resp) 
开发者ID:apache,项目名称:airflow,代码行数:19,代码来源:test_views.py

示例2: test_delete_dag_button_for_dag_on_scheduler_only

# 需要导入模块: from airflow.models import DagRun [as 别名]
# 或者: from airflow.models.DagRun import dag_id [as 别名]
def test_delete_dag_button_for_dag_on_scheduler_only(self):
        # Test for JIRA AIRFLOW-3233 (PR 4069):
        # The delete-dag URL should be generated correctly for DAGs
        # that exist on the scheduler (DB) but not the webserver DagBag

        dag_id = 'example_bash_operator'
        test_dag_id = "non_existent_dag"

        DM = models.DagModel
        dag_query = self.session.query(DM).filter(DM.dag_id == dag_id)
        dag_query.first().tags = []  # To avoid "FOREIGN KEY constraint" error
        self.session.commit()

        dag_query.update({'dag_id': test_dag_id})
        self.session.commit()

        resp = self.client.get('/', follow_redirects=True)
        self.check_content_in_response('/delete?dag_id={}'.format(test_dag_id), resp)
        self.check_content_in_response("return confirmDeleteDag(this, '{}')".format(test_dag_id), resp)

        self.session.query(DM).filter(DM.dag_id == test_dag_id).update({'dag_id': dag_id})
        self.session.commit() 
开发者ID:apache,项目名称:airflow,代码行数:24,代码来源:test_views.py

示例3: test_show_external_log_redirect_link_with_external_log_handler

# 需要导入模块: from airflow.models import DagRun [as 别名]
# 或者: from airflow.models.DagRun import dag_id [as 别名]
def test_show_external_log_redirect_link_with_external_log_handler(self, endpoint, mock_log_handler):
        """Show external links if log handler is external."""
        class ExternalHandler(ExternalLoggingMixin):
            LOG_NAME = 'ExternalLog'

            @property
            def log_name(self):
                return self.LOG_NAME

        mock_log_handler.return_value = ExternalHandler()

        url = f'{endpoint}?dag_id=example_bash_operator'
        with self.capture_templates() as templates:
            self.client.get(url, follow_redirects=True)
            ctx = templates[0].local_context
            self.assertTrue(ctx['show_external_log_redirect'])
            self.assertEqual(ctx['external_log_name'], ExternalHandler.LOG_NAME) 
开发者ID:apache,项目名称:airflow,代码行数:19,代码来源:test_views.py

示例4: test_get_logs_with_metadata_as_download_file

# 需要导入模块: from airflow.models import DagRun [as 别名]
# 或者: from airflow.models.DagRun import dag_id [as 别名]
def test_get_logs_with_metadata_as_download_file(self):
        url_template = "get_logs_with_metadata?dag_id={}&" \
                       "task_id={}&execution_date={}&" \
                       "try_number={}&metadata={}&format=file"
        try_number = 1
        url = url_template.format(self.DAG_ID,
                                  self.TASK_ID,
                                  quote_plus(self.DEFAULT_DATE.isoformat()),
                                  try_number,
                                  json.dumps({}))
        response = self.client.get(url)
        expected_filename = '{}/{}/{}/{}.log'.format(self.DAG_ID,
                                                     self.TASK_ID,
                                                     self.DEFAULT_DATE.isoformat(),
                                                     try_number)

        content_disposition = response.headers.get('Content-Disposition')
        self.assertTrue(content_disposition.startswith('attachment'))
        self.assertTrue(expected_filename in content_disposition)
        self.assertEqual(200, response.status_code)
        self.assertIn('Log for testing.', response.data.decode('utf-8')) 
开发者ID:apache,项目名称:airflow,代码行数:23,代码来源:test_views.py

示例5: test_get_logs_with_metadata_as_download_large_file

# 需要导入模块: from airflow.models import DagRun [as 别名]
# 或者: from airflow.models.DagRun import dag_id [as 别名]
def test_get_logs_with_metadata_as_download_large_file(self):
        with mock.patch("airflow.utils.log.file_task_handler.FileTaskHandler.read") as read_mock:
            first_return = (['1st line'], [{}])
            second_return = (['2nd line'], [{'end_of_log': False}])
            third_return = (['3rd line'], [{'end_of_log': True}])
            fourth_return = (['should never be read'], [{'end_of_log': True}])
            read_mock.side_effect = [first_return, second_return, third_return, fourth_return]
            url_template = "get_logs_with_metadata?dag_id={}&" \
                           "task_id={}&execution_date={}&" \
                           "try_number={}&metadata={}&format=file"
            try_number = 1
            url = url_template.format(self.DAG_ID,
                                      self.TASK_ID,
                                      quote_plus(self.DEFAULT_DATE.isoformat()),
                                      try_number,
                                      json.dumps({}))
            response = self.client.get(url)

            self.assertIn('1st line', response.data.decode('utf-8'))
            self.assertIn('2nd line', response.data.decode('utf-8'))
            self.assertIn('3rd line', response.data.decode('utf-8'))
            self.assertNotIn('should never be read', response.data.decode('utf-8')) 
开发者ID:apache,项目名称:airflow,代码行数:24,代码来源:test_views.py

示例6: test_get_logs_with_metadata

# 需要导入模块: from airflow.models import DagRun [as 别名]
# 或者: from airflow.models.DagRun import dag_id [as 别名]
def test_get_logs_with_metadata(self):
        url_template = "get_logs_with_metadata?dag_id={}&" \
                       "task_id={}&execution_date={}&" \
                       "try_number={}&metadata={}"
        response = \
            self.client.get(url_template.format(self.DAG_ID,
                                                self.TASK_ID,
                                                quote_plus(self.DEFAULT_DATE.isoformat()),
                                                1,
                                                json.dumps({})), data=dict(
                                                    username='test',
                                                    password='test'),
                            follow_redirects=True)

        self.assertIn('"message":', response.data.decode('utf-8'))
        self.assertIn('"metadata":', response.data.decode('utf-8'))
        self.assertIn('Log for testing.', response.data.decode('utf-8'))
        self.assertEqual(200, response.status_code) 
开发者ID:apache,项目名称:airflow,代码行数:20,代码来源:test_views.py

示例7: test_get_logs_with_metadata_for_removed_dag

# 需要导入模块: from airflow.models import DagRun [as 别名]
# 或者: from airflow.models.DagRun import dag_id [as 别名]
def test_get_logs_with_metadata_for_removed_dag(self, mock_read):
        mock_read.return_value = (['airflow log line'], [{'end_of_log': True}])
        url_template = "get_logs_with_metadata?dag_id={}&" \
                       "task_id={}&execution_date={}&" \
                       "try_number={}&metadata={}"
        url = url_template.format(self.DAG_ID_REMOVED, self.TASK_ID,
                                  quote_plus(self.DEFAULT_DATE.isoformat()), 1, json.dumps({}))
        response = self.client.get(
            url,
            data=dict(
                username='test',
                password='test'
            ),
            follow_redirects=True
        )

        self.assertIn('"message":', response.data.decode('utf-8'))
        self.assertIn('"metadata":', response.data.decode('utf-8'))
        self.assertIn('airflow log line', response.data.decode('utf-8'))
        self.assertEqual(200, response.status_code) 
开发者ID:apache,项目名称:airflow,代码行数:22,代码来源:test_views.py

示例8: test_get_logs_for_handler_without_read_method

# 需要导入模块: from airflow.models import DagRun [as 别名]
# 或者: from airflow.models.DagRun import dag_id [as 别名]
def test_get_logs_for_handler_without_read_method(self, mock_log_reader):
        type(mock_log_reader.return_value).supports_read = PropertyMock(return_value=False)

        url_template = "get_logs_with_metadata?dag_id={}&" \
                       "task_id={}&execution_date={}&" \
                       "try_number={}&metadata={}&format=json"
        try_number = 1
        url = url_template.format(self.DAG_ID,
                                  self.TASK_ID,
                                  quote_plus(self.DEFAULT_DATE.isoformat()),
                                  try_number,
                                  json.dumps({}))
        response = self.client.get(url)
        self.assertEqual(200, response.status_code)
        self.assertIn('message', response.json)
        self.assertIn('metadata', response.json)
        self.assertIn(
            'Task log handler does not support read logs.',
            response.json['message']) 
开发者ID:apache,项目名称:airflow,代码行数:21,代码来源:test_views.py

示例9: test_blocked_success_when_selecting_dags

# 需要导入模块: from airflow.models import DagRun [as 别名]
# 或者: from airflow.models.DagRun import dag_id [as 别名]
def test_blocked_success_when_selecting_dags(self):
        resp = self.client.post('blocked',
                                data={'dag_ids': ['example_subdag_operator']},
                                follow_redirects=True)
        self.assertEqual(resp.status_code, 200)
        blocked_dags = {blocked['dag_id'] for blocked in json.loads(resp.data.decode('utf-8'))}
        self.assertNotIn('example_bash_operator', blocked_dags)
        self.assertIn('example_subdag_operator', blocked_dags)

        # Multiple
        resp = self.client.post('blocked',
                                data={'dag_ids': ['example_subdag_operator', 'example_bash_operator']},
                                follow_redirects=True)
        self.assertEqual(resp.status_code, 200)
        blocked_dags = {blocked['dag_id'] for blocked in json.loads(resp.data.decode('utf-8'))}
        self.assertIn('example_bash_operator', blocked_dags)
        self.assertIn('example_subdag_operator', blocked_dags)
        self.check_content_not_in_response('example_xcom', resp) 
开发者ID:apache,项目名称:airflow,代码行数:20,代码来源:test_views.py

示例10: test_success_fail_for_read_only_role

# 需要导入模块: from airflow.models import DagRun [as 别名]
# 或者: from airflow.models.DagRun import dag_id [as 别名]
def test_success_fail_for_read_only_role(self):
        # succcess endpoint need can_dag_edit, which read only role can not access
        self.logout()
        self.login(username='dag_read_only',
                   password='dag_read_only')

        form = dict(
            task_id="run_this_last",
            dag_id="example_bash_operator",
            execution_date=self.default_date,
            upstream="false",
            downstream="false",
            future="false",
            past="false",
        )
        resp = self.client.post('success', data=form)
        self.check_content_not_in_response('Wait a minute', resp, resp_code=302) 
开发者ID:apache,项目名称:airflow,代码行数:19,代码来源:test_views.py

示例11: test_user_defined_filter_and_macros_raise_error

# 需要导入模块: from airflow.models import DagRun [as 别名]
# 或者: from airflow.models.DagRun import dag_id [as 别名]
def test_user_defined_filter_and_macros_raise_error(self):
        """
        Test that the Rendered View is able to show rendered values
        even for TIs that have not yet executed
        """
        self.app.dag_bag = mock.MagicMock(
            **{'get_dag.return_value': SerializedDagModel.get(self.dag.dag_id).dag}
        )
        self.assertEqual(self.task2.bash_command,
                         'echo {{ fullname("Apache", "Airflow") | hello }}')

        url = ('rendered?task_id=task2&dag_id=testdag&execution_date={}'
               .format(self.percent_encode(self.default_date)))

        resp = self.client.get(url, follow_redirects=True)
        self.check_content_not_in_response("echo Hello Apache Airflow", resp)
        self.check_content_in_response(
            "Webserver does not have access to User-defined Macros or Filters "
            "when Dag Serialization is enabled. Hence for the task that have not yet "
            "started running, please use 'airflow tasks render' for debugging the "
            "rendering of template_fields.<br/><br/>OriginalError: no filter named &#39;hello&#39",
            resp
        ) 
开发者ID:apache,项目名称:airflow,代码行数:25,代码来源:test_views.py

示例12: test_trigger_dag_conf

# 需要导入模块: from airflow.models import DagRun [as 别名]
# 或者: from airflow.models.DagRun import dag_id [as 别名]
def test_trigger_dag_conf(self):

        test_dag_id = "example_bash_operator"
        conf_dict = {'string': 'Hello, World!'}

        DR = models.DagRun
        self.session.query(DR).delete()
        self.session.commit()

        self.client.post('trigger?dag_id={}'.format(test_dag_id), data={'conf': json.dumps(conf_dict)})

        run = self.session.query(DR).filter(DR.dag_id == test_dag_id).first()
        self.assertIsNotNone(run)
        self.assertIn(DagRunType.MANUAL.value, run.run_id)
        self.assertEqual(run.run_type, DagRunType.MANUAL.value)
        self.assertEqual(run.conf, conf_dict) 
开发者ID:apache,项目名称:airflow,代码行数:18,代码来源:test_views.py

示例13: test_task

# 需要导入模块: from airflow.models import DagRun [as 别名]
# 或者: from airflow.models.DagRun import dag_id [as 别名]
def test_task(self):
        url = ('task?task_id=runme_0&dag_id=example_bash_operator&execution_date={}'
               .format(self.percent_encode(self.EXAMPLE_DAG_DEFAULT_DATE)))
        resp = self.client.get(url, follow_redirects=True)
        self.check_content_in_response('Task Instance Details', resp) 
开发者ID:apache,项目名称:airflow,代码行数:7,代码来源:test_views.py

示例14: test_xcom

# 需要导入模块: from airflow.models import DagRun [as 别名]
# 或者: from airflow.models.DagRun import dag_id [as 别名]
def test_xcom(self):
        url = ('xcom?task_id=runme_0&dag_id=example_bash_operator&execution_date={}'
               .format(self.percent_encode(self.EXAMPLE_DAG_DEFAULT_DATE)))
        resp = self.client.get(url, follow_redirects=True)
        self.check_content_in_response('XCom', resp) 
开发者ID:apache,项目名称:airflow,代码行数:7,代码来源:test_views.py

示例15: test_rendered

# 需要导入模块: from airflow.models import DagRun [as 别名]
# 或者: from airflow.models.DagRun import dag_id [as 别名]
def test_rendered(self):
        url = ('rendered?task_id=runme_0&dag_id=example_bash_operator&execution_date={}'
               .format(self.percent_encode(self.EXAMPLE_DAG_DEFAULT_DATE)))
        resp = self.client.get(url, follow_redirects=True)
        self.check_content_in_response('Rendered Template', resp) 
开发者ID:apache,项目名称:airflow,代码行数:7,代码来源:test_views.py


注:本文中的airflow.models.DagRun.dag_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。