示例#1
0
 def test_additional_params(self, mock_hook):
     op = CloudVisionDetectTextOperator(
         image=DETECT_TEST_IMAGE,
         task_id="id",
         language_hints="pl",
         web_detection_params={'param': 'test'},
         additional_properties={
             'image_context': {
                 'additional_property_1': 'add_1'
             },
             'additional_property_2': 'add_2'
         })
     op.execute(context=None)
     mock_hook.assert_called_once_with(gcp_conn_id=GCP_CONN_ID)
     mock_hook.return_value.text_detection.assert_called_once_with(
         image=DETECT_TEST_IMAGE,
         max_results=None,
         retry=None,
         timeout=None,
         additional_properties={
             'additional_property_2': 'add_2',
             'image_context': {
                 'language_hints': 'pl',
                 'additional_property_1': 'add_1',
                 'web_detection_params': {
                     'param': 'test'
                 }
             }
         })
示例#2
0
 def test_minimal_green_path(self, mock_hook):
     op = CloudVisionDetectTextOperator(image=DETECT_TEST_IMAGE, task_id="id")
     op.execute(context=None)
     mock_hook.assert_called_once_with(gcp_conn_id=GCP_CONN_ID)
     mock_hook.return_value.text_detection.assert_called_once_with(
         image=DETECT_TEST_IMAGE, max_results=None, retry=None, timeout=None, additional_properties=None
     )
示例#3
0
        task_id='annotate_image')
    # [END howto_operator_vision_annotate_image]

    # [START howto_operator_vision_annotate_image_result]
    annotate_image_result = BashOperator(
        bash_command="echo {{ task_instance.xcom_pull('annotate_image')"
        "['logoAnnotations'][0]['description'] }}",
        task_id='annotate_image_result',
    )
    # [END howto_operator_vision_annotate_image_result]

    # [START howto_operator_vision_detect_text]
    detect_text = CloudVisionDetectTextOperator(
        image=DETECT_IMAGE,
        retry=Retry(maximum=10.0),
        timeout=5,
        task_id="detect_text",
        language_hints="en",
        web_detection_params={'include_geo_results': True},
    )
    # [END howto_operator_vision_detect_text]

    # [START howto_operator_vision_detect_text_result]
    detect_text_result = BashOperator(
        bash_command=
        "echo {{ task_instance.xcom_pull('detect_text')['textAnnotations'][0] }}",
        task_id="detect_text_result",
    )
    # [END howto_operator_vision_detect_text_result]

    # [START howto_operator_vision_document_detect_text]
    document_detect_text = CloudVisionTextDetectOperator(