airflow.providers.google.cloud.hooks.vision

This module contains a Google Cloud Vision Hook.

Module Contents

Classes

NameDeterminer

Helper class to determine entity name.

CloudVisionHook

Hook for Google Cloud Vision APIs.

Attributes

ERR_DIFF_NAMES

ERR_UNABLE_TO_CREATE

airflow.providers.google.cloud.hooks.vision.ERR_DIFF_NAMES = Multiline-String[source]
Show Value
1The {label} name provided in the object ({explicit_name}) is different
2    than the name created from the input parameters ({constructed_name}). Please either:
3    1) Remove the {label} name,
4    2) Remove the location and {id_label} parameters,
5    3) Unify the {label} name and input parameters.
airflow.providers.google.cloud.hooks.vision.ERR_UNABLE_TO_CREATE = Multiline-String[source]
Show Value
1Unable to determine the {label} name. Please either set the name directly
2    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]

Helper class to determine entity name.

get_entity_with_name(self, entity, entity_id, location, project_id)[source]

Check if entity has the name attribute set: * If so, no action is taken.

  • If not, and the name can be constructed from other parameters provided, it is created and filled in

    the entity.

  • If both the entity's 'name' attribute is set and the name can be constructed from other parameters

    provided:

    • If they are the same - no action is taken

    • if they are different - an exception is thrown.

Parameters
  • entity (Any) -- Entity

  • entity_id (Optional[str]) -- Entity id

  • location (Optional[str]) -- Location

  • project_id (str) -- The id of Google Cloud Vision project.

Returns

The same entity or entity with new name

Return type

str

Raises

AirflowException

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

Bases: airflow.providers.google.common.hooks.base_google.GoogleBaseHook

Hook for Google Cloud Vision APIs.

All the methods in the hook where project_id is used must be called with keyword arguments rather than positional.

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

Retrieves connection to Cloud Vision.

Returns

Google Cloud Vision client object.

Return type

google.cloud.vision_v1.ProductSearchClient

annotator_client(self)[source]

Creates ImageAnnotatorClient.

Returns

Google Image Annotator client object.

Return type

google.cloud.vision_v1.ImageAnnotatorClient

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

For the documentation see: CloudVisionCreateProductSetOperator

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

For the documentation see: CloudVisionGetProductSetOperator

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

For the documentation see: CloudVisionUpdateProductSetOperator

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

For the documentation see: CloudVisionDeleteProductSetOperator

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

For the documentation see: CloudVisionCreateProductOperator

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

For the documentation see: CloudVisionGetProductOperator

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

For the documentation see: CloudVisionUpdateProductOperator

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

For the documentation see: CloudVisionDeleteProductOperator

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

For the documentation see: CloudVisionCreateReferenceImageOperator

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

For the documentation see: CloudVisionDeleteReferenceImageOperator

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

For the documentation see: CloudVisionAddProductToProductSetOperator

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

For the documentation see: CloudVisionRemoveProductFromProductSetOperator

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

For the documentation see: CloudVisionImageAnnotateOperator

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

For the documentation see: CloudVisionImageAnnotateOperator

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

For the documentation see: CloudVisionDetectTextOperator

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

For the documentation see: CloudVisionTextDetectOperator

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

For the documentation see: CloudVisionDetectImageLabelsOperator

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

For the documentation see: CloudVisionDetectImageSafeSearchOperator

Was this entry helpful?