Integrate Modal-hosted Marker and add env-based switch to offload layout extraction from local RQ#157
Integrate Modal-hosted Marker and add env-based switch to offload layout extraction from local RQ#157priyankeshh wants to merge 8 commits intodevelopfrom
Conversation
…r layout extraction
extralit-server/src/extralit_server/integrations/modal/marker_client.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Hey @priyankeshh, these code are handling nested dict for both function arguments and returns types, and it's better to define our own data types with pydantic.BaseModel or import a defined type from marker. We want to avoid using these nested dict parsing method since it's hard to maintain this code when there's no typehinting. Can you define the models at extralit-server/src/extralit_server/api/schemas/v1/document/layout.py?
You can see here for an example: https://github.com/Extralit/extralit/blob/e919e0453c808c89a4e7bfa331f1542fde5c2674/extralit-server/src/extralit_server/api/schemas/v1/document/metadata.py
There was a problem hiding this comment.
refactored the code to use Pydantic models for layout parsing and defined them in layout.py as suggested.
… OCR settings and client - Deleted the .env.example file as it is no longer needed. - Added new layout.py for PDF OCR settings using Pydantic. - Created marker_client.py to handle interactions with the Modal-hosted Marker service. - Updated ocr_jobs.py to import the new Modal client for document conversion.
|
Save later for determining modal external call due to complexity |
Summary
This PR adds a clean integration path to run Marker on Modal instead of locally via RQ. It introduces an environment-based switch (MARKER_RUN_MODE) and an HTTP client that forwards PDFs to a Modal-hosted Marker service. This lets us use proper GPU/compute and avoid HF Space resource limits. Layout correctness improvements can be iterated later; this PR focuses on wiring and compute offload.
Key changes
Configuration
How to test
Checklist