Skip to content

Commit a8bbf52

Browse files
committed
chore: run linter checks
1 parent f38f6aa commit a8bbf52

File tree

4 files changed

+36
-23
lines changed

4 files changed

+36
-23
lines changed

lib/idp_common_pkg/idp_common/assessment/service.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -678,18 +678,20 @@ def process_document_section(self, document: Document, section_id: str) -> Docum
678678
logger.info(f"Time taken to read text content: {t2 - t1:.2f} seconds")
679679

680680
# Read page images with configurable dimensions
681-
image_config = self.config.get('image', {})
682-
target_width = image_config.get('target_width', 951) # Default fallback
683-
target_height = image_config.get('target_height', 1268)
684-
681+
image_config = self.config.get("image", {})
682+
target_width = image_config.get("target_width", 951) # Default fallback
683+
target_height = image_config.get("target_height", 1268)
684+
685685
page_images = []
686686
for page_id in sorted_page_ids:
687687
if page_id not in document.pages:
688688
continue
689689

690690
page = document.pages[page_id]
691691
image_uri = page.image_uri
692-
image_content = image.prepare_image(image_uri, target_width, target_height)
692+
image_content = image.prepare_image(
693+
image_uri, target_width, target_height
694+
)
693695
page_images.append(image_content)
694696

695697
t3 = time.time()

lib/idp_common_pkg/idp_common/classification/service.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -608,11 +608,13 @@ def classify_page_bedrock(
608608
# Load image content from URI with configurable dimensions
609609
if image_uri:
610610
try:
611-
image_config = self.config.get('image', {})
612-
target_width = image_config.get('target_width', 951) # Default fallback
613-
target_height = image_config.get('target_height', 1268)
614-
615-
image_content = image.prepare_image(image_uri, target_width, target_height)
611+
image_config = self.config.get("image", {})
612+
target_width = image_config.get("target_width", 951) # Default fallback
613+
target_height = image_config.get("target_height", 1268)
614+
615+
image_content = image.prepare_image(
616+
image_uri, target_width, target_height
617+
)
616618
except Exception as e:
617619
logger.warning(f"Failed to load image content from {image_uri}: {e}")
618620
# Continue without image content

lib/idp_common_pkg/idp_common/extraction/service.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -618,18 +618,20 @@ def process_document_section(self, document: Document, section_id: str) -> Docum
618618
logger.info(f"Time taken to read text content: {t1 - t0:.2f} seconds")
619619

620620
# Read page images with configurable dimensions
621-
image_config = self.config.get('image', {})
622-
target_width = image_config.get('target_width', 951) # Default fallback
623-
target_height = image_config.get('target_height', 1268)
624-
621+
image_config = self.config.get("image", {})
622+
target_width = image_config.get("target_width", 951) # Default fallback
623+
target_height = image_config.get("target_height", 1268)
624+
625625
page_images = []
626626
for page_id in sorted_page_ids:
627627
if page_id not in document.pages:
628628
continue
629629

630630
page = document.pages[page_id]
631631
image_uri = page.image_uri
632-
image_content = image.prepare_image(image_uri, target_width, target_height)
632+
image_content = image.prepare_image(
633+
image_uri, target_width, target_height
634+
)
633635
page_images.append(image_content)
634636

635637
t2 = time.time()

lib/idp_common_pkg/idp_common/ocr/service.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,15 @@ def __init__(
5656
self.max_workers = max_workers
5757
self.dpi = dpi
5858
self.resize_config = resize_config
59-
59+
6060
# Log DPI setting for debugging
6161
logger.info(f"OCR Service initialized with DPI: {self.dpi}")
62-
62+
6363
# Log resize config if provided
6464
if self.resize_config:
65-
logger.info(f"OCR Service initialized with resize config: {self.resize_config}")
65+
logger.info(
66+
f"OCR Service initialized with resize config: {self.resize_config}"
67+
)
6668

6769
# Define valid Textract feature types
6870
VALID_FEATURES = ["TABLES", "FORMS", "SIGNATURES", "LAYOUT"]
@@ -291,13 +293,18 @@ def _process_single_page(
291293
# Resize image for OCR processing if configured
292294
ocr_img_bytes = img_bytes # Default to original image
293295
if self.resize_config:
294-
target_width = self.resize_config.get('target_width')
295-
target_height = self.resize_config.get('target_height')
296-
296+
target_width = self.resize_config.get("target_width")
297+
target_height = self.resize_config.get("target_height")
298+
297299
if target_width and target_height:
298300
from idp_common import image
299-
ocr_img_bytes = image.resize_image(img_bytes, target_width, target_height)
300-
logger.debug(f"Resized image for OCR processing (page {page_id}) to {target_width}x{target_height}")
301+
302+
ocr_img_bytes = image.resize_image(
303+
img_bytes, target_width, target_height
304+
)
305+
logger.debug(
306+
f"Resized image for OCR processing (page {page_id}) to {target_width}x{target_height}"
307+
)
301308

302309
# Process with OCR using potentially resized image
303310
if isinstance(self.enhanced_features, list) and self.enhanced_features:

0 commit comments

Comments
 (0)