airflow.providers.google.cloud.hooks.vision

此模块包含一个 Google Cloud Vision Hook。

属性

ERR_DIFF_NAMES

ERR_UNABLE_TO_CREATE

NameDeterminer

用于确定实体名称的辅助类。

CloudVisionHook

用于 Google Cloud Vision API 的 Hook。

模块内容

airflow.providers.google.cloud.hooks.vision.ERR_DIFF_NAMES = Multiline-String[source]
显示值
"""The {label} name provided in the object ({explicit_name}) is different
    than the name created from the input parameters ({constructed_name}). Please either:
    1) Remove the {label} name,
    2) Remove the location and {id_label} parameters,
    3) Unify the {label} name and input parameters.
    """
airflow.providers.google.cloud.hooks.vision.ERR_UNABLE_TO_CREATE = Multiline-String[source]
显示值
"""Unable to determine the {label} name. Please either set the name directly
    in the {label} object or provide the `location` and `{id_label}` parameters.
    """
class airflow.providers.google.cloud.hooks.vision.NameDeterminer(label, id_label, get_path)[source]

用于确定实体名称的辅助类。

label[source]
id_label[source]
get_path[source]
get_entity_with_name(entity, entity_id, location, project_id)[source]

检查实体是否设置了 name 属性。

  • 如果设置了,则不采取任何行动。

  • 如果未设置,但名称可以由提供的其他参数构建,则创建并填充到

    实体中。

  • 如果实体的“name”属性已设置且名称可以由提供的其他参数

    构建:* 如果它们相同 - 不采取任何行动 * 如果它们不同 - 抛出异常。

参数:
  • entity (Any) – 实体

  • entity_id (str | None) – 实体 ID

  • location (str | None) – 位置

  • project_id (str) – Google Cloud Vision 项目的 ID。

返回:

相同的实体或具有新名称的实体

抛出异常:

AirflowException

返回类型:

Any

class airflow.providers.google.cloud.hooks.vision.CloudVisionHook(gcp_conn_id='google_cloud_default', impersonation_chain=None, **kwargs)[source]

继承自: airflow.providers.google.common.hooks.base_google.GoogleBaseHook

用于 Google Cloud Vision API 的 Hook。

Hook 中所有使用 project_id 的方法必须使用关键字参数调用,而不是位置参数。

product_name_determiner[source]
product_set_name_determiner[source]
get_conn()[source]

获取 Cloud Vision 的连接。

返回:

Google Cloud Vision 客户端对象。

返回类型:

google.cloud.vision_v1.ProductSearchClient

property annotator_client: google.cloud.vision_v1.ImageAnnotatorClient[source]

创建 ImageAnnotatorClient。

返回:

Google Image Annotator 客户端对象。

返回类型:

google.cloud.vision_v1.ImageAnnotatorClient

create_product_set(location, product_set, project_id=PROVIDE_PROJECT_ID, product_set_id=None, retry=DEFAULT, timeout=None, metadata=())[source]

创建产品集。

有关文档,请参阅: CloudVisionCreateProductSetOperator

get_product_set(location, product_set_id, project_id=PROVIDE_PROJECT_ID, retry=DEFAULT, timeout=None, metadata=())[source]

获取产品集。

有关文档,请参阅: CloudVisionGetProductSetOperator

update_product_set(product_set, project_id=PROVIDE_PROJECT_ID, location=None, product_set_id=None, update_mask=None, retry=DEFAULT, timeout=None, metadata=())[source]

更新产品集。

有关文档,请参阅: CloudVisionUpdateProductSetOperator

delete_product_set(location, product_set_id, project_id=PROVIDE_PROJECT_ID, retry=DEFAULT, timeout=None, metadata=())[source]

删除产品集。

有关文档,请参阅: CloudVisionDeleteProductSetOperator

create_product(location, product, project_id=PROVIDE_PROJECT_ID, product_id=None, retry=DEFAULT, timeout=None, metadata=())[source]

创建产品。

有关文档,请参阅: CloudVisionCreateProductOperator

get_product(location, product_id, project_id=PROVIDE_PROJECT_ID, retry=DEFAULT, timeout=None, metadata=())[source]

获取产品。

有关文档,请参阅: CloudVisionGetProductOperator

update_product(product, project_id=PROVIDE_PROJECT_ID, location=None, product_id=None, update_mask=None, retry=DEFAULT, timeout=None, metadata=())[source]

更新产品。

有关文档,请参阅: CloudVisionUpdateProductOperator

delete_product(location, product_id, project_id=PROVIDE_PROJECT_ID, retry=DEFAULT, timeout=None, metadata=())[source]

删除产品。

有关文档,请参阅: CloudVisionDeleteProductOperator

create_reference_image(location, product_id, reference_image, project_id, reference_image_id=None, retry=DEFAULT, timeout=None, metadata=())[source]

创建参考图片。

有关文档,请参阅: CloudVisionCreateReferenceImageOperator

delete_reference_image(location, product_id, reference_image_id, project_id, retry=DEFAULT, timeout=None, metadata=())[source]

删除参考图片。

有关文档,请参阅: CloudVisionDeleteReferenceImageOperator

add_product_to_product_set(product_set_id, product_id, project_id, location, retry=DEFAULT, timeout=None, metadata=())[source]

将产品添加到产品集。

有关文档,请参阅: CloudVisionAddProductToProductSetOperator

remove_product_from_product_set(product_set_id, product_id, project_id, location, retry=DEFAULT, timeout=None, metadata=())[source]

从产品集中移除产品。

有关文档,请参阅: CloudVisionRemoveProductFromProductSetOperator

annotate_image(request, retry=DEFAULT, timeout=None)[source]

对图片进行标注。

有关文档,请参阅: CloudVisionImageAnnotateOperator

batch_annotate_images(requests, retry=DEFAULT, timeout=None)[source]

批量标注图片。

有关文档,请参阅: CloudVisionImageAnnotateOperator

text_detection(image, max_results=None, retry=DEFAULT, timeout=None, additional_properties=None)[source]

文本检测。

有关文档,请参阅: CloudVisionDetectTextOperator

document_text_detection(image, max_results=None, retry=DEFAULT, timeout=None, additional_properties=None)[source]

文档文本检测。

有关文档,请参阅: CloudVisionTextDetectOperator

label_detection(image, max_results=None, retry=DEFAULT, timeout=None, additional_properties=None)[source]

标签检测。

有关文档,请参阅: CloudVisionDetectImageLabelsOperator

safe_search_detection(image, max_results=None, retry=DEFAULT, timeout=None, additional_properties=None)[source]

安全搜索检测。

更多文档请参阅:CloudVisionDetectImageSafeSearchOperator

此条目是否有帮助?