Google Cloud Vision 算子

先决任务

要使用这些算子,您必须执行以下几项操作

CloudVisionAddProductToProductSetOperator

创建一个新的 ReferenceImage 资源。

有关参数定义,请参阅 CloudVisionAddProductToProductSetOperator

使用运算符

我们正在使用 ProductProductSetRetry 对象,这些对象来自 Google 库

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

from google.api_core.retry import Retry  # isort:skip

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

from google.cloud.vision_v1.types import ProductSet  # isort:skip

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

from google.cloud.vision_v1.types import Product  # isort:skip

如果 product_set_idproduct_id 是由 API 生成的,则可以从 XCOM 中提取

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

add_product_to_product_set = CloudVisionAddProductToProductSetOperator(
    location=LOCATION,
    product_set_id=product_set_create_output,
    product_id="{{ task_instance.xcom_pull('product_create') }}",
    retry=Retry(maximum=10.0),
    timeout=5,
    task_id="add_product_to_product_set",
)

否则,可以明确指定

tests/system/providers/google/cloud/vision/example_vision_explicit.py[源代码]

add_product_to_product_set_2 = CloudVisionAddProductToProductSetOperator(
    location=LOCATION,
    product_set_id=GCP_VISION_PRODUCT_SET_ID,
    product_id=GCP_VISION_PRODUCT_ID,
    retry=Retry(maximum=10.0),
    timeout=5,
    task_id="add_product_to_product_set_2",
)

模板

template_fields: Sequence[str] = (
    "location",
    "product_set_id",
    "product_id",
    "project_id",
    "gcp_conn_id",
    "impersonation_chain",
)

CloudVisionImageAnnotateOperator

为图像运行图像检测和注释。

有关参数定义,请参阅 CloudVisionImageAnnotateOperator

使用运算符

我们正在使用 enumsRetry 对象,这些对象来自 Google 库

tests/system/providers/google/cloud/vision/example_vision_annotate_image.py[源代码]

from google.api_core.retry import Retry  # isort:skip

tests/system/providers/google/cloud/vision/example_vision_annotate_image.py[源代码]

from google.cloud.vision_v1 import Feature  # isort:skip
from tests.system.providers.google import DEFAULT_GCP_SYSTEM_TEST_PROJECT_ID

tests/system/providers/google/cloud/vision/example_vision_annotate_image.py[源代码]

annotate_image = CloudVisionImageAnnotateOperator(
    request=annotate_image_request,
    retry=Retry(maximum=10.0),
    timeout=5,
    task_id="annotate_image",
)

结果可从 XCOM 中提取

tests/system/providers/google/cloud/vision/example_vision_annotate_image.py[源代码]

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

模板化

template_fields: Sequence[str] = (
    "request",
    "gcp_conn_id",
    "impersonation_chain",
)

更多信息

请参阅 Google Cloud Vision 注释图像文档

CloudVisionCreateProductOperator

创建并返回一个新产品资源。

有关所提供的 Product 对象的可能错误

  • 如果 display_name 缺失或长度超过 4096 个字符,则返回 INVALID_ARGUMENT。

  • 如果 description 的长度超过 4096 个字符,则返回 INVALID_ARGUMENT。

  • 如果 product_category 缺失或无效,则返回 INVALID_ARGUMENT。

有关参数定义,请参阅 CloudVisionCreateProductOperator

使用运算符

我们正在使用 Google 库中的 ProductRetry 对象

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

from google.cloud.vision_v1.types import Product  # isort:skip

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

from google.api_core.retry import Retry  # isort:skip

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

product = Product(display_name="My Product 1", product_category="toys")

可以省略 product_id 参数(它将由 API 生成)

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

product_create = CloudVisionCreateProductOperator(
    location=LOCATION,
    product=product,
    retry=Retry(maximum=10.0),
    timeout=5,
    task_id="product_create",
)

或者可以明确指定

tests/system/providers/google/cloud/vision/example_vision_explicit.py[源代码]

product_create_2 = CloudVisionCreateProductOperator(
    product_id=GCP_VISION_PRODUCT_ID,
    location=LOCATION,
    product=product,
    retry=Retry(maximum=10.0),
    timeout=5,
    task_id="product_create_2",
)

模板化

template_fields: Sequence[str] = (
    "location",
    "project_id",
    "product_id",
    "gcp_conn_id",
    "impersonation_chain",
)

更多信息

请参阅 Google Cloud Vision 产品创建文档

CloudVisionDeleteProductOperator

永久删除产品及其参考图像。

产品及其所有图像的元数据将立即被删除,但针对包含该产品的 ProductSets 的搜索查询在所有相关缓存刷新之前可能仍然有效。

