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
Improve File Explorer performance #7337
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-builds.s3.amazonaws.com/712a7fd4f92f71521d324e0eb6fd0db8824638b8/gradio-4.18.0-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@712a7fd4f92f71521d324e0eb6fd0db8824638b8#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.
|
Nice! There are some bugs related to the
(Edit: it looks like @freddyaboulton has already addressed the first one.) |
…p/gradio into simplify_file_explorer
…p/gradio into simplify_file_explorer
ready for review |
Great PR @aliabid94! Everything looks good to me, just left a few nits on the code above. I also added the On the UI side, I preferred having the checkboxes next to everything, even if they weren't clickable. Now, you have this empty space, which looks odd imo: |
@@ -59,7 +58,7 @@ def __init__( | |||
value: The file (or list of files, depending on the `file_count` parameter) to show as "selected" when the component is first loaded. If a callable is provided, it will be called when the app loads to set the initial value of the component. If not provided, no files are shown as selected. | |||
file_count: Whether to allow single or multiple files to be selected. If "single", the component will return a single absolute file path as a string. If "multiple", the component will return a list of absolute file paths as a list of strings. | |||
root_dir: Path to root directory to select files from. If not provided, defaults to current working directory. | |||
ignore_glob: The glob-tyle pattern that will be used to exclude files from the list. For example, "*.py" will exclude all .py files from the list. See the Python glob documentation at https://docs.python.org/3/library/glob.html for more information. | |||
ignore_glob: The glob-style pattern that will be used to exclude files from the list. For example, "*.py" will exclude all .py files from the list. See the Python glob documentation at https://docs.python.org/3/library/glob.html for more information. | |||
label: The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to. | |||
every: If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise.sed (e.g. to cancel it) via this component's .load_event attribute. | |||
show_label: if True, will display label. |
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.
Can we properly document interactive
parameter below and fix #6627?
Yeah I liked the disabled checkboxes, they make the alignment tidier and hint more clearly that selecting the entire folder is explicitly not allowed on this app. |
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
…p/gradio into simplify_file_explorer
Thanks so much for the fix @aliabid94 ! I was just running into this issue |
Previously we would load the entire directory structure at the root directory and send that to the frontend when the fileexplorer component loaded. This could be prohibitively expensive for higher level directories to crawl through all the nested subdirectories, taking on the order of minutes to load. Now the API call only returns the content of a single level, and when opening a folder, we load the content of that folder. See gif below, showing network requests as well.
Also fixed root_dir update issue.
Fixes: #7149
Demo code to repro fix (change root_dir values ofc):