Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix lora settings: item filename keyerror #16008

Closed

Conversation

light-and-ray
Copy link
Contributor

@light-and-ray light-and-ray commented Jun 12, 2024

Description

Sometimes opening settings doesn't work due to this error:

stable-diffusion-webui/modules/ui_extra_networks_user_metadata.py", line 77, in get_card_html
    filename, _ = os.path.splitext(item["filename"])
KeyError: filename

It happens because lora's name is alias

Checklist:

@light-and-ray light-and-ray changed the title fix item filename keyerror fix lora settings: item filename keyerror Jun 12, 2024
@w-e-w
Copy link
Collaborator

w-e-w commented Jun 12, 2024

It happens because lora's name is alias

in what case does that happen?

@light-and-ray
Copy link
Contributor Author

After editing cards with different names and aliases. If I understand correctly. Or just after opening and closing. It's also connected with preview update, the error happens there

In general I had very inconsistent card settings, and after adding these 2 lines all started to be ok. I found this solution while making sdxl support in my old-sd-firstpasser extension, because SD model field is filled in the same place

@@ -17,6 +17,8 @@ def refresh(self):

def create_item(self, name, index=None, enable_filter=True):
lora_on_disk = networks.available_networks.get(name)
if lora_on_disk is None:
lora_on_disk = networks.available_network_aliases.get(name)
if lora_on_disk is None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

no that is not the fix

thes line of code is just a thread safe check to make sure that the entry is already loaded
otherwise it stopped processing

this functuon is for creading cards not selecting lora in prompt
name MUST be unique and and in available_networks
available_network_aliases should not be used as a fallback

if you use available_network_aliases as fallback then you could end up in a situation where the lora list is not fully loaded but a but the matching alias is, which would then cause you to select the wrong lora to be edited

the issue as you have written is for some reason

    filename, _ = os.path.splitext(item["filename"])
KeyError: filename

so the investigation subsequent fix fix should be about why the filename key is missing
and not adding a problematic pullback

@light-and-ray
Copy link
Contributor Author

I don't understand

this functuon is for creading cards not selecting lora in prompt

I know, and I write in the description about cards in ui

if you use available_network_aliases as fallback then you could end up in a situation where the lora list is not fully loaded but a but the matching alias is, which would then cause you to select the wrong lora to be edited

Available networks are loaded first, and then "info" objects for cards are being loaded. How does it possible to not have lora list fully loaded

so the investigation subsequent fix fix should be about why the filename key is missing
and not adding a problematic pullback

Okay I'll find a way to reproduce

@light-and-ray
Copy link
Contributor Author

light-and-ray commented Jun 13, 2024

Oh I see, thank you @w-e-w . This problem happens only if the backend was reloaded, but the frontend - not. Users need to press reload button

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants