Repository navigation
Add ReductoSageMaker, a client for an r-1 endpoint on SageMaker - #124
Merged
Merged
Conversation
- ReductoSageMaker and AsyncReductoSageMaker parse a PDF or an image through an r-1 endpoint on Amazon SageMaker, one page per request, and return a ParseResponse with one chunk per page. - Install with: pip install "reductoai[sagemaker]". HEIC images need the heic extra. import reducto loads no extra dependency. - The client renders each page to fit the endpoint's documented default image size (3,145,728 pixels), up to 300 DPI, and sends PNG (JPEG only when a page is over the 6 MB InvokeEndpoint limit). - Retries: 429 and 5xx other than 504, two times with jitter. - If any page fails, parse.run raises PageParseError. The error lists the failed pages, holds the pages that succeeded, and gives the page_range to retry the failed pages. - Only settings.page_range and settings.document_password are supported. Other options, and extract, split, edit, pipeline, and upload, raise UnsupportedOnProviderError: use the hosted Reducto API. - max_concurrency limits the pages in flight for each client. - The provider-neutral code is in reducto.lib._page_parse, so another provider needs only a transport and a small client. - Docs and an example are in examples/sagemaker/.
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
Original prompt from Alvin
|
Contributor
Author
|
Devin is currently unreachable - the session may have died. |
Contributor
thanks bro |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds
ReductoSageMakerandAsyncReductoSageMaker. They parse documents through a customer's own r-1 endpoint on Amazon SageMaker (the r-1 model package from AWS Marketplace). The client renders each page on the customer's machine and sends one page per request to the endpoint. Documents do not go to Reducto.What is in it
document_password), PNG, JPEG, TIFF (multi-frame), WebP, GIF, BMP. HEIC needs theheicextra.ParseResponseas the hosted API, with one chunk per page.settings.page_rangeandsettings.document_password. Every other option, andextract,split,edit,pipeline, andupload, raiseUnsupportedOnProviderError, which points to the hosted Reducto API.parse.runraisesPageParseErrorafter the other pages finish. The error lists the failed pages, holds the pages that succeeded, and gives thepage_rangeto retry them.max_concurrencylimits the pages in flight for each client. The async client has the same API.sagemakerandheicextras (also on thereductoalias package).import reductoloads none of them.Layout
reducto/lib/_page_parse/: private, provider-neutral code (documents, render, runner, response, a smallPageTransportprotocol, and a client base).reducto/lib/sagemaker/: the AWS parts only (session,invoke_endpointtransport, public classes).examples/sagemaker/: docs and an example. The root README does not change.Another provider needs only a transport and a small client on the same base.
Tests
./scripts/lint: ruff, pyright, and mypy pass../scripts/test: passes on pydantic v2 and v1. The new tests use botocore stubs and a local HTTP server, with no network.page_range, async cancel, shared-client concurrency, and the failed-page path.🤖 Generated with Claude Code
Link to Devin session: https://app.devin.ai/sessions/e9ecfef02d294823abcbc9008adefce8
Open in Devin Desktop: https://app.devin.ai/desktop/session/e9ecfef02d294823abcbc9008adefce8?variant=devin
Requested by: @alvin-r
Need help on this PR? Tag
@codesmith-botwith what you need.