4.1.8 pde.backends.registry module
Defines the registry for managing backends.
Class handling all backends and their configurations. |
|
Load a default configuration from a module. |
|
Return backend specified by string of instance. |
|
Returns all registered backends. |
- class BackendRegistry[source]
Bases:
objectClass handling all backends and their configurations.
Backends can exist in three different states in registry: * Registered meta-information on how to load a backend package * Loaded backend module, so the class is available * Fully instantiated
BackendBaseclasses- get_backend(name, *, config=None, **kwargs)[source]
Return backend object, potentially loading the respective package.
- Parameters:
- Returns:
An instance of the backend with the particular configuration
- Return type:
- get_config(name)[source]
Get configuration of a particular backend.
An empty configuration is returned if nothing was found.
- register_backend(backend, *, link_config=False)[source]
Register a loaded backend object.
- Parameters:
backend (
BackendBase) – Implementation of the backendlink_config (bool) – If True, the configuration of backend is linked with the global configuration, so that both show consistent values.
- Return type:
None
- register_class(name, cls)[source]
Register a backend class.
- Parameters:
name (str) – Name of the backend
cls (subclass of
BackendBase) – The class for creating a backend
- register_package(name, package_path, *, config=None)[source]
Register a backend python package (without loading it yet)
- values()[source]
Iterate over all backends that can be imported.
- Return type:
Iterator[BackendBase]
- get_backend(backend)[source]
Return backend specified by string of instance.
- Parameters:
backend (str or
BackendBase) – Backend specified by name given as a string. If the string contains a colon, the first part determines the backend, whereas the second part can be used to convey additional information. For example,torch:cudamay load a torch backend and use a cuda device. As a special case, we also allow full backend objects, which are simply returned. This is a simple way to allow providing full backend objects in places where we otherwise would expect a backend name.- Return type: