[Sub] OCR 데이터 모델 + 예외 처리 구현#52
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
📝 Walkthrough워크스루Pydantic 기반 OCR 요청/응답 모델 4개와 OCR 전용 예외 계층 8개를 추가하고, 패키지 초기화에서 공개 API를 정의하며 관련 단위 테스트를 포함합니다. 변경사항OCR 노드 기반 구조
예상 코드 리뷰 난이도🎯 3 (Moderate) | ⏱️ ~25 minutes 제안 리뷰어
시
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/proovy_agent/graph/nodes/ocr_node/models.py (1)
45-49: ⚡ Quick win컨테이너 필드 타입을 더 구체화하는 편이 안전합니다.
list[dict],dict는 정적 타입 검증 이점이 약합니다. 최소한 키/값 타입(dict[str, object]등)까지 명시해 타입 안전성을 유지해 주세요.Also applies to: 89-89
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/proovy_agent/graph/nodes/ocr_node/models.py` around lines 45 - 49, The container fields bbox_data and metadata are currently typed as list[dict] and dict which weakens static type checks; update their annotations to concrete types (e.g., bbox_data: list[dict[str, Any]] or list[Mapping[str, Any]] and metadata: dict[str, Any] or Mapping[str, Any]) and import Any/Mapping from typing, and make the same change for the other occurrence referenced (the field at the later occurrence). Ensure the Field(...) declarations remain unchanged apart from the updated type annotations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/proovy_agent/graph/nodes/ocr_node/__init__.py`:
- Around line 3-10: The module is missing two public exception exports: add
OCRTimeoutError and OCRResourceError to the exceptions import list (the from
.exceptions import (...) block) and include "OCRTimeoutError" and
"OCRResourceError" in the module's __all__ export list so they are accessible at
package level; update both the import statement that currently lists
CommandParsingError, ConfidenceThresholdError, ImageProcessingError,
MathParsingError, OCREngineError, OCRError and the __all__ tuple/list where
public symbols are declared to include these two names.
In `@src/proovy_agent/graph/nodes/ocr_node/exceptions.py`:
- Around line 21-27: The __init__ methods in this file are missing return type
annotations; update each constructor (the __init__ methods such as the one that
currently has signature "def __init__(self, message: str = 'Image preprocessing
failed', details: dict | None = None, recovery_suggestion: str | None = None)"
and the other __init__ definitions around the file) to include an explicit "->
None" return type; ensure every constructor signature (including the ones at the
other occurrences referenced in the review) is changed to "def __init__(...) ->
None:" and keep the existing parameters and super().__init__ calls unchanged.
In `@src/proovy_agent/graph/nodes/ocr_node/models.py`:
- Around line 29-35: Add explicit Python 3.12+ type hints to the Pydantic field
validators: update validate_engines to accept and return list[str] (e.g., v:
list[str]) so its signature is annotated; update validate_image_size to accept
and return tuple[int, int] (or the exact sequence type used by the image_size
field) and update validate_text_content to accept and return str; keep the
`@field_validator` decorator and cls parameter but annotate v and the return types
accordingly so the signatures for validate_engines, validate_image_size, and
validate_text_content are fully typed.
---
Nitpick comments:
In `@src/proovy_agent/graph/nodes/ocr_node/models.py`:
- Around line 45-49: The container fields bbox_data and metadata are currently
typed as list[dict] and dict which weakens static type checks; update their
annotations to concrete types (e.g., bbox_data: list[dict[str, Any]] or
list[Mapping[str, Any]] and metadata: dict[str, Any] or Mapping[str, Any]) and
import Any/Mapping from typing, and make the same change for the other
occurrence referenced (the field at the later occurrence). Ensure the Field(...)
declarations remain unchanged apart from the updated type annotations.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 14caf210-8d58-4abc-ae80-1db5bcf43194
📒 Files selected for processing (6)
src/proovy_agent/graph/nodes/ocr_node/__init__.pysrc/proovy_agent/graph/nodes/ocr_node/exceptions.pysrc/proovy_agent/graph/nodes/ocr_node/models.pytests/ocr_node/__init__.pytests/ocr_node/test_exceptions.pytests/ocr_node/test_models.py
📌 관련 이슈
🏷️ PR 타입
📝 작업 내용
OCR 데이터 모델 구현
OCROptions: OCR 처리 옵션 및 설정 (engines, language, math_mode, confidence_threshold, max_processing_time)OCREngineResult: 개별 OCR 엔진 결과 (engine_name, raw_text, confidence, processing_time, bbox_data, metadata)OCRRequest: OCR 처리 요청 데이터 (image_data, image_format, user_id, thread_id, processing_options)OCRResult: 최종 OCR 처리 결과 (extracted_text, confidence, tags, math_expressions, engine_results, processing_time, metadata)포괄적 예외 처리 체계 구현
OCRError: 베이스 예외 클래스 (구조화된 에러 메시지 + 세부 정보)ImageProcessingError: 이미지 전처리 실패 예외 (복구 제안 포함)OCREngineError: 특정 OCR 엔진 실패 예외 (fallback 가능성 표시)MathParsingError: 수학 표기법 후처리 실패 예외 (원본 텍스트 보존)CommandParsingError: @커맨드 파싱 실패 예외 (잘못된 커맨드 목록 포함)ConfidenceThresholdError: 신뢰도 기준 미달 예외 (임계값 및 최고 점수 표시)OCRTimeoutError: OCR 처리 시간 초과 예외OCRResourceError: 리소스 제약 예외 (메모리, GPU 등)데이터 검증 및 타입 안전성
@field_validator사용으로 모든 모델의 데이터 무결성 보장list[T],dict[K, V],T | None)📸 스크린샷
✅ 체크리스트
📎 기타 참고사항
Summary by CodeRabbit
New Features
Tests
Chores