diff --git a/mindone/diffusers/configuration_utils.py b/mindone/diffusers/configuration_utils.py index a95d8b3dc4..d5f8de9fa3 100644 --- a/mindone/diffusers/configuration_utils.py +++ b/mindone/diffusers/configuration_utils.py @@ -120,23 +120,24 @@ def register_to_config(self, **kwargs): self._internal_dict = FrozenDict(internal_dict) - def __getattr__(self, name: str) -> Any: - """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/torch/nn/modules/module.html#Module - """ - - is_in_config = "_internal_dict" in self.__dict__ and hasattr(self.__dict__["_internal_dict"], name) - is_attribute = name in self.__dict__ - - if is_in_config and not is_attribute: - 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}'." # noqa: E501 - deprecate("direct config name access", "1.0.0", deprecation_message, standard_warn=False) - return self._internal_dict[name] - - raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'") + # TODO: The __getattr__ function will fail in graph mode during training. It needs to be fixed later. + # def __getattr__(self, name: str) -> Any: + # """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/torch/nn/modules/module.html#Module + # """ + # + # is_in_config = "_internal_dict" in self.__dict__ and hasattr(self.__dict__["_internal_dict"], name) + # is_attribute = name in self.__dict__ + # + # if is_in_config and not is_attribute: + # 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}'." # noqa: E501 + # deprecate("direct config name access", "1.0.0", deprecation_message, standard_warn=False) + # return self._internal_dict[name] + # + # raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'") def save_config(self, save_directory: Union[str, os.PathLike], push_to_hub: bool = False, **kwargs): """