gradio
gradio copied to clipboard
fixing issue #3178
if the first param is self, trim the param list
Description
#3178 issue When extracting params from a function, if the first param is a self parameter, the param list will contain the parameter "self". In case you do it, it'll display self as the parameter name - which is wrong (instead of image, i.e.). Little if clause, in case the param list is not empty, if the first param is 'self', trim the list.
Please include:
- relevant motivation
- a summary of the change
- which issue is fixed.
- any additional dependencies that are required for this change.
Closes: # (issue)
Checklist:
- [ v] I have performed a self-review of my own code
- [x] I have added a short summary of my change to the CHANGELOG.md
- [ v] My code follows the style guidelines of this project
- [ v] I have commented my code in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [ ] I have added tests that prove my fix is effective or that my feature works
- [x] 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.
All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-3227-all-demos
Thanks for the PR @or25! We'll take a look at it and share our feedback, likely early next week
Hi @or25 thanks for making this PR! Instead of checking to see if "self" is the name of the first parameter, which is not that precise (since a regular function could have a parameter called "self"), I would check to see if the function is an instance method. You can use inspect.ismethod
for that, as described here: https://stackoverflow.com/a/1260997/5209347
Would you be able to update your PR to use this function? I would also add a test to make sure this works as expected. The best place to add this test would be in test/test_interface.py
.
Thank you!
Hi @or25 as in PR #3231, we can lend a hand to get this PR completed
Just made a tweak and added some tests. This PR should be good to go, if anyone wants to take a quick look at it @freddyaboulton @aliabid94 @dawoodkhan82
Thanks @or25 for your contribution!