Skip to content

feat(vision): upgrade google/cloud-vision to ^2.0 - #2344

Merged
bshaffer merged 2 commits into
mainfrom
vision/upgrade-v2
Nov 6, 2026
Merged

bshaffer merged 2 commits into
mainfrom
vision/upgrade-v2

Conversation

@bshaffer

@bshaffer bshaffer commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Upgrade our Vision samples to google/cloud-vision v2:

  • Update google/cloud-vision, google/cloud-storage, and google/cloud-logging to ^2.0 in vision/ and functions/imagemagick/
  • Migrate Vision samples from the removed V1 helper methods to BatchAnnotateImagesRequest

@bshaffer
bshaffer requested review from a team as code owners November 6, 2026 17:28
@product-auto-label product-auto-label Bot added api: vision Issues related to the Cloud Vision API. samples Issues that are directly related to samples. labels Nov 6, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request upgrades the Google Cloud Vision and Storage dependencies to version 2.0 across the ImageMagick Cloud Function and various Vision samples. It refactors the code to replace deprecated direct detection methods with the new batch annotation pattern using BatchAnnotateImagesRequest and AnnotateImageRequest. Feedback on the changes suggests explicitly closing the ImageAnnotatorClient instance in the Cloud Function to prevent potential connection leaks.

->setFeatures([$feature]);
$batchRequest = (new BatchAnnotateImagesRequest())
->setRequests([$request]);
$response = $annotator->batchAnnotateImages($batchRequest)->getResponses()[0];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The ImageAnnotatorClient instance should be closed to free up resources and avoid potential connection leaks, especially since this is a Cloud Function where the container and process can be reused across multiple invocations. Other Vision samples in this repository explicitly call close() on the client.

        $response = $annotator->batchAnnotateImages($batchRequest)->getResponses()[0];
        $annotator->close();

@bshaffer
bshaffer merged commit b26947a into main Nov 6, 2026
12 checks passed
@bshaffer
bshaffer deleted the vision/upgrade-v2 branch November 6, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: vision Issues related to the Cloud Vision API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant