BackendCandidate#

class scikitplot.corpus.BackendCandidate(name, run, accept=<function _accept_any>, fallback_exceptions=(<class 'Exception'>, ), failure_level=30, miss_level=10, degrades_on_failure=True, capability=None, requires_network=False, may_download=False, offline_capable=False)[source]#

One lazy backend attempt.

Parameters:
namestr

Stable backend identifier used in logs and diagnostics.

runcallable

Zero-argument callable that performs the backend work. Third-party imports should remain inside this callable.

acceptcallable, optional

Predicate deciding whether a returned value is usable. Returning False is a miss, not a failure, and advances to the next backend. The default accepts every returned value, including None and empty containers.

fallback_exceptionstuple of exception classes, optional

Exceptions that mean “this backend could not serve the request; try the next one”. Exceptions outside this tuple propagate immediately. Defaults to ordinary Exception, intentionally excluding KeyboardInterrupt and SystemExit.

failure_levelint, optional

Logging level for backend exceptions. Default: logging.WARNING.

miss_levelint, optional

Logging level when accept rejects a normal return value. Default: logging.DEBUG.

degrades_on_failurebool, optional

Whether failure of this preferred backend makes a later successful fallback DEGRADED. Set False when absence/failure is an expected capability probe and the fallback is semantically equivalent.

capabilitystr or None, optional

Capability-registry key used for readiness preflight and provenance.

requires_networkbool, optional

Whether normal execution requires network access.

may_downloadbool, optional

Whether first use may need to download assets. This is a risk/property flag, not proof that a download is needed for the current request.

offline_capablebool, optional

Whether the candidate can enforce local-only execution when policy forbids downloads/network. Such a candidate may be attempted when asset readiness is UNKNOWN; its runner must then select a local-only mode rather than silently contacting the network.

Parameters:
accept()[source]#
Parameters:

_value (Any)

Return type:

bool

capability: str | None = None#
degrades_on_failure: bool = True#
failure_level: int = 30#
fallback_exceptions: tuple[type[BaseException], ...] = (<class 'Exception'>,)#
may_download: bool = False#
miss_level: int = 10#
name: str[source]#
offline_capable: bool = False#
requires_network: bool = False#
run: Callable[[], _T][source]#