Esempio n. 1
0
    def test_execute(self, mock_hook):
        template = {}

        op = DataprocInstantiateInlineWorkflowTemplateOperator(
            task_id=TASK_ID,
            template=template,
            region=GCP_LOCATION,
            project_id=GCP_PROJECT,
            request_id=REQUEST_ID,
            retry=RETRY,
            timeout=TIMEOUT,
            metadata=METADATA,
            gcp_conn_id=GCP_CONN_ID,
            impersonation_chain=IMPERSONATION_CHAIN,
        )
        op.execute(context={})
        mock_hook.assert_called_once_with(
            gcp_conn_id=GCP_CONN_ID,
            impersonation_chain=IMPERSONATION_CHAIN,
        )
        mock_hook.return_value.instantiate_inline_workflow_template.assert_called_once_with(
            template=template,
            location=GCP_LOCATION,
            project_id=GCP_PROJECT,
            request_id=REQUEST_ID,
            retry=RETRY,
            timeout=TIMEOUT,
            metadata=METADATA,
        )
Esempio n. 2
0
        project_id=PROJECT_ID,
        region=REGION,
    )
    # [END how_to_cloud_dataproc_create_workflow_template]

    # [START how_to_cloud_dataproc_trigger_workflow_template]
    trigger_workflow = DataprocInstantiateWorkflowTemplateOperator(
        task_id="trigger_workflow",
        region=REGION,
        project_id=PROJECT_ID,
        template_id=WORKFLOW_NAME)
    # [END how_to_cloud_dataproc_trigger_workflow_template]

    # [START how_to_cloud_dataproc_instantiate_inline_workflow_template]
    instantiate_inline_workflow_template = DataprocInstantiateInlineWorkflowTemplateOperator(
        task_id='instantiate_inline_workflow_template',
        template=WORKFLOW_TEMPLATE,
        region=REGION)
    # [END how_to_cloud_dataproc_instantiate_inline_workflow_template]

    pig_task = DataprocSubmitJobOperator(task_id="pig_task",
                                         job=PIG_JOB,
                                         region=REGION,
                                         project_id=PROJECT_ID)
    spark_sql_task = DataprocSubmitJobOperator(task_id="spark_sql_task",
                                               job=SPARK_SQL_JOB,
                                               region=REGION,
                                               project_id=PROJECT_ID)

    spark_task = DataprocSubmitJobOperator(task_id="spark_task",
                                           job=SPARK_JOB,
                                           region=REGION,