Skip to content

Bynt-1351: Missing whisper handling#111

Merged
tarekio merged 13 commits intomainfrom
bynt-1351-missing-whisper-handling
Jun 19, 2025
Merged

Bynt-1351: Missing whisper handling#111
tarekio merged 13 commits intomainfrom
bynt-1351-missing-whisper-handling

Conversation

@cango91
Copy link
Contributor

@cango91 cango91 commented Jun 16, 2025

Jira Issue

  1. BYNT-1351

Description

Simplified approach following @level09 's guidance:
SIMPLE_DEPENDENCY_FIX_PLAN.pdf

  • 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]

cango91 added 2 commits June 16, 2025 18:52
 ## 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]
@cango91 cango91 self-assigned this Jun 16, 2025
@cango91 cango91 requested a review from tarekio June 16, 2025 23:05
@tarekio tarekio requested a review from level09 June 17, 2025 17:18
@tarekio tarekio removed the request for review from level09 June 18, 2025 14:42
@cango91 cango91 requested a review from Copilot June 19, 2025 13:25
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 DependencyUtils singleton to detect availability of Whisper and Tesseract.
  • Expose HAS_WHISPER/HAS_TESSERACT in 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_whisper and check_tesseract to validate both installed and missing scenarios.
    def check_whisper(cls):

enferno/tasks/init.py:1244

  • [nitpick] The variable _flask_app may be unclear—everywhere else you use current_app. Consider using current_app for 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 ocrEnabled data 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_deps doesn't exist and will raise ImportError. You likely want to import TO_LANGUAGE_CODE directly from whisper.tokenizer or adjust to the correct helper module.
            from enferno.utils.optional_deps import TO_LANGUAGE_CODE

enferno/utils/dep_utils.py:37

  • [nitpick] Instantiating DependencyUtils at 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()

Copy link
Collaborator

@level09 level09 left a comment

Choose a reason for hiding this comment

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

Good job. just small little notes to merge

@tarekio tarekio merged commit 495de02 into main Jun 19, 2025
6 of 7 checks passed
@tarekio tarekio deleted the bynt-1351-missing-whisper-handling branch June 19, 2025 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants