fix: process.py — use apply_ops() instead of phantom add_row/update_row/delete_row
Deploy contracts-flask / validate (push) Successful in 0s
Deploy contracts-flask / validate (push) Successful in 0s
This commit is contained in:
+15
-21
@@ -86,27 +86,21 @@ def run_pipeline(contract_id, order_ids, build_prompt_fn):
|
|||||||
"time_s": round(time.time() - t1, 1),
|
"time_s": round(time.time() - t1, 1),
|
||||||
}
|
}
|
||||||
|
|
||||||
# Apply ops to DB
|
# Apply ops to DB via apply_ops
|
||||||
applied_ops = []
|
try:
|
||||||
summary = {"added": 0, "updated": 0, "deleted": 0, "unresolved": 0}
|
summary = spec_events.apply_ops(
|
||||||
for op in ops:
|
contract_id, sid, s["document_id"], ops, prompt_id, result
|
||||||
action = op.get("action", "UNRESOLVED")
|
)
|
||||||
summary[action.lower()] = summary.get(action.lower(), 0) + 1
|
applied_ops = ops
|
||||||
try:
|
except Exception as e:
|
||||||
if action == "ADD":
|
summary = {"added": 0, "updated": 0, "deleted": 0, "unresolved": len(ops)}
|
||||||
nr = op.get("new_row", {})
|
applied_ops = []
|
||||||
spec_events.add_row(contract_id, sid, nr)
|
yield {
|
||||||
elif action == "UPDATE":
|
"type": "extract_error",
|
||||||
nr = op.get("new_row", {})
|
"supplement_id": sid,
|
||||||
nv = op.get("new_values", {})
|
"filename": filename,
|
||||||
target = op.get("target_hash", "")
|
"error": str(e),
|
||||||
spec_events.update_row(contract_id, sid, target, nr, nv)
|
}
|
||||||
elif action == "DELETE":
|
|
||||||
target = op.get("target_hash", "")
|
|
||||||
spec_events.delete_row(contract_id, sid, target)
|
|
||||||
applied_ops.append(op)
|
|
||||||
except Exception:
|
|
||||||
summary["unresolved"] = summary.get("unresolved", 0) + 1
|
|
||||||
|
|
||||||
# Arithmetic check
|
# Arithmetic check
|
||||||
check_arithmetic(contract_id)
|
check_arithmetic(contract_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user