Update rule + flow hdfs new

This commit is contained in:
2026-09-23 11:36:34 +07:00
parent c79ea9f05f
commit 0e15bc89a8
10 changed files with 159 additions and 35 deletions

View File

@@ -26,6 +26,7 @@ class ProcessRequest(BaseModel):
file_path: str = Field(min_length=1, max_length=2048)
file_type: str = "application/pdf"
callback_url: str | None = None
dag_run_id: str | None = Field(default=None, min_length=1, max_length=250)
batch_id: str | None = Field(default=None, max_length=128)
@@ -71,7 +72,7 @@ def create_app(settings: Settings | None = None) -> FastAPI:
def public_job(job: dict) -> dict:
result = {key: job[key] for key in (
"id", "request_id", "batch_id", "status", "file_path", "filename", "source_kind",
"id", "request_id", "dag_run_id", "batch_id", "status", "file_path", "filename", "source_kind",
"total_pages", "completed_pages", "failed_pages", "error",
"callback_state", "callback_error", "created_at", "updated_at")}
result["result_available"] = job["result_json"] is not None
@@ -100,6 +101,7 @@ def create_app(settings: Settings | None = None) -> FastAPI:
file: UploadFile = File(...),
request_id: UUID | None = Form(default=None),
callback_url: str | None = Form(default=None),
dag_run_id: str | None = Form(default=None, min_length=1, max_length=250),
batch_id: str | None = Form(default=None, max_length=128)):
"""Nhận thẳng file PDF qua multipart/form-data và trả job_id ngay."""
filename = Path(file.filename or "").name
@@ -127,7 +129,7 @@ def create_app(settings: Settings | None = None) -> FastAPI:
try:
job, created = store.create_job(str(request_id or uuid4()), str(stored), callback_url,
batch_id, settings.max_queued_jobs, filename, "upload")
batch_id, settings.max_queued_jobs, filename, "upload", dag_run_id)
except ValueError as exc:
discard_upload(stored)
raise HTTPException(status_code=409, detail=str(exc)) from exc
@@ -146,7 +148,7 @@ def create_app(settings: Settings | None = None) -> FastAPI:
try:
job, created = store.create_job(str(request.request_id), request.file_path,
request.callback_url, request.batch_id,
settings.max_queued_jobs)
settings.max_queued_jobs, dag_run_id=request.dag_run_id)
except ValueError as exc:
raise HTTPException(status_code=409, detail=str(exc)) from exc
except OverflowError as exc: