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


Python DataFlowHook.start_template_dataflow方法代码示例

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


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

示例1: execute

# 需要导入模块: from airflow.contrib.hooks.gcp_dataflow_hook import DataFlowHook [as 别名]
# 或者: from airflow.contrib.hooks.gcp_dataflow_hook.DataFlowHook import start_template_dataflow [as 别名]
    def execute(self, context):
        hook = DataFlowHook(gcp_conn_id=self.gcp_conn_id,
                            delegate_to=self.delegate_to,
                            poll_sleep=self.poll_sleep)

        hook.start_template_dataflow(self.task_id, self.dataflow_default_options,
                                     self.parameters, self.template)
开发者ID:caseybrown89,项目名称:airflow,代码行数:9,代码来源:dataflow_operator.py

示例2: DataFlowTemplateHookTest

# 需要导入模块: from airflow.contrib.hooks.gcp_dataflow_hook import DataFlowHook [as 别名]
# 或者: from airflow.contrib.hooks.gcp_dataflow_hook.DataFlowHook import start_template_dataflow [as 别名]
class DataFlowTemplateHookTest(unittest.TestCase):

    def setUp(self):
        with mock.patch(BASE_STRING.format('GoogleCloudBaseHook.__init__'),
                        new=mock_init):
            self.dataflow_hook = DataFlowHook(gcp_conn_id='test')

    @mock.patch(DATAFLOW_STRING.format('DataFlowHook._start_template_dataflow'))
    def test_start_template_dataflow(self, internal_dataflow_mock):
        self.dataflow_hook.start_template_dataflow(
            task_id=TASK_ID, variables=DATAFLOW_OPTIONS_TEMPLATE, parameters=PARAMETERS,
            dataflow_template=TEMPLATE)
        internal_dataflow_mock.assert_called_once_with(
            mock.ANY, DATAFLOW_OPTIONS_TEMPLATE, PARAMETERS, TEMPLATE)
开发者ID:arihantsurana,项目名称:incubator-airflow,代码行数:16,代码来源:test_gcp_dataflow_hook.py

示例3: DataFlowTemplateHookTest

# 需要导入模块: from airflow.contrib.hooks.gcp_dataflow_hook import DataFlowHook [as 别名]
# 或者: from airflow.contrib.hooks.gcp_dataflow_hook.DataFlowHook import start_template_dataflow [as 别名]
class DataFlowTemplateHookTest(unittest.TestCase):

    def setUp(self):
        with mock.patch(BASE_STRING.format('GoogleCloudBaseHook.__init__'),
                        new=mock_init):
            self.dataflow_hook = DataFlowHook(gcp_conn_id='test')

    @mock.patch(DATAFLOW_STRING.format('DataFlowHook._start_template_dataflow'))
    def test_start_template_dataflow(self, internal_dataflow_mock):
        self.dataflow_hook.start_template_dataflow(
            job_name=JOB_NAME, variables=DATAFLOW_OPTIONS_TEMPLATE, parameters=PARAMETERS,
            dataflow_template=TEMPLATE)
        options_with_region = {'region': 'us-central1'}
        options_with_region.update(DATAFLOW_OPTIONS_TEMPLATE)
        internal_dataflow_mock.assert_called_once_with(
            mock.ANY, options_with_region, PARAMETERS, TEMPLATE)

    @mock.patch(DATAFLOW_STRING.format('_DataflowJob'))
    @mock.patch(DATAFLOW_STRING.format('DataFlowHook.get_conn'))
    def test_start_template_dataflow_with_runtime_env(self, mock_conn, mock_dataflowjob):
        dataflow_options_template = copy.deepcopy(DATAFLOW_OPTIONS_TEMPLATE)
        options_with_runtime_env = copy.deepcopy(RUNTIME_ENV)
        options_with_runtime_env.update(dataflow_options_template)

        dataflowjob_instance = mock_dataflowjob.return_value
        dataflowjob_instance.wait_for_done.return_value = None
        method = (mock_conn.return_value
                  .projects.return_value
                  .locations.return_value
                  .templates.return_value
                  .launch)

        self.dataflow_hook.start_template_dataflow(
            job_name=JOB_NAME,
            variables=options_with_runtime_env,
            parameters=PARAMETERS,
            dataflow_template=TEMPLATE
        )
        body = {"jobName": mock.ANY,
                "parameters": PARAMETERS,
                "environment": RUNTIME_ENV
                }
        method.assert_called_once_with(
            projectId=options_with_runtime_env['project'],
            location='us-central1',
            gcsPath=TEMPLATE,
            body=body,
        )
开发者ID:apache,项目名称:incubator-airflow,代码行数:50,代码来源:test_gcp_dataflow_hook.py

示例4: DataFlowTemplateHookTest

# 需要导入模块: from airflow.contrib.hooks.gcp_dataflow_hook import DataFlowHook [as 别名]
# 或者: from airflow.contrib.hooks.gcp_dataflow_hook.DataFlowHook import start_template_dataflow [as 别名]
class DataFlowTemplateHookTest(unittest.TestCase):

    def setUp(self):
        with mock.patch(BASE_STRING.format('GoogleCloudBaseHook.__init__'),
                        new=mock_init):
            self.dataflow_hook = DataFlowHook(gcp_conn_id='test')

    @mock.patch(DATAFLOW_STRING.format('DataFlowHook._start_template_dataflow'))
    def test_start_template_dataflow(self, internal_dataflow_mock):
        self.dataflow_hook.start_template_dataflow(
            job_name=JOB_NAME, variables=DATAFLOW_OPTIONS_TEMPLATE, parameters=PARAMETERS,
            dataflow_template=TEMPLATE)
        options_with_region = {'region': 'us-central1'}
        options_with_region.update(DATAFLOW_OPTIONS_TEMPLATE)
        internal_dataflow_mock.assert_called_once_with(
            mock.ANY, options_with_region, PARAMETERS, TEMPLATE)
开发者ID:Fokko,项目名称:incubator-airflow,代码行数:18,代码来源:test_gcp_dataflow_hook.py


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