aboutsummaryrefslogtreecommitdiff
path: root/modules/options.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2024-01-01 17:01:28 +0300
committerGitHub <noreply@github.com>2024-01-01 17:01:28 +0300
commitc507d7b25239bde465d0a556f66ba22e008089e5 (patch)
treeb317227a0e63c42aa8c4b06147761dfd37ae24fc /modules/options.py
parent15156cde18844f459ba101b1356d162aa7f39c47 (diff)
parent7ba02e0b7cfc85d5d237eba71ab4d66564857d55 (diff)
Merge pull request #13789 from nickpharrison/finer-settings-freezing-control
Finer settings freezing control
Diffstat (limited to 'modules/options.py')
-rw-r--r--modules/options.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/modules/options.py b/modules/options.py
index 4fead690..09ff9403 100644
--- a/modules/options.py
+++ b/modules/options.py
@@ -91,18 +91,35 @@ class Options:
if self.data is not None:
if key in self.data or key in self.data_labels:
+
+ # Check that settings aren't globally frozen
assert not cmd_opts.freeze_settings, "changing settings is disabled"
+ # Get the info related to the setting being changed
info = self.data_labels.get(key, None)
if info.do_not_save:
return
+ # Restrict component arguments
comp_args = info.component_args if info else None
if isinstance(comp_args, dict) and comp_args.get('visible', True) is False:
- raise RuntimeError(f"not possible to set {key} because it is restricted")
+ raise RuntimeError(f"not possible to set '{key}' because it is restricted")
+
+ # Check that this section isn't frozen
+ if cmd_opts.freeze_settings_in_sections is not None:
+ frozen_sections = list(map(str.strip, cmd_opts.freeze_settings_in_sections.split(','))) # Trim whitespace from section names
+ section_key = info.section[0]
+ section_name = info.section[1]
+ assert section_key not in frozen_sections, f"not possible to set '{key}' because settings in section '{section_name}' ({section_key}) are frozen with --freeze-settings-in-sections"
+
+ # Check that this section of the settings isn't frozen
+ if cmd_opts.freeze_specific_settings is not None:
+ frozen_keys = list(map(str.strip, cmd_opts.freeze_specific_settings.split(','))) # Trim whitespace from setting keys
+ assert key not in frozen_keys, f"not possible to set '{key}' because this setting is frozen with --freeze-specific-settings"
+ # Check shorthand option which disables editing options in "saving-paths"
if cmd_opts.hide_ui_dir_config and key in self.restricted_opts:
- raise RuntimeError(f"not possible to set {key} because it is restricted")
+ raise RuntimeError(f"not possible to set '{key}' because it is restricted with --hide_ui_dir_config")
self.data[key] = value
return