Skip to content

feat: add reusable document parsers and parse jobs - #151

Open
francisrafal wants to merge 7 commits into
mainfrom
francisrafal/parser-jobs
Open

feat: add reusable document parsers and parse jobs#151
francisrafal wants to merge 7 commits into
mainfrom
francisrafal/parser-jobs

Conversation

@francisrafal

Copy link
Copy Markdown
Contributor

Summary

  • add reusable parser CRUD at /v1/parsers, durable asynchronous jobs at /v1/parse-jobs, and the prebuilt document-to-markdown parser
  • make /v1/extraction-jobs the canonical extraction resource while retaining /v1/jobs as a deprecated v0.3 compatibility alias scheduled for removal in v0.4
  • return canonical per-page Markdown plus derived content and page_count, with snapshotted parser configuration and provider/model/adapter execution metadata
  • support parsing end to end across persistence, fair worker scheduling, OpenAPI, CLI, Web UI, telemetry, generated references, and user documentation

Compatibility and migration

  • the database migration preserves existing extraction jobs while renaming the generic jobs table to extraction_jobs
  • a second migration adds parser and parse-job persistence
  • existing /v1/jobs clients continue to work during v0.3 and see the same extraction-job representation
  • parsing has a separate PARSEHAWK_PARSING_MAX_TOKENS budget, defaulting to 8192

E2E strategy

The E2E suite covers the new parser and parse-job API surface while keeping model-bound work deliberately small: exactly one real extraction job and one real parse job. Parser CRUD, aliases, filters, file types, terminal cancellation, deletion, and validation are covered without additional LLM requests.

Verification

  • parsehawk restart on Linux x86_64 with an NVIDIA L4 and the bundled NuExtract runtime
  • just check — 411 Python tests, 100% core coverage, OpenAPI and generated references in sync, docs typecheck/build/link validation, 36 Web tests, and Web production build
  • just e2e — 17 passed, including the real parse-job execution
  • local dependency-license scanning was skipped because osv-scanner is unavailable; the bundled-image manifest check passed and CI runs the dependency scan

macOS Apple Silicon runtime verification was not available in this environment.

Closes #20

@francisrafal

Copy link
Copy Markdown
Contributor Author

Verified locally on macOS 26.5.2 (Apple Silicon, arm64) at commit d787404f4fe9d05ad54403fdd5d515435df7ca9a.

  • UV_FROZEN=1 uv run parsehawk restart completed successfully. The database migrations applied, and the API, worker, Web UI, Phoenix, and vLLM Metal runtime all started successfully.
  • UV_FROZEN=1 just e2e passed: 17 passed in 27.87s.

The PR works locally on macOS for the full repository E2E path.

Separate extraction and parsing into explicit resources so each workflow can evolve without overloading the legacy jobs contract. Add parser CRUD, durable parse jobs, canonical page-based Markdown results, fair worker scheduling, CLI and Web support, data-preserving migrations, and generated public documentation while retaining /v1/jobs as a deprecated compatibility alias through v0.3.
Exercise parser CRUD and both canonical job resources over the real API and worker while keeping inference costs bounded. The suite now uses exactly one extraction job and one parse job for model-bound coverage and validates the remaining routes without extra LLM requests.
Use a sanitized Markdown pipeline so document and per-page previews render tables, links, formatting, and safe embedded HTML while the raw view remains unchanged. Style the rendered document for readable review and represent unavailable generated image assets without broken images.
Lower the default per-page output budget below the smallest bundled context and pass the setting through Docker Compose so local parsing remains valid and configurable. Regenerate the public references and align the Web settings copy with the new safe default.
Derive canonical JPEG and PNG media types from accepted file extensions so uploads with missing or generic browser metadata still reach vision models as image inputs.
Scope asynchronous job refreshes to the latest parser, poll through parser lists so completed deletions disappear, and remove accepted deletions optimistically. Derive Markdown download names from each job's source file and cover the race and deletion paths in the Web suite.
Move the byte-for-byte alias comparison after polling so worker state transitions cannot produce two valid but different snapshots.
@francisrafal
francisrafal force-pushed the francisrafal/parser-jobs branch from d787404 to c917ac9 Compare August 9, 2026 18:43
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

Successfully merging this pull request may close these issues.

Add reusable document-to-Markdown parsers and asynchronous parse jobs

1 participant