Add container diarization configuration
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
@@ -26,6 +27,7 @@ class AppSettings:
|
||||
diarization_mode: str = "auto"
|
||||
diarization_runtime: str = "native"
|
||||
diarization_container_image: str | None = None
|
||||
diarization_container_args: tuple[str, ...] = ()
|
||||
|
||||
@classmethod
|
||||
def from_environment(cls) -> AppSettings:
|
||||
@@ -45,6 +47,9 @@ class AppSettings:
|
||||
diarization_mode=os.getenv("MKA_DIARIZATION_MODE", "auto"),
|
||||
diarization_runtime=os.getenv("MKA_DIARIZATION_RUNTIME", "native"),
|
||||
diarization_container_image=os.getenv("MKA_DIARIZATION_CONTAINER_IMAGE"),
|
||||
diarization_container_args=_parse_container_args(
|
||||
os.getenv("MKA_DIARIZATION_CONTAINER_ARGS")
|
||||
),
|
||||
)
|
||||
|
||||
def validate_for_processing(self) -> None:
|
||||
@@ -67,3 +72,29 @@ class AppSettings:
|
||||
raise ConfigurationError(
|
||||
"MKA_DIARIZATION_CONTAINER_IMAGE is required for container runtime."
|
||||
)
|
||||
if any(
|
||||
not isinstance(argument, str) or not argument
|
||||
for argument in self.diarization_container_args
|
||||
):
|
||||
raise ConfigurationError(
|
||||
"MKA_DIARIZATION_CONTAINER_ARGS must contain only non-empty strings."
|
||||
)
|
||||
|
||||
|
||||
def _parse_container_args(value: str | None) -> tuple[str, ...]:
|
||||
"""Parse an ordered JSON array of opaque container command arguments."""
|
||||
if value is None or not value.strip():
|
||||
return ()
|
||||
try:
|
||||
parsed = json.loads(value)
|
||||
except json.JSONDecodeError as exc:
|
||||
raise ConfigurationError(
|
||||
"MKA_DIARIZATION_CONTAINER_ARGS must be a JSON array of strings."
|
||||
) from exc
|
||||
if not isinstance(parsed, list) or any(
|
||||
not isinstance(argument, str) or not argument for argument in parsed
|
||||
):
|
||||
raise ConfigurationError(
|
||||
"MKA_DIARIZATION_CONTAINER_ARGS must be a JSON array of non-empty strings."
|
||||
)
|
||||
return tuple(parsed)
|
||||
|
||||
@@ -200,6 +200,7 @@ class MeetingProcessingService:
|
||||
),
|
||||
"diarization_runtime": self.settings.diarization_runtime,
|
||||
"diarization_container_image": (self.settings.diarization_container_image),
|
||||
"diarization_container_args": self.settings.diarization_container_args,
|
||||
}
|
||||
)
|
||||
current_stage: str | None = None
|
||||
@@ -230,13 +231,17 @@ class MeetingProcessingService:
|
||||
"transcript_validation": "transcription",
|
||||
"protocol": "protocol_generation",
|
||||
}.get(backend_stage, backend_stage)
|
||||
failure_message = failure.get("message") or "Meeting Lab processing failed."
|
||||
failure_type = failure.get("type")
|
||||
if failure_type and not failure_message.startswith(f"{failure_type}:"):
|
||||
failure_message = f"{failure_type}: {failure_message}"
|
||||
return ProcessingOutcome(
|
||||
succeeded=False,
|
||||
run_dir=result.run_dir,
|
||||
original_protocol=None,
|
||||
protocol_path=None,
|
||||
failed_stage=failed_stage or current_stage or "preparing",
|
||||
error_message=failure.get("message") or "Meeting Lab processing failed.",
|
||||
error_message=failure_message,
|
||||
)
|
||||
protocol_path = Path(result.protocol_path)
|
||||
return ProcessingOutcome(
|
||||
|
||||
@@ -286,7 +286,10 @@ def main() -> None:
|
||||
if outcome.succeeded:
|
||||
status_box.success("Processing completed.")
|
||||
else:
|
||||
status_box.error("Processing failed. Artifacts were preserved.")
|
||||
status_box.error(
|
||||
f"Processing failed during {outcome.failed_stage}: "
|
||||
f"{outcome.error_message} Artifacts were preserved."
|
||||
)
|
||||
except (ConfigurationError, MeetingLabUnavailableError, ValueError) as exc:
|
||||
st.error(str(exc))
|
||||
except Exception as exc:
|
||||
|
||||
Reference in New Issue
Block a user