registry
Registry
from dara.core.internal.registry import Registry
class Registry(Generic[T])
A generic registry class that allows for new registries to be quickly added and expose a common interface
Attributes
- _registry: MutableMapping[str, T]
Methods
__init__
def __init__(name: RegistryType,
initial_registry: Optional[MutableMapping[str, T]] = None,
allow_duplicates: Optional[bool] = True)
Arguments:
name: human readable name of the registry; used for metricsinitial_registry: an optional initial set of elements for the registryallow_duplicates: an optional boolean which determines whether this registry should allow for duplicate uids entries
register
def register(key: str, value: T)
Register an entity to the registry
get
def get(key: str) -> T
Fetch an entity from the registry, will raise if it's not found
has
def has(key: str) -> bool
Check whether the registry has the given key registered
set
def set(key: str, value: T)
Set an entity for the registry, if already present overwrites it
get_all
def get_all() -> MutableMapping[str, T]
Fetch all the items currently registered
remove
def remove(key: str)
Remove the key from registry, will raise if it's not found
replace
def replace(new_registry: MutableMapping[str, T], deepcopy=True)
Replace the entire registry with a new one