run_backend_chain#
- scikitplot.corpus.run_backend_chain(candidates, *, default, logger, component, operation, subject=None, error_code='OPTIONAL_BACKEND_FAILED', error_category=ErrorCategory.CAPABILITY, stage=None, is_empty=<function _never_empty>, passthrough_exceptions=(<class 'MemoryError'>, ), policy=None, capability_registry=None)[source]#
Try candidates in order and return a structured outcome.
This function deliberately does not decide whether a failed chain should raise. That is operation policy: ASR may be fail-soft by default and strict on request, while a parser may always raise. Callers inspect the returned status/errors and apply their own public contract.
- Parameters:
- candidatessequence of BackendCandidate
Ordered backend attempts.
- defaultobject
Value returned when no backend produces an accepted result.
- loggerlogging.Logger
Logger receiving per-backend diagnostics.
- componentstr
Human-facing owner, e.g.
"AudioReader".- operationstr
Operation label, e.g.
"transcription".- subjectstr or None, optional
Filename or other specific subject for diagnostics.
- error_codestr, optional
Stable
ErrorRecordcode used for backend exceptions.- error_categoryErrorCategory or str, optional
Diagnostic category. Defaults to
CAPABILITY.- stagestr or None, optional
Pipeline stage stored in structured errors.
- is_emptycallable, optional
Predicate identifying a successful but empty accepted value.
- passthrough_exceptionstuple, optional
Exceptions never converted into fallback diagnostics. Defaults to
MemoryError.
- Returns:
- BackendOutcome
Safe result plus backend provenance and structured errors. No live exception objects are retained.
- Parameters:
candidates (Sequence[BackendCandidate[_T]])
default (_T)
logger (Logger)
component (str)
operation (str)
subject (str | None)
error_code (str)
error_category (ErrorCategory | str)
stage (str | None)
passthrough_exceptions (tuple[type[BaseException], ...])
policy (BackendPolicy | str | Mapping[str, Any] | None)
capability_registry (CapabilityRegistry | None)
- Return type:
BackendOutcome[_T]