Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions surfsense_backend/app/tasks/document_processors/file_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,13 +886,40 @@ async def process_file_in_background(
)

# Use Docling service for document processing
import warnings

from app.services.docling_service import create_docling_service

# Create Docling service
docling_service = create_docling_service()

# Process the document
result = await docling_service.process_document(file_path, filename)
# Suppress pdfminer warnings that can cause processing to hang
# These warnings are harmless but can spam logs and potentially halt processing
# Suppress both Python warnings and logging warnings from pdfminer
pdfminer_logger = logging.getLogger("pdfminer")
original_level = pdfminer_logger.level

with warnings.catch_warnings():
warnings.filterwarnings(
"ignore", category=UserWarning, module="pdfminer"
)
warnings.filterwarnings(
"ignore",
message=".*Cannot set gray non-stroke color.*",
)
warnings.filterwarnings(
"ignore", message=".*invalid float value.*"
)

# Temporarily suppress pdfminer logging warnings
pdfminer_logger.setLevel(logging.ERROR)

try:
# Process the document
result = await docling_service.process_document(file_path, filename)
finally:
# Restore original logging level
pdfminer_logger.setLevel(original_level)

# Clean up the temp file
import os
Expand Down
11 changes: 11 additions & 0 deletions surfsense_backend/pyproject.toml
Copy link
Owner

Choose a reason for hiding this comment

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

@codeBunny2022 This is causing docker build to fail. Please revert these changes.

Err Log

10.68 Downloading av (38.7MiB)
12.60   × Failed to build `surf-new-backend @ file:///app`
12.60   ├─▶ The build backend returned an error
12.60   ╰─▶ Call to `setuptools.build_meta.build_editable` failed (exit status: 1)
12.60
12.60       [stdout]
12.60       running egg_info
12.60       creating surf_new_backend.egg-info
12.60       writing surf_new_backend.egg-info/PKG-INFO
12.60       writing dependency_links to
12.60       surf_new_backend.egg-info/dependency_links.txt
12.60       writing requirements to surf_new_backend.egg-info/requires.txt
12.60       writing top-level names to surf_new_backend.egg-info/top_level.txt
12.60       writing manifest file 'surf_new_backend.egg-info/SOURCES.txt'
12.60
12.60       [stderr]
12.60       /tmp/.tmp7SLZ0s/builds-v0/.tmprY3Eyn/lib/python3.12/site-packages/setuptools/config/expand.py:128:
12.60       SetuptoolsWarning: File '/app/README.md' cannot be found
12.60         for path in _filter_existing_files(_filepaths)
12.60       error: package directory 'app' does not exist
12.60
12.60       hint: This usually indicates a problem with the package or the build
12.60       environment.
------
failed to solve: process "/bin/sh -c pip install --no-cache-dir uv &&     uv pip install --system --no-cache-dir -e ." did not complete successfully: exit code: 1

Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
packages = ["app"]
include-package-data = false

[tool.setuptools.package-data]
app = ["**/*"]

[project]
name = "surf-new-backend"
version = "0.0.8"
Expand Down