コード例 #1
0
 def test_minimal_green_path_for_batch(self, mock_hook):
     op = CloudVisionImageAnnotateOperator(
         request=ANNOTATE_REQUEST_BATCH_TEST, task_id='id')
     op.execute(context=None)
     mock_hook.assert_called_once_with(gcp_conn_id=GCP_CONN_ID)
     mock_hook.return_value.batch_annotate_images.assert_called_once_with(
         requests=ANNOTATE_REQUEST_BATCH_TEST, retry=None, timeout=None)
コード例 #2
0
 def test_minimal_green_path_for_one_image(self, mock_hook):
     op = CloudVisionImageAnnotateOperator(request=ANNOTATE_REQUEST_TEST, task_id='id')
     op.execute(context=None)
     mock_hook.assert_called_once_with(
         gcp_conn_id=GCP_CONN_ID, impersonation_chain=None,
     )
     mock_hook.return_value.annotate_image.assert_called_once_with(
         request=ANNOTATE_REQUEST_TEST, retry=None, timeout=None
     )
コード例 #3
0
ファイル: example_vision.py プロジェクト: yulei-li/airflow
    product_set_create_2 >> add_product_to_product_set_2
    product_create_2 >> add_product_to_product_set_2
    remove_product_from_product_set_2 >> product_set_delete_2
    remove_product_from_product_set_2 >> product_delete_2

with models.DAG('example_gcp_vision_annotate_image',
                schedule_interval='@once',
                start_date=days_ago(1)) as dag_annotate_image:
    # ############################## #
    # ### Annotate image example ### #
    # ############################## #

    # [START howto_operator_vision_annotate_image]
    annotate_image = CloudVisionImageAnnotateOperator(
        request=annotate_image_request,
        retry=Retry(maximum=10.0),
        timeout=5,
        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,