ObjectRegistry

Provides a simple interface to global object registries so that pieces of code don’t need to pass things like loggers or parallelizers through every step of the code

 

__init__(self, default='raise'): 

LLM Docstring

Create a weak-value registry with configurable behavior for missing keys.

  • default: object

    the fallback returned when a key is absent

  • :returns: None

    No explicit value; the method mutates state or performs I/O.

 

temp_default(self, val): 

LLM Docstring

Create a context manager that temporarily replaces the registry fallback value.

  • val: object

    the value being stored, converted, or installed

  • :returns: object

    The resolved or newly constructed helper object.

 

__contains__(self, item): 

LLM Docstring

Test whether a live weakly referenced object is registered under a key.

  • item: object

    the lookup key or index

  • :returns: bool

    Whether the tested condition is satisfied.

 

lookup(self, key): 

LLM Docstring

Return the registered object, or the configured default when missing-key lookup is non-raising.

  • key: object

    the storage or lookup key

  • :returns: object

    The reconstructed, loaded, or selected Python value.

 

__getitem__(self, item): 

LLM Docstring

Look up a registry key using the configured missing-key policy.

  • item: object

    the lookup key or index

  • :returns: object

    The reconstructed, loaded, or selected Python value.

 

register(self, key, val): 

LLM Docstring

Store a weak reference to val under key.

  • key: object

    the storage or lookup key

  • val: object

    the value being stored, converted, or installed

  • :returns: None

    No explicit value; the method mutates state or performs I/O.

 

__setitem__(self, key, value): 

LLM Docstring

Register a value using dictionary assignment syntax.

  • key: object

    the storage or lookup key

  • value: object

    the value to store

  • :returns: None

    No explicit value; the method mutates state or performs I/O.

 

keys(self): 

LLM Docstring

Return the live registry keys.

  • :returns: collections.abc.KeysView | collections.abc.ItemsView | collections.abc.ValuesView | list

    A view or list of the requested registry, cache, checkpoint, or mapping entries.

 

items(self): 

LLM Docstring

Return the live registry key/value pairs.

  • :returns: collections.abc.KeysView | collections.abc.ItemsView | collections.abc.ValuesView | list

    A view or list of the requested registry, cache, checkpoint, or mapping entries.

 

values(self): 

LLM Docstring

Return the live registered objects.

  • :returns: collections.abc.KeysView | collections.abc.ItemsView | collections.abc.ValuesView | list

    A view or list of the requested registry, cache, checkpoint, or mapping entries.


Feedback

Examples

Templates

Documentation