From 321e13ca176b256177c4a752d1f2bbee79b5532e Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Fri, 4 Nov 2022 10:35:30 +0300 Subject: [PATCH] produce a readable error message when setting an option fails on the settings screen --- modules/ui.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/ui.py b/modules/ui.py index 633b56ef..3ac7540c 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -1439,8 +1439,7 @@ def create_ui(wrap_gradio_gpu_call): changed = 0 for key, value, comp in zip(opts.data_labels.keys(), args, components): - if comp != dummy_component and not opts.same_type(value, opts.data_labels[key].default): - return f"Bad value for setting {key}: {value}; expecting {type(opts.data_labels[key].default).__name__}", opts.dumpjson() + assert comp == dummy_component or opts.same_type(value, opts.data_labels[key].default), f"Bad value for setting {key}: {value}; expecting {type(opts.data_labels[key].default).__name__}" for key, value, comp in zip(opts.data_labels.keys(), args, components): if comp == dummy_component: @@ -1458,7 +1457,7 @@ def create_ui(wrap_gradio_gpu_call): opts.save(shared.config_filename) - return f'{changed} settings changed.', opts.dumpjson() + return opts.dumpjson(), f'{changed} settings changed.' def run_settings_single(value, key): if not opts.same_type(value, opts.data_labels[key].default): @@ -1622,9 +1621,9 @@ def create_ui(wrap_gradio_gpu_call): text_settings = gr.Textbox(elem_id="settings_json", value=lambda: opts.dumpjson(), visible=False) settings_submit.click( - fn=run_settings, + fn=wrap_gradio_call(run_settings, extra_outputs=[gr.update()]), inputs=components, - outputs=[result, text_settings], + outputs=[text_settings, result], ) for i, k, item in quicksettings_list: