Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose async (promise-returning) methods in ImageAnnotatorClient #7747

Open
mikethea1 opened this issue Oct 15, 2024 · 0 comments
Open

Expose async (promise-returning) methods in ImageAnnotatorClient #7747

mikethea1 opened this issue Oct 15, 2024 · 0 comments

Comments

@mikethea1
Copy link

Thanks for stopping by to let us know something could be better!

Is your feature request related to a problem? Please describe.
I'm using the ImageAnnotatorClient to OCR some pages from a document. Because the API only accepts 5 pages at a time (and sometimes fails with a full 5, doing this serially takes many seconds to finish; sometimes the request times out just processing a modest number of pages.

Describe the solution you'd like

Under the hood, the annotator client is actually calling ->wait() on an async promise before returning. I'd like for an API like batchAnnotateImagesAsync() which just returned the promise directly. This would allow me to process in parallel:

$promises = array_map(fn($r) => $imageAnnotator->batchAnnotateImagesAsync($r), $requests);
foreach ($promises as $promise) {
    $result = $promise->wait();
    // do something with $result
}

Describe alternatives you've considered
The current client DOES have a asyncBatchAnnotateImages() function, but this synchronously sets up an offline operation. I'm still doing online operations; I'd just like to parallelize for speed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant