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


Python CloudVisionHook.annotate_image方法代码示例

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


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

示例1: TestGcpVisionHook

# 需要导入模块: from airflow.contrib.hooks.gcp_vision_hook import CloudVisionHook [as 别名]
# 或者: from airflow.contrib.hooks.gcp_vision_hook.CloudVisionHook import annotate_image [as 别名]

#.........这里部分代码省略.........
        # When
        self.hook.add_product_to_product_set(
            product_set_id=PRODUCTSET_ID_TEST,
            product_id=PRODUCT_ID_TEST,
            location=LOC_ID_TEST,
            project_id=PROJECT_ID_TEST,
        )
        # Then
        # Product ID was provided explicitly in the method call above, should be returned from the method
        add_product_to_product_set_method.assert_called_once_with(
            name=PRODUCTSET_NAME_TEST, product=PRODUCT_NAME_TEST, retry=None, timeout=None, metadata=None
        )

    # remove_product_from_product_set
    @mock.patch('airflow.contrib.hooks.gcp_vision_hook.CloudVisionHook.get_conn')
    def test_remove_product_from_product_set(self, get_conn):
        # Given
        remove_product_from_product_set_method = get_conn.return_value.remove_product_from_product_set

        # When
        self.hook.remove_product_from_product_set(
            product_set_id=PRODUCTSET_ID_TEST,
            product_id=PRODUCT_ID_TEST,
            location=LOC_ID_TEST,
            project_id=PROJECT_ID_TEST,
        )
        # Then
        # Product ID was provided explicitly in the method call above, should be returned from the method
        remove_product_from_product_set_method.assert_called_once_with(
            name=PRODUCTSET_NAME_TEST, product=PRODUCT_NAME_TEST, retry=None, timeout=None, metadata=None
        )

    @mock.patch('airflow.contrib.hooks.gcp_vision_hook.CloudVisionHook.annotator_client')
    def test_annotate_image(self, annotator_client_mock):
        # Given
        annotate_image_method = annotator_client_mock.annotate_image

        # When
        self.hook.annotate_image(request=ANNOTATE_IMAGE_REQUEST)
        # Then
        # Product ID was provided explicitly in the method call above, should be returned from the method
        annotate_image_method.assert_called_once_with(
            request=ANNOTATE_IMAGE_REQUEST, retry=None, timeout=None
        )

    @mock.patch('airflow.contrib.hooks.gcp_vision_hook.CloudVisionHook.get_conn')
    def test_create_product_explicit_id(self, get_conn):
        # Given
        create_product_method = get_conn.return_value.create_product
        create_product_method.return_value = None
        parent = ProductSearchClient.location_path(PROJECT_ID_TEST, LOC_ID_TEST)
        product = Product()
        # When
        result = self.hook.create_product(
            location=LOC_ID_TEST, product_id=PRODUCT_ID_TEST, product=product, project_id=PROJECT_ID_TEST
        )
        # Then
        # Product ID was provided explicitly in the method call above, should be returned from the method
        self.assertEqual(result, PRODUCT_ID_TEST)
        create_product_method.assert_called_once_with(
            parent=parent,
            product=product,
            product_id=PRODUCT_ID_TEST,
            retry=None,
            timeout=None,
            metadata=None,
开发者ID:Fokko,项目名称:incubator-airflow,代码行数:70,代码来源:test_gcp_vision_hook.py

示例2: execute

# 需要导入模块: from airflow.contrib.hooks.gcp_vision_hook import CloudVisionHook [as 别名]
# 或者: from airflow.contrib.hooks.gcp_vision_hook.CloudVisionHook import annotate_image [as 别名]
 def execute(self, context):
     hook = CloudVisionHook(gcp_conn_id=self.gcp_conn_id)
     return hook.annotate_image(request=self.request, retry=self.retry, timeout=self.timeout)
开发者ID:astronomerio,项目名称:incubator-airflow,代码行数:5,代码来源:gcp_vision_operator.py


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