scverse_backends.Settings#

class scverse_backends.Settings(registry)[source]#

Bases: object

Per-host settings exposing .backend and .use_backend().

Each BackendDispatcher owns one _Settings with its own ContextVar so host libraries’ active backends are isolated.

Parameters:
registry _Registry

__init__(registry)[source]#
Parameters:
registry _Registry

Return type:

None

Methods

__init__(registry)

available_backends()

Return canonical names of all discovered backends.

get_backend(name)

Look up a backend by name or alias.

use_backend(backend)

Temporarily set the backend within a context.

Attributes

backend

The active backend name (default 'cpu').

property backend: str#

The active backend name (default 'cpu').

Set to a registered backend name or alias (e.g. 'cuda'). Aliases are resolved to the canonical name on assignment.

use_backend(backend)[source]#

Temporarily set the backend within a context.

Examples

>>> with settings.use_backend("cuda"):
...     ...
Parameters:
backend str

Return type:

Generator[None, None, None]

available_backends()[source]#

Return canonical names of all discovered backends.

Return type:

list[str]

get_backend(name)[source]#

Look up a backend by name or alias.

Parameters:
name str

Return type:

Any | None