File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66"""
77import json
88import sys
9+ import warnings
10+ import logging
911from pathlib import Path
1012
13+ # Suppress all warnings and logging from Docling and its dependencies
14+ warnings .filterwarnings ("ignore" )
15+ logging .disable (logging .CRITICAL ) # Disable all logging
16+
17+ import os
18+ import contextlib
19+
1120from docling .document_converter import DocumentConverter
1221from docling .datamodel .base_models import InputFormat
1322
1423
24+ @contextlib .contextmanager
25+ def suppress_stderr ():
26+ """Temporarily suppress stderr to hide Docling's verbose output."""
27+ with open (os .devnull , 'w' ) as devnull :
28+ old_stderr = sys .stderr
29+ sys .stderr = devnull
30+ try :
31+ yield
32+ finally :
33+ sys .stderr = old_stderr
34+
35+
1536def strip_image_data (extraction : dict ) -> dict :
1637 """Remove base64 image data from extraction to reduce size."""
1738 if "pictures" in extraction :
@@ -64,7 +85,9 @@ def main():
6485 print (json .dumps ({"success" : False , "error" : f"File not found: { file_path } " }), flush = True )
6586 continue
6687
67- result = extract (converter , file_path )
88+ # Suppress stderr during extraction to hide Docling's verbose output
89+ with suppress_stderr ():
90+ result = extract (converter , file_path )
6891 print (json .dumps ({"success" : True , ** result }), flush = True )
6992
7093 except Exception as e :
You can’t perform that action at this time.
0 commit comments