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

Support gr.Progress() in python client #3924

Merged
merged 7 commits into from
Apr 24, 2023

Conversation

freddyaboulton
Copy link
Collaborator

Description

There was a bug where progress updates via gr.Progress were causing the client to crash. This PR adds the correct parsing to the progress messages so that they can be accessed via job.status().progress_data

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.

@gradio-pr-bot
Copy link
Collaborator

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

statuses.append(job.status())
time.sleep(0.05)
assert any(s.code == Status.PROGRESS for s in statuses)
assert any(s.progress_data is not None for s in statuses)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: can we make this test more speicific? E.g. assert something like the

any(s.progress_data == ProgressUnit(index=19, length=20, unit="steps", progress=None, desc=None) for s in statuses)

It will help readers of the codebase understand the expected format of the progress data

@abidlabs
Copy link
Member

abidlabs commented Apr 24, 2023

Nice fix @freddyaboulton! This LGTM. I would just add some more documentation around the .progress_data attribute and its expected format, for example in the docstring of .status() method

And I would add a test for a difference Space which doesn't have a progress bar, asserting that the .progress_data attribute is None.

@freddyaboulton freddyaboulton force-pushed the fix-progress-tracking-for-client branch from 23ab7e2 to 5f61548 Compare April 24, 2023 15:17
@freddyaboulton
Copy link
Collaborator Author

Thanks for the review and helpful comments @abidlabs !

Pushed both of those changes up and will fix after CI

@freddyaboulton freddyaboulton force-pushed the fix-progress-tracking-for-client branch from ae70d16 to a11af11 Compare April 24, 2023 16:03
@freddyaboulton freddyaboulton merged commit d835c9a into main Apr 24, 2023
@freddyaboulton freddyaboulton deleted the fix-progress-tracking-for-client branch April 24, 2023 16:52
@pngwn pngwn mentioned this pull request Jul 26, 2023
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.

3 participants