可能的错误

  • 如果产品不存在,则返回 NOT_FOUND。

有关参数定义,请参阅 CloudVisionDeleteProductOperator

使用操作符

如果 product_id 由 API 生成,则可以从 XCOM 中提取它

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

product_delete = CloudVisionDeleteProductOperator(
    location=LOCATION,
    product_id="{{ task_instance.xcom_pull('product_create') }}",
    task_id="product_delete",
)

否则,可以明确指定

tests/system/providers/google/cloud/vision/example_vision_explicit.py[源代码]

product_delete_2 = CloudVisionDeleteProductOperator(
    location=LOCATION, product_id=GCP_VISION_PRODUCT_ID, task_id="product_delete_2"
)

模板化

template_fields: Sequence[str] = (
    "location",
    "project_id",
    "product_id",
    "gcp_conn_id",
    "impersonation_chain",
)

更多信息

请参阅 Google Cloud Vision 产品删除文档

CloudVisionGetProductOperator

获取与 Product 关联的信息。

可能的错误

  • 如果 Product 不存在,则返回 NOT_FOUND。

有关参数定义,请参阅 CloudVisionGetProductOperator

使用操作符

如果 product_id 由 API 生成,则可以从 XCOM 中提取它

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

product_get = CloudVisionGetProductOperator(
    location=LOCATION,
    product_id="{{ task_instance.xcom_pull('product_create') }}",
    task_id="product_get",
)

否则,可以明确指定

tests/system/providers/google/cloud/vision/example_vision_explicit.py[源代码]

product_get_2 = CloudVisionGetProductOperator(
    location=LOCATION, product_id=GCP_VISION_PRODUCT_ID, task_id="product_get_2"
)

模板化

template_fields: Sequence[str] = (
    "location",
    "project_id",
    "product_id",
    "gcp_conn_id",
    "impersonation_chain",
)

更多信息

请参阅 Google Cloud Vision 产品获取文档

CloudVisionProductSetCreateOperator

创建一个新的 ProductSet 资源。

有关参数定义,请参阅 CloudVisionCreateProductSetOperator

使用运算符

我们正在使用 Google 库中的 ProductSetRetry 对象

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

from google.cloud.vision_v1.types import ProductSet  # isort:skip

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

from google.api_core.retry import Retry  # isort:skip

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

product_set = ProductSet(display_name="My Product Set")

可以省略 product_set_id 参数(它将由 API 生成)

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

product_set_create = CloudVisionCreateProductSetOperator(
    location=LOCATION,
    product_set=product_set,
    retry=Retry(maximum=10.0),
    timeout=5,
    task_id="product_set_create",
)

或者可以明确指定

tests/system/providers/google/cloud/vision/example_vision_explicit.py[源代码]

product_set_create_2 = CloudVisionCreateProductSetOperator(
    product_set_id=GCP_VISION_PRODUCT_SET_ID,
    location=LOCATION,
    product_set=product_set,
    retry=Retry(maximum=10.0),
    timeout=5,
    task_id="product_set_create_2",
)

模板化

template_fields: Sequence[str] = (
    "location",
    "project_id",
    "product_set_id",
    "gcp_conn_id",
    "impersonation_chain",
)

CloudVisionDeleteProductSetOperator

永久删除 ProductSetProductsReferenceImages 中的 ProductSet 不会被删除。实际的图像文件不会从 Google Cloud Storage 中删除。

有关参数定义,请查看 CloudVisionDeleteProductSetOperator

使用运算符

如果 product_set_id 由 API 生成,则可以从 XCOM 中提取它

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

product_set_delete = CloudVisionDeleteProductSetOperator(
    location=LOCATION,
    product_set_id=product_set_create_output,
    task_id="product_set_delete",
)

否则,可以明确指定

tests/system/providers/google/cloud/vision/example_vision_explicit.py[源代码]

product_set_delete_2 = CloudVisionDeleteProductSetOperator(
    location=LOCATION, product_set_id=GCP_VISION_PRODUCT_SET_ID, task_id="product_set_delete_2"
)

模板化

template_fields: Sequence[str] = (
    "location",
    "project_id",
    "product_set_id",
    "gcp_conn_id",
    "impersonation_chain",
)

CloudVisionGetProductSetOperator

获取与 ProductSet 关联的信息。

有关参数定义,请查看 CloudVisionGetProductSetOperator

使用运算符

如果 product_set_id 由 API 生成,则可以从 XCOM 中提取它

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

product_set_get = CloudVisionGetProductSetOperator(
    location=LOCATION,
    product_set_id=product_set_create_output,
    task_id="product_set_get",
)

