airflow.gcp.hooks.vision
¶
This module contains a Google Cloud Vision Hook.
Module Contents¶
-
airflow.gcp.hooks.vision.
ERR_DIFF_NAMES
= 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.[source]¶
-
airflow.gcp.hooks.vision.
ERR_UNABLE_TO_CREATE
= Unable to determine the {label} name. Please either set the name directly in the {label} object or provide the `location` and `{id_label}` parameters.[source]¶
-
class
airflow.gcp.hooks.vision.
NameDeterminer
(label:str, id_label:str, get_path:Callable[[str, str, str], str])[source]¶ Helper class to determine entity name.
-
get_entity_with_name
(self, entity:Any, entity_id:Optional[str], location:Optional[str], project_id:str)[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.
-
-
class
airflow.gcp.hooks.vision.
CloudVisionHook
(gcp_conn_id:str='google_cloud_default', delegate_to:str=None)[source]¶ Bases:
airflow.contrib.hooks.gcp_api_base_hook.GoogleCloudBaseHook
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.
-
get_conn
(self)[source]¶ Retrieves connection to Cloud Vision.
- Returns
Google Cloud Vision client object.
- Return type
-
annotator_client
(self)[source]¶ Creates ImageAnnotatorClient.
- Returns
Google Image Annotator client object.
- Return type
-
create_product_set
(self, location:str, product_set:Union[dict, ProductSet], project_id:str=None, product_set_id:str=None, retry:Retry=None, timeout:float=None, metadata:Sequence[Tuple[str, str]]=None)[source]¶ For the documentation see:
CloudVisionProductSetCreateOperator
-
get_product_set
(self, location:str, product_set_id:str, project_id:str=None, retry:Retry=None, timeout:float=None, metadata:Sequence[Tuple[str, str]]=None)[source]¶ For the documentation see:
CloudVisionProductSetGetOperator
-
update_product_set
(self, product_set:Union[dict, ProductSet], location:str=None, product_set_id:str=None, update_mask:Union[dict, FieldMask]=None, project_id:str=None, retry:Retry=None, timeout:float=None, metadata:Sequence[Tuple[str, str]]=None)[source]¶ For the documentation see:
CloudVisionProductSetUpdateOperator
-
delete_product_set
(self, location:str, product_set_id:str, project_id:str=None, retry:Retry=None, timeout:float=None, metadata:Sequence[Tuple[str, str]]=None)[source]¶ For the documentation see:
CloudVisionProductSetDeleteOperator
-
create_product
(self, location:str, product:Union[dict, Product], project_id:str=None, product_id=None, retry:Retry=None, timeout:float=None, metadata:Sequence[Tuple[str, str]]=None)[source]¶ For the documentation see:
CloudVisionProductCreateOperator
-
get_product
(self, location:str, product_id:str, project_id:str=None, retry:Retry=None, timeout:float=None, metadata:Sequence[Tuple[str, str]]=None)[source]¶ For the documentation see:
CloudVisionProductGetOperator
-
update_product
(self, product:Union[dict, Product], location:str=None, product_id:str=None, update_mask:Dict[str, FieldMask]=None, project_id:str=None, retry:Retry=None, timeout:float=None, metadata:Sequence[Tuple[str, str]]=None)[source]¶ For the documentation see:
CloudVisionProductUpdateOperator
-
delete_product
(self, location:str, product_id:str, project_id:str=None, retry:Retry=None, timeout:float=None, metadata:Sequence[Tuple[str, str]]=None)[source]¶ For the documentation see:
CloudVisionProductDeleteOperator
-
create_reference_image
(self, location:str, product_id:str, reference_image:Union[Dict, ReferenceImage], reference_image_id:str=None, project_id:str=None, retry:Retry=None, timeout:float=None, metadata:Sequence[Tuple[str, str]]=None)[source]¶ For the documentation see:
CloudVisionReferenceImageCreateOperator
-
delete_reference_image
(self, location:str, product_id:str, reference_image_id:str, project_id:str=None, retry:Retry=None, timeout:float=None, metadata:Sequence[Tuple[str, str]]=None)[source]¶ For the documentation see:
CloudVisionReferenceImageCreateOperator
-
add_product_to_product_set
(self, product_set_id:str, product_id:str, location:str=None, project_id:str=None, retry:Retry=None, timeout:float=None, metadata:Sequence[Tuple[str, str]]=None)[source]¶ For the documentation see:
CloudVisionAddProductToProductSetOperator
-
remove_product_from_product_set
(self, product_set_id:str, product_id:str, location:str=None, project_id:str=None, retry:Retry=None, timeout:float=None, metadata:Sequence[Tuple[str, str]]=None)[source]¶ For the documentation see:
CloudVisionRemoveProductFromProductSetOperator
# pylint: disable=line-too-long # noqa
-
annotate_image
(self, request:Union[dict, AnnotateImageRequest], retry:Retry=None, timeout:float=None)[source]¶ For the documentation see:
CloudVisionAnnotateImage
-
batch_annotate_images
(self, requests:Union[List[dict], List[AnnotateImageRequest]], retry:Retry=None, timeout:float=None)[source]¶ For the documentation see:
CloudVisionAnnotateImage
-
text_detection
(self, image:Union[Dict, Image], max_results:int=None, retry:Retry=None, timeout:float=None, additional_properties:Dict=None)[source]¶ For the documentation see:
CloudVisionDetectTextOperator
-
document_text_detection
(self, image:Union[Dict, Image], max_results:int=None, retry:Retry=None, timeout:float=None, additional_properties:Dict=None)[source]¶ For the documentation see:
CloudVisionDetectDocumentTextOperator
-
label_detection
(self, image:Union[Dict, Image], max_results:int=None, retry:Retry=None, timeout:float=None, additional_properties:Dict=None)[source]¶ For the documentation see:
CloudVisionDetectImageLabelsOperator
-