🥅(summary) catch file-related exceptions when handling recording objects
Previously, if a recording file was not found in the bucket, the code would crash. This adds proper error handling to avoid unhandled failures.
This commit is contained in:
committed by
aleb_the_flash
parent
716e11b5b3
commit
9f58efb851
@@ -20,6 +20,7 @@ and this project adheres to
|
|||||||
- ♿️(frontend) sr pin/unpin announcements with dedicated messages #898
|
- ♿️(frontend) sr pin/unpin announcements with dedicated messages #898
|
||||||
- ♿(frontend) adjust sr announcements for idle disconnect timer #908
|
- ♿(frontend) adjust sr announcements for idle disconnect timer #908
|
||||||
- ♿️(frontend) add global screen reader announcer#922
|
- ♿️(frontend) add global screen reader announcer#922
|
||||||
|
- 🥅(summary) catch file-related exceptions when handling recording #944
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ from urllib3.util import Retry
|
|||||||
|
|
||||||
from summary.core.analytics import MetadataManager, get_analytics
|
from summary.core.analytics import MetadataManager, get_analytics
|
||||||
from summary.core.config import get_settings
|
from summary.core.config import get_settings
|
||||||
from summary.core.file_service import FileService
|
from summary.core.file_service import FileService, FileServiceException
|
||||||
from summary.core.llm_service import LLMException, LLMObservability, LLMService
|
from summary.core.llm_service import LLMException, LLMObservability, LLMService
|
||||||
from summary.core.prompt import (
|
from summary.core.prompt import (
|
||||||
FORMAT_NEXT_STEPS,
|
FORMAT_NEXT_STEPS,
|
||||||
@@ -145,6 +145,7 @@ def process_audio_transcribe_summarize_v2(
|
|||||||
max_retries=settings.whisperx_max_retries,
|
max_retries=settings.whisperx_max_retries,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
with (
|
with (
|
||||||
file_service.prepare_audio_file(filename) as (audio_file, metadata),
|
file_service.prepare_audio_file(filename) as (audio_file, metadata),
|
||||||
):
|
):
|
||||||
@@ -176,6 +177,10 @@ def process_audio_transcribe_summarize_v2(
|
|||||||
logger.info("Transcription received in %.2f seconds.", transcription_time)
|
logger.info("Transcription received in %.2f seconds.", transcription_time)
|
||||||
logger.debug("Transcription: \n %s", transcription)
|
logger.debug("Transcription: \n %s", transcription)
|
||||||
|
|
||||||
|
except FileServiceException:
|
||||||
|
logger.exception("Unexpected error for filename: %s", filename)
|
||||||
|
return
|
||||||
|
|
||||||
metadata_manager.track_transcription_metadata(task_id, transcription)
|
metadata_manager.track_transcription_metadata(task_id, transcription)
|
||||||
|
|
||||||
formatter = TranscriptFormatter()
|
formatter = TranscriptFormatter()
|
||||||
|
|||||||
@@ -8,12 +8,19 @@ from pathlib import Path
|
|||||||
|
|
||||||
import mutagen
|
import mutagen
|
||||||
from minio import Minio
|
from minio import Minio
|
||||||
|
from minio.error import MinioException, S3Error
|
||||||
|
|
||||||
from summary.core.config import get_settings
|
from summary.core.config import get_settings
|
||||||
|
|
||||||
settings = get_settings()
|
settings = get_settings()
|
||||||
|
|
||||||
|
|
||||||
|
class FileServiceException(Exception):
|
||||||
|
"""Base exception for file service operations."""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class FileService:
|
class FileService:
|
||||||
"""Service for downloading and preparing files from MinIO storage."""
|
"""Service for downloading and preparing files from MinIO storage."""
|
||||||
|
|
||||||
@@ -79,6 +86,11 @@ class FileService:
|
|||||||
|
|
||||||
return local_path
|
return local_path
|
||||||
|
|
||||||
|
except (MinioException, S3Error) as e:
|
||||||
|
raise FileServiceException(
|
||||||
|
"Unexpected error while downloading object."
|
||||||
|
) from e
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
if response:
|
if response:
|
||||||
response.close()
|
response.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user