feat(config): more resiliant update_config method

Only set values that have changed.
This commit is contained in:
psychedelicious 2024-03-12 01:39:08 +11:00
parent 1079bf3ccf
commit 5e39e46954

View File

@ -190,7 +190,10 @@ class InvokeAIAppConfig(BaseSettings):
new_config = config
for field_name in new_config.model_fields_set:
setattr(self, field_name, getattr(new_config, field_name))
new_value = getattr(new_config, field_name)
current_value = getattr(self, field_name)
if new_value != current_value:
setattr(self, field_name, new_value)
def write_file(self, exclude_defaults: bool) -> None:
"""Write the current configuration to the `invokeai.yaml` file. This will overwrite the existing file.