dgs.utils.loader.register_instance

dgs.utils.loader.register_instance(name: str, instance: Type[I], instances: dict[str, Type[I]], inst_class: type, call: bool = True) None[source]

Given an instance with a name, add it to the available instances.

Parameters:
  • name – The name of the instance. Cannot be a value already present in instances.

  • instance – The instance that should be added to instances.

  • instances – A dictionary containing a mapping from instance names to instance classes.

  • inst_class – The class the instance should have.

  • call – Whether the instance should be callable. Default True.

Raises:

ValueError if either the name exists in instances or the instance has incorrect properties.