Merged
Conversation
## Jira Issue 1. [BYNT-1351](https://syriajustice.atlassian.net/browse/BYNT-1351) ## Description - Centralize optional dependency handling - Fix imports through codebase - Add config validation for whisper and tesseract - Frontend: Avoid polluting the global namespace ## Checklist - [ ] Tests added/updated - [ ] Documentation updated (if needed) - [ ] New strings prepared for translations ## API Changes (if applicable) - [ ] Permissions checked - [ ] Endpoint tests added ## Additional Notes [Any other relevant information]
…that caches the check results on first instance creation.
There was a problem hiding this comment.
Pull Request Overview
Centralize optional dependency checks for Whisper and Tesseract and propagate flags through backend and frontend to avoid import errors when these packages are missing.
- Introduce
DependencyUtilssingleton to detect availability of Whisper and Tesseract. - Expose
HAS_WHISPER/HAS_TESSERACTin configuration and guard backend tasks and utilities. - Replace global window feature flags in the Vue template with reactive data properties and disable UI controls when dependencies are unavailable.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| utils/dep_utils.py | New singleton to check and cache Whisper/Tesseract availability |
| tasks/init.py | Guard load_whisper_model task with HAS_WHISPER flag |
| settings.py | Import DependencyUtils and add HAS_WHISPER/HAS_TESSERACT |
| data_import/views.py | Return empty list if Whisper is unavailable in API endpoint |
| data_import/utils/media_import.py | Remove old imports, guard OCR/transcription logic with flags |
| data_import/templates/media-import.html | Replace global flags with reactive Vue properties |
| admin/views.py | Remove stray whitespace in upload handler |
| admin/validation/models.py | Remove unused os import |
| admin/templates/system-administration.html | Disable UI switches and show alerts when dependencies are missing |
Comments suppressed due to low confidence (5)
enferno/utils/dep_utils.py:14
- New logic branches for detecting Whisper and Tesseract are not covered by existing tests. Add unit tests for
check_whisperandcheck_tesseractto validate both installed and missing scenarios.
def check_whisper(cls):
enferno/tasks/init.py:1244
- [nitpick] The variable
_flask_appmay be unclear—everywhere else you usecurrent_app. Consider usingcurrent_appfor consistency and to avoid confusion.
if not _flask_app.config["HAS_WHISPER"]:
enferno/data_import/templates/media-import.html:448
- [nitpick] Mixing Jinja expressions inside Vue template directives can be hard to read and maintain. Consider binding to the reactive
ocrEnableddata property directly with a straightforward negation (v-if="!ocrEnabled").
this.selAllDisabled = false;
enferno/data_import/utils/media_import.py:321
- The module
enferno.utils.optional_depsdoesn't exist and will raise ImportError. You likely want to importTO_LANGUAGE_CODEdirectly fromwhisper.tokenizeror adjust to the correct helper module.
from enferno.utils.optional_deps import TO_LANGUAGE_CODE
enferno/utils/dep_utils.py:37
- [nitpick] Instantiating
DependencyUtilsat import time introduces side effects early. Consider lazy initialization of checks when flags are first accessed to avoid unnecessary imports during startup or in tests.
DependencyUtils()
level09
reviewed
Jun 19, 2025
Collaborator
level09
left a comment
There was a problem hiding this comment.
Good job. just small little notes to merge
level09
approved these changes
Jun 19, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira Issue
Description
Simplified approach following @level09 's guidance:
SIMPLE_DEPENDENCY_FIX_PLAN.pdf
Checklist
API Changes (if applicable)
Additional Notes
[Any other relevant information]