feat: Update docker-compose configuration to use environment variables for sensitive data, enhance testing documentation with new LaTeX files for capacity planning, and refine README for clarity on compilation and testing processes.
This commit is contained in:
@@ -11,6 +11,7 @@ import logging
|
||||
import os
|
||||
from typing import Any
|
||||
|
||||
from sqlalchemy.orm.attributes import flag_modified
|
||||
from infrastructure.database import ExtractionRow, Task, session_scope, utcnow
|
||||
from infrastructure.serialization import flatten_extraction_result
|
||||
from api.desktop_ingest import (
|
||||
@@ -128,7 +129,8 @@ async def process_document(
|
||||
# Persistir resultado en BD
|
||||
def _persist() -> dict[str, Any]:
|
||||
with session_scope() as session:
|
||||
task = session.get(Task, task_id)
|
||||
# Lock evita lost-update en result.processed con N workers concurrentes.
|
||||
task = session.get(Task, task_id, with_for_update=True)
|
||||
if task is None:
|
||||
return {"skipped": True, "reason": "task_not_found"}
|
||||
|
||||
@@ -185,6 +187,7 @@ async def process_document(
|
||||
result["row_count"] = row_index
|
||||
result["processed"] = int(result.get("processed") or 0) + 1
|
||||
task.result = result
|
||||
flag_modified(task, "result")
|
||||
task.updated_at = utcnow()
|
||||
session.flush()
|
||||
mark_task_completed_if_done(session, task, batch_id)
|
||||
@@ -206,7 +209,7 @@ async def process_document(
|
||||
def _record_error() -> None:
|
||||
try:
|
||||
with session_scope() as session:
|
||||
task = session.get(Task, task_id)
|
||||
task = session.get(Task, task_id, with_for_update=True)
|
||||
if task is None:
|
||||
return
|
||||
result = dict(task.result or {})
|
||||
@@ -219,6 +222,7 @@ async def process_document(
|
||||
result["errors"] = errors
|
||||
result["processed"] = int(result.get("processed") or 0) + 1
|
||||
task.result = result
|
||||
flag_modified(task, "result")
|
||||
task.updated_at = utcnow()
|
||||
mark_task_completed_if_done(session, task, batch_id)
|
||||
except Exception as inner:
|
||||
|
||||
Reference in New Issue
Block a user