否则,可以明确指定

tests/system/providers/google/cloud/vision/example_vision_explicit.py[源代码]

product_set_get_2 = CloudVisionGetProductSetOperator(
    location=LOCATION, product_set_id=GCP_VISION_PRODUCT_SET_ID, task_id="product_set_get_2"
)

模板化

template_fields: Sequence[str] = (
    "location",
    "project_id",
    "product_set_id",
    "gcp_conn_id",
    "impersonation_chain",
)

CloudVisionUpdateProductSetOperator

ProductSet 资源进行更改。目前,只有 display_name 可以更新。

注意

要找到 ProductSet 资源,需要以 projects/PROJECT_ID/locations/LOC_ID/productSets/PRODUCT_SET_ID 的形式提供其 name

你可以直接将 name 作为 product_set 对象的属性提供。但是,你可以将其留空,并改为提供 locationproduct_set_id(以及可选的 project_id - 如果不存在,将使用连接默认值),而 name 将由操作符本身创建。

此机制的存在是为了方便你,让你可以将 project_id 留空,并让 Airflow 使用连接默认值 project_id

有关参数定义,请查看 CloudVisionUpdateProductSetOperator

使用操作符

我们正在使用 Google Cloud Vision 库中的 ProductSet 对象

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

from google.cloud.vision_v1.types import ProductSet  # isort:skip

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

product_set = ProductSet(display_name="My Product Set")

任务初始化

如果 product_set_id 由 API 生成,则可以从 XCOM 中提取它

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

product_set_update = CloudVisionUpdateProductSetOperator(
    location=LOCATION,
    product_set_id=product_set_create_output,
    product_set=ProductSet(display_name="My Product Set 2"),
    task_id="product_set_update",
)

否则,可以明确指定

tests/system/providers/google/cloud/vision/example_vision_explicit.py[源代码]

product_set_update_2 = CloudVisionUpdateProductSetOperator(
    location=LOCATION,
    product_set_id=GCP_VISION_PRODUCT_SET_ID,
    product_set=ProductSet(display_name="My Product Set 2"),
    task_id="product_set_update_2",
)

模板化

template_fields: Sequence[str] = (
    "location",
    "project_id",
    "product_set_id",
    "gcp_conn_id",
    "impersonation_chain",
)

CloudVisionUpdateProductOperator

Product 资源进行更改。目前,只有 display_namedescriptionlabels 字段可以更新。如果更新标签,则更改不会反映在查询中,直到下次索引时间。

注意

要找到 Product 资源,需要以 projects/PROJECT_ID/locations/LOC_ID/products/PRODUCT_ID 的形式提供其 name

你可以直接将 name 作为 product 对象的属性提供。但是,你可以将其留空,并提供 locationproduct_id(以及可选的 project_id - 如果不存在,将使用连接默认值),name 将由操作符本身创建。

此机制的存在是为了方便你,让你可以将 project_id 留空,并让 Airflow 使用连接默认值 project_id

可能的错误

  • 如果 Product 不存在,则返回 NOT_FOUND。

  • 如果 display_name 存在于 update_mask 中,但请求中不存在或长度超过 4096 个字符,则返回 INVALID_ARGUMENT。

  • 如果 description 存在于 update_mask 中,但长度超过 4096 个字符,则返回 INVALID_ARGUMENT。

  • 如果 product_category 存在于 update_mask 中,则返回 INVALID_ARGUMENT。

有关参数定义,请参阅 CloudVisionUpdateProductOperator

使用操作符

我们正在使用 Google Cloud Vision 库中的 Product 对象

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

from google.cloud.vision_v1.types import Product  # isort:skip

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

product = Product(display_name="My Product 1", product_category="toys")

如果 product_id 由 API 生成,则可以从 XCOM 中提取它

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

product_update = CloudVisionUpdateProductOperator(
    location=LOCATION,
    product_id="{{ task_instance.xcom_pull('product_create') }}",
    product=Product(display_name="My Product 2", description="My updated description"),
    task_id="product_update",
)

否则,可以明确指定

tests/system/providers/google/cloud/vision/example_vision_explicit.py[源代码]

product_update_2 = CloudVisionUpdateProductOperator(
    location=LOCATION,
    product_id=GCP_VISION_PRODUCT_ID,
    product=Product(display_name="My Product 2", description="My updated description"),
    task_id="product_update_2",
)

模板化

template_fields: Sequence[str] = (
    "location",
    "project_id",
    "product_id",
    "gcp_conn_id",
    "impersonation_chain",
)

更多信息

请参阅 Google Cloud Vision 产品更新文档

CloudVisionCreateReferenceImageOperator

创建一个新的 ReferenceImage 资源。

有关参数定义,请查看 CloudVisionCreateReferenceImageOperator

使用操作符

我们正在使用 Google 库中的 ReferenceImageRetry 对象

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

from google.cloud.vision_v1.types import ReferenceImage  # isort:skip

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

from google.api_core.retry import Retry  # isort:skip

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

reference_image = ReferenceImage(uri=VISION_IMAGE_URL)

可以省略 product_set_id 参数(它将由 API 生成)

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

reference_image_create = CloudVisionCreateReferenceImageOperator(
    location=LOCATION,
    reference_image=reference_image,
    product_id="{{ task_instance.xcom_pull('product_create') }}",
    reference_image_id=GCP_VISION_REFERENCE_IMAGE_ID,
    retry=Retry(maximum=10.0),
    timeout=5,
    task_id="reference_image_create",
)

或者可以明确指定

tests/system/providers/google/cloud/vision/example_vision_explicit.py[源代码]

reference_image_create_2 = CloudVisionCreateReferenceImageOperator(
    location=LOCATION,
    reference_image=reference_image,
    product_id=GCP_VISION_PRODUCT_ID,
    reference_image_id=GCP_VISION_REFERENCE_IMAGE_ID,
    retry=Retry(maximum=10.0),
    timeout=5,
    task_id="reference_image_create_2",
)

模板化

template_fields: Sequence[str] = (
    "location",
    "reference_image",
    "product_id",
    "reference_image_id",
    "project_id",
    "gcp_conn_id",
    "impersonation_chain",
)

CloudVisionDeleteReferenceImageOperator

删除 ReferenceImage 资源。

有关参数定义,请查看 CloudVisionDeleteReferenceImageOperator

使用操作符

我们正在使用 Google 库中的 ReferenceImageRetry 对象

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

from google.cloud.vision_v1.types import ReferenceImage  # isort:skip

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

from google.api_core.retry import Retry  # isort:skip

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

reference_image = ReferenceImage(uri=VISION_IMAGE_URL)

可以省略 product_set_id 参数(它将由 API 生成)

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

reference_image_delete = CloudVisionDeleteReferenceImageOperator(
    location=LOCATION,
    product_id="{{ task_instance.xcom_pull('product_create') }}",
    reference_image_id=GCP_VISION_REFERENCE_IMAGE_ID,
    retry=Retry(maximum=10.0),
    timeout=5,
    task_id="reference_image_delete",
)

或者可以明确指定

tests/system/providers/google/cloud/vision/example_vision_explicit.py[源代码]

reference_image_delete_2 = CloudVisionDeleteReferenceImageOperator(
    location=LOCATION,
    reference_image_id=GCP_VISION_REFERENCE_IMAGE_ID,
    product_id=GCP_VISION_PRODUCT_ID,
    retry=Retry(maximum=10.0),
    timeout=5,
    task_id="reference_image_delete_2",
)

模板化

template_fields: Sequence[str] = (
    "location",
    "reference_image",
    "product_id",
    "reference_image_id",
    "project_id",
    "gcp_conn_id",
    "impersonation_chain",
)

CloudVisionRemoveProductFromProductSetOperator

创建一个新的 ReferenceImage 资源。

有关参数定义,请查看 CloudVisionRemoveProductFromProductSetOperator

使用操作符

我们正在使用 ProductProductSetRetry 对象,这些对象来自 Google 库

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

from google.api_core.retry import Retry  # isort:skip

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

from google.cloud.vision_v1.types import ProductSet  # isort:skip

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

from google.cloud.vision_v1.types import Product  # isort:skip

如果 product_set_idproduct_id 是由 API 生成的,则可以从 XCOM 中提取

tests/system/providers/google/cloud/vision/example_vision_autogenerated.py[源代码]

remove_product_from_product_set = CloudVisionRemoveProductFromProductSetOperator(
    location=LOCATION,
    product_set_id=product_set_create_output,
    product_id="{{ task_instance.xcom_pull('product_create') }}",
    retry=Retry(maximum=10.0),
    timeout=5,
    task_id="remove_product_from_product_set",
)

否则,可以明确指定

tests/system/providers/google/cloud/vision/example_vision_explicit.py[源代码]

remove_product_from_product_set_2 = CloudVisionRemoveProductFromProductSetOperator(
    location=LOCATION,
    product_set_id=GCP_VISION_PRODUCT_SET_ID,
    product_id=GCP_VISION_PRODUCT_ID,
    retry=Retry(maximum=10.0),
    timeout=5,
    task_id="remove_product_from_product_set_2",
)

