Feature/133 config model path - #262
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
📝 WalkthroughWalkthroughThis PR adds configuration-driven tokenizer resolution and runtime validation for unresolved YAML placeholders across document processors. Tokenizers are now resolved from local paths with HuggingFace fallback, injected through processor constructors, and stored for chunking. Configuration files introduce new ChangesConfiguration-driven tokenization and placeholder validation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 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.
🧹 Nitpick comments (1)
genon/preprocessor/facade/parser_processor.py (1)
143-169: 💤 Low valueConsider extracting
_warn_unresolved_placeholdersto a shared utility module.This function is duplicated across multiple facade processors (intelligent_processor, parser_processor, convert_processor, attachment_processor). Extracting it to a shared module (e.g.,
genon/preprocessor/facade/config_utils.py) would reduce duplication and simplify future maintenance.That said, if the facade architecture intentionally keeps processors self-contained for deployment flexibility, the duplication is acceptable.
🤖 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 `@genon/preprocessor/facade/parser_processor.py` around lines 143 - 169, The _warn_unresolved_placeholders function in parser_processor.py is duplicated across multiple facade processors; extract it into a shared utility module (e.g., create genon/preprocessor/facade/config_utils.py) as a single function named _warn_unresolved_placeholders (or warn_unresolved_placeholders) implemented exactly once, then replace the local implementations in parser_processor, intelligent_processor, convert_processor, and attachment_processor with imports from that module and update their calls; ensure the regex, traversal logic, signature (cfg: dict, config_path: str) and logging via _log remain unchanged and run linters/tests to validate imports.
🤖 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.
Nitpick comments:
In `@genon/preprocessor/facade/parser_processor.py`:
- Around line 143-169: The _warn_unresolved_placeholders function in
parser_processor.py is duplicated across multiple facade processors; extract it
into a shared utility module (e.g., create
genon/preprocessor/facade/config_utils.py) as a single function named
_warn_unresolved_placeholders (or warn_unresolved_placeholders) implemented
exactly once, then replace the local implementations in parser_processor,
intelligent_processor, convert_processor, and attachment_processor with imports
from that module and update their calls; ensure the regex, traversal logic,
signature (cfg: dict, config_path: str) and logging via _log remain unchanged
and run linters/tests to validate imports.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 59b682a8-5263-4ad9-a774-baad379d8533
📒 Files selected for processing (11)
genon/preprocessor/facade/attachment_processor.pygenon/preprocessor/facade/convert_processor.pygenon/preprocessor/facade/intelligent_processor.pygenon/preprocessor/facade/parser_processor.pygenon/preprocessor/resource/attachment_processor_config.yamlgenon/preprocessor/resource/convert_processor_config.yamlgenon/preprocessor/resource/intelligent_processor_config.yamlgenon/preprocessor/resource/parser_processor_config.yamlgenon/preprocessor/resource_dev/attachment_processor_config.yamlgenon/preprocessor/resource_dev/convert_processor_config.yamlgenon/preprocessor/resource_dev/intelligent_processor_config.yaml
feat(#133): 모델 경로(토크나이저·artifacts) yaml 설정화 + 미치환 플레이스홀더 경고
배경 / 문제
/models/doc_parser_models/...)와HF fallback id, docling 모델(TableFormer 등) artifacts 경로가 코드에 하드코딩되어
있어, site별로 경로가 다르거나 외부 네트워크가 차단된 환경에서 재배포 없이 변경할 수
없었다.
<WHISPER_ENDPOINT>등플레이스홀더를 실제 값으로 치환해야 하는데, 치환을 빠뜨려도 기동 시점에 드러나지 않고
해당 기능을 실제로 호출할 때서야 오류가 발생했다.
변경 사항
1. 모델 경로 yaml 설정화 (
models:섹션 신설)config yaml에
models:섹션을 추가하여 토크나이저/artifacts 경로를 코드 수정 없이 조정가능하도록 노출. 미지정 시 현행 하드코딩 기본값과 동일하게 동작(하위 호환).
_resolve_tokenizer(models_cfg)헬퍼:tokenizer_path가 실제 존재하면 로컬경로(
Path)를, 없으면tokenizer_id(HF) 로 폴백.GenosSmartChunker.tokenizer기본값도 동일 로직의 모듈 상수(
_DEFAULT_TOKENIZER_LOCAL_PATH/_DEFAULT_TOKENIZER_ID)로 정리.artifacts_path: config에 값이 있을 때만pipe_line_options.artifacts_path를 설정하고, 비어 있으면 설정하지 않아 docling 기본 캐시 동작을 그대로 유지
(
ocr_pipe_line_options는 deep copy라 자동 전파). convert/intelligent에 적용.DocumentProcessor에서cfg.get("models")를 읽어self._tokenizer를 결정하고,split_documents()의 청킹 시 해당 토크나이저를 전달.2. 미치환 플레이스홀더 경고
_warn_unresolved_placeholders(cfg, config_path):_load_config()에서 config전체를 재귀 스캔해
<[A-Z0-9_]+>패턴(미치환 UPPER_SNAKE 플레이스홀더)을 탐지.발견 시 경로와 함께 WARNING 로그를 남긴다.
경우(예: 음성 미사용 site의
<WHISPER_ENDPOINT>)에도 정상 기동.3. whisper 설정 주석 정리
명확화하고,
<WHISPER_ENDPOINT>가 미사용 시 무시됨을 명시.영향 범위 / 호환성
models:섹션 / 신규 키를 생략하면 기존과 동일하게 코드 기본값으로 동작(하위 호환).artifacts_path가 비어 있으면 docling 기본 캐시 경로를 그대로 사용.변경 파일
facade 4종
genon/preprocessor/facade/parser_processor.pygenon/preprocessor/facade/convert_processor.pygenon/preprocessor/facade/intelligent_processor.pygenon/preprocessor/facade/attachment_processor.pyconfig yaml 7종 (
models:섹션 추가 / whisper 주석 정리)resource/{parser,convert,intelligent,attachment}_processor_config.yamlresource_dev/{convert,intelligent,attachment}_processor_config.yaml테스트
tokenizer_path가 존재하지 않는 환경에서tokenizer_id(HF) 폴백 확인.artifacts_path지정 시 docling 모델이 해당 로컬 경로에서 로딩되는지 확인.<WHISPER_ENDPOINT>등 플레이스홀더가 남은 config 로드 시 경로와 함께 WARNING로그가 출력되는지 확인.
Summary by CodeRabbit
Release Notes
New Features
Documentation