Repository navigation
feat(vision): upgrade google/cloud-vision to ^2.0 - #2344
Conversation
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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();
Upgrade our Vision samples to
google/cloud-visionv2:google/cloud-vision,google/cloud-storage, andgoogle/cloud-loggingto^2.0invision/andfunctions/imagemagick/BatchAnnotateImagesRequest