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

Updating the root parameter in the fileexplorer component does not change the front-end display of the file directory. #7149

Closed
1 task done
lifeisgoodcdj opened this issue Jan 25, 2024 · 5 comments · Fixed by #7337
Assignees
Labels
bug Something isn't working Priority High priority issues

Comments

@lifeisgoodcdj
Copy link

Describe the bug

The gr.fileexplorer() object changes the root parameter when used as a callback function, but it does not actually change the root directory of the component for file searches.
I want to know how to change the root directory of gr.fileexplorer()

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

import gradio as gr

with gr.Blocks() as app:
    objFileExplorer = gr.FileExplorer(root="/home/file_path1/", show_label=True, height=400, interactive=True)
    objButtonClear = gr.Button("clear")

    @objButtonClear.click(inputs=[objFileExplorer], outputs=[objFileExplorer])
    def fnButtonClearClick(listSelectedFiles):
        print(listSelectedFiles)
        return gr.update(root="/home/file_path2/", value="", show_label=True, height=600, interactive=False)

if __name__ == "__main__":
    app.queue().launch(server_name='0.0.0.0',
                       server_port=40123,
                       share=False,
                       debug=True,
                       max_threads=2,
                       )

Screenshot

No response

Logs

No response

System Info

gradio==4.4.0

Severity

Blocking usage of gradio

@lifeisgoodcdj lifeisgoodcdj added the bug Something isn't working label Jan 25, 2024
@abidlabs
Copy link
Member

Hi @lifeisgoodcdj is this still an issue in the latest version of Gradio (4.15.0)? I believe we’ve fixed it

@lifeisgoodcdj
Copy link
Author

The issue still exists. I have tried the 4.15.0 version of gradio, but I still cannot update or switch directories actually

@abidlabs
Copy link
Member

cc @aliabid94

@abidlabs abidlabs added the Priority High priority issues label Jan 30, 2024
@liucw2012
Copy link

i also need to update root dir ~

@freddyaboulton
Copy link
Collaborator

Hi @lifeisgoodcdj - the root parameter is deprecated for the FileExplorer. If you use root_dir in both the definition of objFileExplorer and gr.update it should work. If you want to use root, you can return a new instance of gr.FileExplorer in your update function.

Going to close as this seems like a corner case with a deprecated API and fixing would require adding some component specific logic to the app-level postprocessing which would not be ideal for maintainability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Priority High priority issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants