Nhận PDF upload trực tiếp qua POST /parse

API trước đây chỉ nhận đường dẫn HDFS từ Airflow. Thêm endpoint
multipart/form-data nhận thẳng file PDF, vẫn chạy bất đồng bộ: trả 202 kèm
job_id và result_url, worker xử lý nền, client lấy dla-document-bundle ở
GET /jobs/{job_id}/result hoặc qua callback.

- File upload ghi xuống IDP_DATA_DIR/uploads theo sha256 nội dung nên gửi lại
  cùng request_id trả cùng job_id; file được xoá khi không còn job nào dùng.
- Thêm cột filename/source_kind để bundle giữ đúng tên file gốc thay vì tên
  đã băm.
- IDP_RUN_WORKER=1 chạy worker trong process API cho triển khai một host.
- IDP_OCR_BACKEND=pdf_text dựng bundle từ text layer của PDF để chạy thử toàn
  bộ luồng khi chưa serve được model.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-21 14:51:19 +00:00
parent 939e3bc8c1
commit c79ea9f05f
11 changed files with 343 additions and 31 deletions

View File

@@ -1,10 +1,11 @@
[project]
name = "idp-parsing-service"
version = "0.1.0"
version = "0.2.0"
requires-python = ">=3.11"
dependencies = [
"fastapi>=0.115,<1",
"uvicorn>=0.30,<1",
"python-multipart>=0.0.9,<1",
"pymupdf>=1.24,<2",
"pycryptodome>=3.20,<4",
]