Skip to content

feat: add benchmark test configs and doctypes#77

Draft
Abdeali099 wants to merge 105 commits intouse-docling-to-extract-datafrom
test-suite
Draft

feat: add benchmark test configs and doctypes#77
Abdeali099 wants to merge 105 commits intouse-docling-to-extract-datafrom
test-suite

Conversation

@Abdeali099
Copy link
Copy Markdown
Member

No description provided.

@vorasmit
Copy link
Copy Markdown
Member

@greptileai

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 16, 2026

Confidence Score: 2/5

Not safe to merge — the public parse endpoint is broken due to a keyword argument name mismatch that causes a TypeError on every background job.

A P0 defect in transaction_parser/transaction_parser/__init__.py (file_url vs file_urls in frappe.enqueue) will cause every invocation of the whitelisted parse() function to fail silently as a background job TypeError. The P1 notification object error further corrupts failure reporting. Both must be fixed before merging.

transaction_parser/transaction_parser/__init__.py requires the most urgent attention — both the file_urlfile_urls enqueue mismatch and the document_name: file (object vs. string) notification bug are located there.

Important Files Changed

Filename Overview
transaction_parser/transaction_parser/init.py Refactored to support multiple file URLs; introduces a critical parameter name mismatch (file_url vs file_urls) in frappe.enqueue that will break every background parse job, plus document_name: file (a Document object) in the duplicate-entry notification path.
transaction_parser/parser_benchmark/runner.py New benchmark runner implementing file-parsing, AI-parsing, cost calculation, and accuracy scoring steps; correctly uses tracemalloc for memory measurement and handles multi-file scenarios by mirroring the controller's merge flow.
transaction_parser/parser_benchmark/scorer.py New recursive scorer with proper normalization, weighted accuracy, and mismatch reporting; logic is sound and handles nested dicts, lists, and numeric precision correctly.
transaction_parser/transaction_parser/utils/response_merger.py New schema-driven ResponseMerger that fills missing primitive/object fields from subsequent file responses and deduplicates list items by match keys; implementation is clean and correct.
transaction_parser/transaction_parser/overrides/communication.py Refactored to match email accounts before checking party emails (fixing an ordering issue), adds process_one_document_per_communication mode, and filters unsupported extensions before enqueueing.
transaction_parser/transaction_parser/ai_integration/parser.py Exposes ai_response on AIParser for downstream use by the benchmark runner, adds company parameter to parse()/_build_messages(), and initializes ai_response = {} to avoid AttributeError before first call.
transaction_parser/transaction_parser/controllers/transaction.py Refactored to accept a list of files, introducing _parse_single_file, _parse_multiple_files, and get_match_keys; _attach_file updated to attach all files to the created document.

Comments Outside Diff (2)

  1. transaction_parser/transaction_parser/__init__.py, line 27 (link)

    Parameter name mismatch breaks all background jobs

    frappe.enqueue passes the argument as file_url=cstr(file_url) (line 27), but _parse was renamed to expect file_urls (line 39). When the background worker calls _parse(file_url=..., ...), it will raise TypeError: _parse() got an unexpected keyword argument 'file_url', making every invocation through the public parse() endpoint fail.

  2. transaction_parser/transaction_parser/__init__.py, line 109-112 (link)

    Error notification uses raw file variable (Document object, not string)

    In the duplicate-entry exception branch, file is now the last frappe.Document object assigned inside the loop (for file_name in file_names: file = frappe.get_doc(...)). The notification sets "document_name": file (a Document object, not a name string) and "subject": _("Duplicate entry found for {0}").format(file_urls) (which formats the raw list, e.g. ['url1', 'url2']). Before this refactor, file.name was used. This will produce a malformed notification.

Reviews (16): Last reviewed commit: "refactor: patch for process one document..." | Re-trigger Greptile

@Abdeali099
Copy link
Copy Markdown
Member Author

@greptileai

Abdeali099 and others added 18 commits March 30, 2026 18:12
…rty and update company context role hints in prompts
def generate(
self, file, ai_model: str | None = None, page_limit: int | None = None
self,
files,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark need change

if isinstance(files, str):
files = [files]

self.files = files
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to check

document_schema=schema,
document_data=content,
file_doc_name=self.file.name,
file_doc_name=file.name,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update benchmark

def get_match_keys(self) -> dict[str, list[str]]:
"""Return list field name -> key fields used to match items during merge."""
return {
"item_list": ["party_item_code", "quantity", "rate", "description"],
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karm1000

if we hard code party_item_code and someone change item schema like company_item_code then?

@Abdeali099
Copy link
Copy Markdown
Member Author

@greptileai

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.

3 participants