Skip to content

Raise error if Blocks has duplicate component with same IDs#2359

Merged
abidlabs merged 5 commits into
mainfrom
duplicate
Sep 28, 2022
Merged

Raise error if Blocks has duplicate component with same IDs#2359
abidlabs merged 5 commits into
mainfrom
duplicate

Conversation

@abidlabs
Copy link
Copy Markdown
Member

@abidlabs abidlabs commented Sep 28, 2022

Fixes: #2320

Also avoids making a call to figure out the IP address if analytics is disabled. The reason for that change is that I was working with airplane Wifi and noticed it was extremely slow to launch a Gradio Interface because it was taking a long time to get the IP address. The real solution is to use async requests, but this is a temporary bandaid

@github-actions
Copy link
Copy Markdown
Contributor

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2359-all-demos

Copy link
Copy Markdown
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

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

@abidlabs Thanks! The changes related to the DuplicateBlockError look good to me but some of the tests are failing due to the refactoring of the analytics payload. What's the intended purpose of that change?

Comment thread gradio/exceptions.py Outdated
@@ -1,3 +1,7 @@
class DuplicateBlockError(KeyError):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think KeyError is usually reserved for when a key in a dictionary is not present? Minor point but I think a ValueError or LookupError would be more appropriate here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure, will change to ValueError

@abidlabs
Copy link
Copy Markdown
Member Author

abidlabs commented Sep 28, 2022

Thanks for the review @freddyaboulton! I added the reason for the analytics refactor above:

Also avoids making a call to figure out the IP address if analytics is disabled. The reason for that change is that I was working with airplane Wifi and noticed it was extremely slow to launch a Gradio Interface because it was taking a long time to get the IP address. The real solution is to use async requests, but this is a temporary bandaid

I'll fix the remaining tests and make the requested change!

@abidlabs
Copy link
Copy Markdown
Member Author

Should be all set to merge now (cc @freddyaboulton).

Comment thread gradio/interface.py
with Column(variant="panel"):
for component in self.output_components:
component.render()
if not (isinstance(component, State)):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Out of curiosity - this was a pre-existing bug?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Originally we would unnecessarily create a second State component with the identical properties as the first. It didn't break anything, but better to avoid it imo.

@abidlabs abidlabs merged commit e5a0a5e into main Sep 28, 2022
@abidlabs abidlabs deleted the duplicate branch September 28, 2022 20:29
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.

Components/Blocks have duplicate IDs if rendered more than once

2 participants