From 53dc1d8197a0a2f9a803dccf9457f9b1b04dbc26 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Tue, 9 Jan 2024 18:59:04 -0800 Subject: [PATCH] UI: Do not save unchanged settings to settings.yaml --- modules/shared.py | 2 ++ modules/ui.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/modules/shared.py b/modules/shared.py index b4194107..1c53ba38 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -1,4 +1,5 @@ import argparse +import copy import os import sys from collections import OrderedDict @@ -65,6 +66,7 @@ settings = { 'default_extensions': ['gallery'], } +default_settings = copy.deepcopy(settings) # Parser copied from https://github.com/vladmandic/automatic parser = argparse.ArgumentParser(description="Text generation web UI", conflict_handler='resolve', add_help=True, formatter_class=lambda prog: argparse.HelpFormatter(prog, max_help_position=55, indent_increment=2, width=200)) diff --git a/modules/ui.py b/modules/ui.py index 486a5b98..176d27a2 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -234,6 +234,11 @@ def save_settings(state, preset, extensions_list, show_controls, theme_state): _id = f"{extension_name}-{param}" output[_id] = params[param] + # Do not save unchanged settings + for key in list(output.keys()): + if key in shared.default_settings and output[key] == shared.default_settings[key]: + output.pop(key) + return yaml.dump(output, sort_keys=False, width=float("inf"))