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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading interface with examples #2640

Merged
merged 8 commits into from
Nov 15, 2022
Merged

Conversation

freddyaboulton
Copy link
Collaborator

@freddyaboulton freddyaboulton commented Nov 11, 2022

Description

Fixes #2638

Test with: https://huggingface.co/spaces/freddyaboulton/calculator. This is a space created with this PR.

image

Checklist:

  • I have performed a self-review of my own code
  • I have added a short summary of my change to the CHANGELOG.md
  • My code follows the style guidelines of this project
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

A note about the CHANGELOG

Hello 馃憢 and thank you for contributing to Gradio!

All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.

Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include
a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by [@myusername](link-to-your-github-profile) in [PR 11111](https://github.com/gradio-app/gradio/pull/11111)".

If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections.
If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the
GitHub web UI since that lets you upload files directly via drag-and-drop.

@github-actions
Copy link
Contributor

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

@freddyaboulton freddyaboulton marked this pull request as ready for review November 14, 2022 21:49
@freddyaboulton freddyaboulton requested review from abidlabs, aliabid94, aliabd, dawoodkhan82 and pngwn and removed request for abidlabs and aliabid94 November 14, 2022 22:15
@abidlabs
Copy link
Member

Thanks for creating this PR @freddyaboulton! Agreed that this would fix the issue in all new Spaces created, but this doesn't solve the bug for loading existing Spaces that have examples. I think we should fix that as well -- is that possible?

I.e. if you run

import gradio as gr

io = gr.Interface.load("spaces/abidlabs/test-calculator-2")

with this branch, it still doesn't work

@freddyaboulton
Copy link
Collaborator Author

Good point @abidlabs !

Modified Blocks.from_config to skip the "fake_event". Demo here:

fix_load

@@ -296,6 +296,8 @@ async def cache(self) -> None:
if self.batch:
output = [value[0] for value in output]
cache_logger.flag(output)
Context.root_block.dependencies.remove(dependency)
Copy link
Member

Choose a reason for hiding this comment

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

It might be good to add a comment here similar to what you added in blocks.py to explain why we're removing the dependency

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done - thanks @abidlabs !

Copy link
Member

@abidlabs abidlabs left a comment

Choose a reason for hiding this comment

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

@freddyaboulton freddyaboulton merged commit ebb65eb into main Nov 15, 2022
@freddyaboulton freddyaboulton deleted the 2638-load-with-examples branch November 15, 2022 16:21
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.

gr.Interface.load() not working if the loaded Space has examples
2 participants