模板化

template_fields: Sequence[str] = (
    "location",
    "product_set_id",
    "product_id",
    "project_id",
    "gcp_conn_id",
    "impersonation_chain",
)

更多信息

请参阅 Google Cloud Vision 从产品集中移除产品文档

CloudVisionDetectTextOperator

针对图像运行文本检测。

有关参数定义,请参阅 CloudVisionDetectTextOperator

使用该运算符

我们正在使用 Google 库中的 Retry 对象

tests/system/providers/google/cloud/vision/example_vision_annotate_image.py[源代码]

from google.api_core.retry import Retry  # isort:skip

tests/system/providers/google/cloud/vision/example_vision_annotate_image.py[源代码]

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},
)

结果可从 XCOM 中提取

tests/system/providers/google/cloud/vision/example_vision_annotate_image.py[源代码]

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

模板化

template_fields: Sequence[str] = (
    "image",
    "max_results",
    "timeout",
    "gcp_conn_id",
    "impersonation_chain",
)

更多信息

请参阅 Google Cloud Vision 文本检测文档

CloudVisionTextDetectOperator

针对图像运行文档文本检测。

有关参数定义,请参阅 CloudVisionTextDetectOperator

使用该运算符

我们正在使用 Google 库中的 Retry 对象

tests/system/providers/google/cloud/vision/example_vision_annotate_image.py[源代码]

from google.api_core.retry import Retry  # isort:skip

tests/system/providers/google/cloud/vision/example_vision_annotate_image.py[源代码]

document_detect_text = CloudVisionTextDetectOperator(
    image=DETECT_IMAGE, retry=Retry(maximum=10.0), timeout=5, task_id="document_detect_text"
)

结果可从 XCOM 中提取

tests/system/providers/google/cloud/vision/example_vision_annotate_image.py[源代码]

document_detect_text_result = BashOperator(
    bash_command="echo {{ task_instance.xcom_pull('document_detect_text')['textAnnotations'][0] }}",
    task_id="document_detect_text_result",
)

模板化

template_fields: Sequence[str] = (
    "image",
    "max_results",
    "timeout",
    "gcp_conn_id",
    "impersonation_chain",
)  # Iterable[str]

更多信息

请参阅 Google Cloud Vision 文档文本检测文档

CloudVisionDetectImageLabelsOperator

针对图像运行图像标签检测。

有关参数定义,请参阅 CloudVisionDetectImageLabelsOperator

使用运算符

我们正在使用 Google 库中的 Retry 对象

tests/system/providers/google/cloud/vision/example_vision_annotate_image.py[源代码]

from google.api_core.retry import Retry  # isort:skip

tests/system/providers/google/cloud/vision/example_vision_annotate_image.py[源代码]

detect_labels = CloudVisionDetectImageLabelsOperator(
    image=DETECT_IMAGE, retry=Retry(maximum=10.0), timeout=5, task_id="detect_labels"
)

结果可从 XCOM 中提取

tests/system/providers/google/cloud/vision/example_vision_annotate_image.py[源代码]

detect_labels_result = BashOperator(
    bash_command="echo {{ task_instance.xcom_pull('detect_labels')['labelAnnotations'][0] }}",
    task_id="detect_labels_result",
)

模板化

template_fields: Sequence[str] = (
    "image",
    "max_results",
    "timeout",
    "gcp_conn_id",
    "impersonation_chain",
)

更多信息

请参阅 Google Cloud Vision 标签检测文档

CloudVisionDetectImageSafeSearchOperator

针对图像运行图像标签检测。

有关参数定义,请参阅 CloudVisionDetectImageSafeSearchOperator

使用运算符

我们正在使用 Google 库中的 Retry 对象

tests/system/providers/google/cloud/vision/example_vision_annotate_image.py[源代码]

from google.api_core.retry import Retry  # isort:skip

tests/system/providers/google/cloud/vision/example_vision_annotate_image.py[源代码]

detect_safe_search = CloudVisionDetectImageSafeSearchOperator(
    image=DETECT_IMAGE, retry=Retry(maximum=10.0), timeout=5, task_id="detect_safe_search"
)

结果可从 XCOM 中提取

tests/system/providers/google/cloud/vision/example_vision_annotate_image.py[源代码]

detect_safe_search_result = BashOperator(
    bash_command=f"echo {detect_safe_search.output}",
    task_id="detect_safe_search_result",
)

模板化

template_fields: Sequence[str] = (
    "image",
    "max_results",
    "timeout",
    "gcp_conn_id",
    "impersonation_chain",
)

参考

有关更多信息,请参阅

此条目有帮助吗?