Skip to content

Commit

Permalink
fix the bug in script-info API
Browse files Browse the repository at this point in the history
  • Loading branch information
AUTOMATIC1111 committed Sep 9, 2023
1 parent 741e8ec commit 259768f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,15 @@ def create_script_ui(self, script):

arg_info = api_models.ScriptArg(label=control.label or "")

for field in ("value", "minimum", "maximum", "step", "choices"):
for field in ("value", "minimum", "maximum", "step"):
v = getattr(control, field, None)
if v is not None:
setattr(arg_info, field, v)

choices = getattr(control, 'choices', None) # as of gradio 3.41, some items in choices are strings, and some are tuples where the first elem is the string
if choices is not None:
setattr(arg_info, 'choices', [x[0] if isinstance(x, tuple) else x for x in choices])

api_args.append(arg_info)

script.api_info = api_models.ScriptInfo(
Expand Down

3 comments on commit 259768f

@GeminiSquishGames
Copy link

@GeminiSquishGames GeminiSquishGames commented on 259768f Dec 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cloned from Master a few days ago and have to change this by hand. Is it not in Master after Commited by Automatic1111? Looked at it from the repo in browser and it's not updated...

@NaCl4Ever
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed the same thing in my latest pull as of Dec, 12th. Had to manually add this fix in

@GeminiSquishGames
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went ahead and started using the dev branch. It has the fix and it seems pretty usable, with interesting features and changes, and some options I've been waiting for.

Please sign in to comment.