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 flagged files and ensure that flagging_mode="auto" saves output components as well #7704
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-builds.s3.amazonaws.com/3c7625eb19fac7959b60abf8b65a1d319b7a82e8/gradio-4.21.0-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@3c7625eb19fac7959b60abf8b65a1d319b7a82e8#subdirectory=client/python" |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
@@ -156,9 +155,6 @@ def postprocess(self, value: tuple[str] | str | None) -> None | str: | |||
else: | |||
return value.strip() | |||
|
|||
def flag(self, payload: Any, flag_dir: str | Path = "") -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed, the base class takes care of this.
@@ -94,13 +93,6 @@ def example_payload(self) -> Any: | |||
def example_value(self) -> Any: | |||
return {"foo": "bar"} | |||
|
|||
def flag( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed anymore either, the base class takes care of this.
gradio/flagging.py
Outdated
@@ -127,8 +127,8 @@ def image_classifier(inp): | |||
Guides: using-flagging | |||
""" | |||
|
|||
def __init__(self): | |||
pass | |||
def __init__(self, simplify_files: bool = True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We add this parameter because example caching also uses this method, and there, we actually do want to keep the full file data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Tested and works well @abidlabs !
Thanks @freddyaboulton |
Components with
FileData
values were being saved in their entirety in the CSV files. This PR makes it so that only the filepaths are saved. I considered modifying theflag()
function, but that would lead to incompatibility with custom components and make it more complex for custom component developers to write their ownflag()
functions so instead I do some postprocessing after the.flag()
function has been called.Closes: #7701
Also fixed a long-standing issue where if
flagging_mode="auto"
, the output was not being saved.Closes: #3441
I set this to
minor
because although these are technically bugfixes, the behavior has been this way for such a long time, some users might see this as a breaking change.