MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / __getattr__

Method __getattr__

diffusers/src/diffusers/configuration_utils.py:127–143  ·  view source on GitHub ↗

The only reason we overwrite `getattr` here is to gracefully deprecate accessing config attributes directly. See https://github.com/huggingface/diffusers/pull/3129 This function is mostly copied from PyTorch's __getattr__ overwrite: https://pytorch.org/docs/stable/_modules/t

(self, name: str)

Source from the content-addressed store, hash-verified

125 self._internal_dict = FrozenDict(internal_dict)
126
127 def __getattr__(self, name: str) -> Any:
128 """The only reason we overwrite `getattr` here is to gracefully deprecate accessing
129 config attributes directly. See https://github.com/huggingface/diffusers/pull/3129
130
131 This function is mostly copied from PyTorch's __getattr__ overwrite:
132 https://pytorch.org/docs/stable/_modules/torch/nn/modules/module.html#Module
133 """
134
135 is_in_config = "_internal_dict" in self.__dict__ and hasattr(self.__dict__["_internal_dict"], name)
136 is_attribute = name in self.__dict__
137
138 if is_in_config and not is_attribute:
139 deprecation_message = f"Accessing config attribute `{name}` directly via '{type(self).__name__}' object attribute is deprecated. Please access '{name}' over '{type(self).__name__}'s config object instead, e.g. 'scheduler.config.{name}'."
140 deprecate("direct config name access", "1.0.0", deprecation_message, standard_warn=False)
141 return self._internal_dict[name]
142
143 raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
144
145 def save_config(self, save_directory: Union[str, os.PathLike], push_to_hub: bool = False, **kwargs):
146 """

Callers

nothing calls this directly

Calls 1

deprecateFunction · 0.85

Tested by

no test coverage detected