Skip to content

[Vision] No Exceptions raised for non-existent gcs uri's  #3268

@ghost

Description

Hi,

Google Vision python package doesn't raise exceptions for non-existent gcs uri resources, instead returns an annotation object with empty list for texts. This makes it harder to tell if the resource doesn't exist or if the vision api failed to detect any text.

  1. OS type and version: macOS Sierra 10.12.3
  2. Python version: Python 2.7.10
  3. google-cloud-python version: Version: 0.23.0
  4. Code example - relevant code snippets
from google.cloud import storage, vision
from google.cloud.storage import Blob
from google.cloud.vision.image import Feature
from google.cloud.vision.image import FeatureTypes

features = [Feature(FeatureTypes.TEXT_DETECTION)]
vision_client = vision.Client()
image = vision_client.image(source_uri="<gcs uri>")
annotations = image.detect(features)
if annotations:
    annotation = annotations[0]
        if annotation.texts:
            text = annotation.texts[0].description
else:
    text = None

print(text)

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: visionIssues related to the Cloud Vision API.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions