fix(nodes): do not freeze or cache config in context wrapper

- The config is already cached by the config class's `get_config()` method.
- The config mutates itself in its `root_path` property getter. Freezing the class makes any attempt to grab a path from the config error. Unfortunately this means we cannot easily freeze the class without fiddling with the inner workings of `InvokeAIAppConfig`, which is outside the scope here.
This commit is contained in:
psychedelicious 2024-02-07 15:58:46 +11:00 committed by Brandon Rising
parent 3fea7a6f00
commit e38d275e20

View File

@ -357,24 +357,10 @@ class ModelsInterface(InvocationContextInterface):
class ConfigInterface(InvocationContextInterface):
def __init__(self, services: InvocationServices, context_data: InvocationContextData) -> None:
super().__init__(services, context_data)
# Config cache, only populated at runtime if requested
self._frozen_config: Optional[InvokeAIAppConfig] = None
def get(self) -> InvokeAIAppConfig:
"""
Gets the app's config. The config is read-only; attempts to mutate it will raise an error.
"""
"""Gets the app's config."""
if self._frozen_config is None:
# The config is a live pydantic model and can be changed at runtime.
# We don't want nodes doing this, so we make a frozen copy.
self._frozen_config = self._services.configuration.get_config().model_copy(
update={"model_config": ConfigDict(frozen=True)}
)
return self._frozen_config
return self._services.configuration.get_config()
class UtilInterface(InvocationContextInterface):