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

Add component <-> server direct communication support, as well as a "file explorer" component #5672

Merged
merged 41 commits into from Oct 5, 2023

Conversation

aliabid94
Copy link
Collaborator

@aliabid94 aliabid94 commented Sep 24, 2023

Closes: #3681

Added ability for components to directly communicate with the backend. This PR includes a basic example component HostFile that utilizes this to get the directory structure from the backend. In host_file.py we have this function:

    @server
    def ls(self, y: list[str] | None) -> tuple[list[str], list[str]] | None:
        ...
        files = []
        folders = []
        for f in os.listdir(absolute_path):
            if os.path.isfile(os.path.join(absolute_path, f)):
                files.append(f)
            else:
                folders.append(f)
        return folders, files

And then we can use this directly in our frontend component as such:

	export let server: {
		ls: (arg0: string[]) => Promise<[string[], string[]]>;
	};
        contents = await server.ls(path);

The HostFile implemented here works and was added to demonstrate how the syntax of this works. It could be extracted out as a custom component. It could also be cleaned up and properly implemented as a core component, for the purpose of having a core component that can be used as a template for a component with a server function.


@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Sep 24, 2023

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
Visual tests all good! Build review
🦄 Changes detected! Details
📓 Notebooks matching!

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/5c466fe817b638deb4a710def12947dfc37402dc/gradio-3.46.1-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@5c466fe817b638deb4a710def12947dfc37402dc#subdirectory=client/python"

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Sep 24, 2023

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/app minor
@gradio/client minor
@gradio/file minor
@gradio/fileexplorer minor
@gradio/theme minor
gradio minor
gradio_client minor

With the following changelog entry.

new FileExplorer component

Thanks to a new capability that allows components to communicate directly with the server without passing data via the value, we have created a new FileExplorer component.

This component allows you to populate the explorer by passing a glob, but only provides the selected file(s) in your prediction function.

Users can then navigate the virtual filesystem and select files which will be accessible in your predict function. This component will allow developers to build more complex spaces, with more flexible input options.

output

For more information check the FileExplorer documentation.

⚠️ The changeset file for this pull request has been modified manually, so the changeset generation bot has been disabled. To go back into automatic mode, delete the changeset file.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

@abidlabs
Copy link
Member

cc @osanseviero @apolinario who was asking for a "file explorer" type component

@osanseviero
Copy link
Contributor

cc @Wauplin for vis as well

@abidlabs abidlabs changed the title Component <-> Server direct communication support Add component <-> server direct communication support, as well as a "file explorer" component Sep 26, 2023
@julien-c
Copy link
Contributor

nice! cc @gary149 too

pngwn and others added 3 commits October 2, 2023 17:22
* start changes

* changes

* changes

* fix arrows
@pngwn
Copy link
Member

pngwn commented Oct 2, 2023

I picked this up and cleaned up the HostFile. It has now been renamed to FileExplorer and focuses only on selecting files from the FS.

API looks like this:

gr.FileExplorer(
    ["themes/utils"],
    glob="**/{components,themes}/**/*.py",
    root=absolute_path,
    ignore_glob="**/__init__.py",
    file_count="multiple"
)

Focused on globs as they are powerful for inclusion. Value is a path to select, passing a folder selects all files in that folder. When used as an input it always passes a list of absolute paths, so should be pretty easy to use. file_count can be "multiple" or "single", same as gr.File()`.

vidjjer:

Screen.Recording.2023-10-02.at.17.41.18.mov

Run demo/file_explorer to test locally.

@pngwn pngwn added the t: highlight A change that we wish to highlight label Oct 2, 2023
@pngwn
Copy link
Member

pngwn commented Oct 2, 2023

This needs a highlight.

Copy link
Member

Choose a reason for hiding this comment

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

This screenshot.gif should be removed

Copy link
Member

@abidlabs abidlabs Oct 2, 2023

Choose a reason for hiding this comment

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

Why is this file even in the gradio repo? It should be removed I think

Copy link
Member

Choose a reason for hiding this comment

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

Why is this file even in the gradio repo? It should be removed (I think it is a remnant from when we used to hardcode configs for our e2e tests)

Copy link
Member

Choose a reason for hiding this comment

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

Do we need this file?

class FileExplorer(Changeable, IOComponent, JSONSerializable):
"""
Creates a file component that allows uploading generic file (when used as an input) and or displaying generic files (output).
Preprocessing: passes the uploaded file as a {tempfile._TemporaryFileWrapper} or {List[tempfile._TemporaryFileWrapper]} depending on `file_count` (or a {bytes}/{List{bytes}} depending on `type`)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Preprocessing: passes the uploaded file as a {tempfile._TemporaryFileWrapper} or {List[tempfile._TemporaryFileWrapper]} depending on `file_count` (or a {bytes}/{List{bytes}} depending on `type`)
Preprocessing: passes the selected file as a {str} absolute path or {list[str}} depending on `file_count`

Copy link
Member

Choose a reason for hiding this comment

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

This can actually be either a file or directory and the path is relative to root. Although it should (and might already) accept an absolute path as well. I haven't tested that.

I changed to

    Preprocessing: passes the selected file or directory as a {str} path (relative to root) or {list[str}} depending on `file_count`

Copy link
Member

Choose a reason for hiding this comment

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

Supporting . will probably need some frontend changes but very simple to implement.

@abidlabs
Copy link
Member

abidlabs commented Oct 2, 2023

Tried to test this @pngwn but I'm not able to run or build the frontend. I did:

  1. pnpm i --ignore-scripts
  2. bash scripts/build_frontend.sh

But I'm seeing this error:

Failed to resolve import "dequal" from "../fileexplorer/shared/utils.ts". Does the file exist?
12:05:11 PM [vite] Internal server error: Failed to resolve import "dequal" from "../fileexplorer/shared/utils.ts". Does the file exist?

Same when trying to just run the frontend:

image

Do you have any suggestions for how to fix? I was able to go through the code changes, they generally look good, although I've suggested a few tweaks for the backend. I think we'll also need to modify the gr.load() function so that it can handle server functions. I'm happy to make the backend changes, once I can get the frontend to work properly

As an aside, a lot of untouched files have are included in this PR because they've been reformatted by prettier. Can we remove those files from this PR to make it easier to review?

@abidlabs
Copy link
Member

abidlabs commented Oct 3, 2023

Made some tweaks to client/js/src/client.ts -- now gr.load() works as well. Sample test code:

import gradio as gr

gr.load("spaces/abidlabs/file-explorer-test").launch()

All the backend issues are fixed, I think the only thing left is a better UI if there are no matching files. Other than, LGTM! Really nice stuff @pngwn

@pngwn
Copy link
Member

pngwn commented Oct 3, 2023

Will fix that empty thing and merge it in.

@abidlabs
Copy link
Member

abidlabs commented Oct 4, 2023

Oh we also need to implement an Example version of this component @pngwn

@abidlabs
Copy link
Member

abidlabs commented Oct 4, 2023

Thanks for adding the example component @pngwn! One thing I noticed is that if a single file is provided as the example, then the filename is spread out over multiple lines in the example:

import gradio as gr

demo = gr.Interface(lambda x:x,
                    gr.FileExplorer("**/*.*", root="flagged"),
                    gr.FileExplorer("**/*.*", root="flagged"),
                    examples=["log.csv"]
                   )
    
demo.launch()
image

@pngwn
Copy link
Member

pngwn commented Oct 4, 2023

Ah, I'll fix that in the morning. I forgot that a single value can be passed.

Copy link
Member

@abidlabs abidlabs left a comment

Choose a reason for hiding this comment

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

Did some more testing and that was the only issue I could find. This is really nice!

@pngwn pngwn merged commit e4a307e into main Oct 5, 2023
26 of 28 checks passed
@pngwn pngwn deleted the server_fns branch October 5, 2023 13:20
@pngwn pngwn mentioned this pull request Oct 5, 2023
freddyaboulton added a commit that referenced this pull request Oct 12, 2023
* Accessibility Improvements (#5554)

* allow remove token via keyboard

* more a11y enhancements

* upload + dataset a11y tweaks

* add changeset

* add webcam label

* improve checkbox focus styling and allow interaction via keyboard

* add changeset

* improve radio focus color

* tweak

* add radio label

* add changeset

* add annotated image alt + use button for labels

* button tweaks

* add changeset

* tweak

* more changes

* tiny tweaks

* galley / image

* label tweaks and add semantic tags to confidence

* nit + docstring

* tweak

* add changeset

* fix tests

* unit test fix

* range tweak

* fix alignment in gallery

* range tweak

* slider test tweak

* tweak

* more test fixes

* last? test tweak

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Fix secondary hue bug in gr.themes.builder() (#5660)

* fix: builder_app.py

* add changeset

* add changeset

---------

Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Improve plot rendering (#5642)

* changes

* add changeset

* changes

* changes

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com>

* Add `render_markdown` parameter to chatbot (#5604)

* disable markdown

* add changeset

* pr fixes

* format

* add changeset

* new line

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Prevent Clients from accessing API endpoints that set `api_name=False` (#5653)

* only autoscroll if user hasn't scrolled up

* docstring

* format

* client

* add changeset

* add changeset

* restore

* add changeset

* fix python client, add test

* format

* js client

* format

* add changeset

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Fix width and height issues that would cut off content in `gr.DataFrame` (#5616)

* fix dataframe height

* fix widths

* add changeset

* fixes

* format

* case

* add changeset

* dataframe docstring

* format

* fix ts

* test components

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Add the brand assets page to the website (#5643)

* Add the /brand page to the website

* add changeset

* Fix layout

* Put each logo in a different line

* fix footer

* remove unnenecessary header

* better spacing

* Add png files

* Set the size of brand-assets/gradio-logo.svg as 64x64

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: aliabd <ali.si3luwa@gmail.com>

* Fix functional tests (#5682)

* unnamed

* add changeset

* add build

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Fix small issues in docs and guides (#5669)

* Keep website guides sidebar width consistent

* add next / prev buttons to chatinterface

* add changeset

* sidebar fixes on docs

* clean iframes from guides

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* [Refactoring] Convert async functions that don't contain `await` statements to normal functions (#5677)

* [Refactoring] Convert async functions that don't contain `await` statements to normal functions

* add changeset

* add changeset

* fix tests

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Pause autoscrolling if a user scrolls up in a `gr.Textbox` and resume autoscrolling if they go all the way down (#5652)

* only autoscroll if user hasn't scrolled up

* docstring

* fixes

* add changeset

* format

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* chore(deps): update dependency @types/prismjs to v1.26.1 (#5671)

* chore(deps): update dependency @types/prismjs to v1.26.1

* add changeset

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Add `gr.on` listener method (#5639)

* changes

* changes

* changes

* changes

* changes

* add changeset

* changes

* changes

* changes

* changes

* changes

* changes

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* add query parameters to the `gr.Request` object through the `query_params` attribute (#5681)

* add queryParams to frontend request to backend

* add changeset

* update guide

* added docs

* add changeset

* fix tests

* client

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Reorganize Docs Navbar and Fill in Gaps (#5675)

* remove combining-interfaces

* reorg navbar and other changes

* better docs for error, warning, and info

* group them together

* navbar reactively update

* add changeset

* lint

* fix chatinterface test

* fix test again

* revert changes to chatinterface test

* Update gradio/helpers.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Update gradio/helpers.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Hannah <hannahblair@hotmail.co.uk>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Fix functional tests, part 2 (#5687)

* remove build

* intentionally break

* add changeset

* testing string

* change to false

* throw error

* revert break

* delete changeset

* add client js files to cache

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* setting share=True on Spaces or in wasm should warn instead of raising error (#5696)

* setting share=True on Spaces or in wasm should raise warning instead of error

* tweak

* add changeset

* lint

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Fix incorrect behavior of `gr.load()` with `gr.Examples` (#5690)

* testing

* fixes

* chat fix

* lint

* add changeset

* fix

* simplify

* simplify

* spacing

* remove print

* docstring

* dataset

* lint

* add changeset

* fix test

* add test

* added test

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Increase Slider clickable area (#5697)

* slider click area

* add changeset

* fix

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Fix blocks essay demo to use non-reserved keywords (#5698)

* fix demo

* notebook

* chore: update versions (#5596)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Fix for regression in rendering empty Markdown (#5701)

* quick fix

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* chore: update versions (#5702)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* fix: prevent internal log_message error from `/api/predict` (#5711)

* Prevent erroring on log_message from /api/predict

* add changeset

* add changeset

* add changeset

* updated docstrings

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Context-based Progress tracker (#5693)

* Context-based Progress tracker

* Lint

* add changeset

* Context-based virtual unpatch

* Avoid creating TrackedIterable if not patched

* Fix function_wrapper args

* More correct

* Add some types

* Single Progress instance to allow nested tqdms

* progress_tracker -> progress

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Fully resolve generated filepaths when running on Hugging Face Spaces with multiple replicas (#5668)

* print

* add changeset

* url

* routes

* routes

* test

* test

* add to / route

* comment

* root_url approach

* replica url

* print

* print

* test

* revert

* fixes

* changes

* replica url fix

* lint

* routes

* routes

* fix

* docstring

* add changeset

* add changeset

* add changeset

* modify in place

* add test

* unit tests

* fix copy

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Fixes gr.select() Method Issues with Dataframe Cells (#5713)

* fixes

* add changeset

* pr fixes

* fix

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Make Tab and Tabs updatable (#5714)

* fix

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* fix changelogs (#5718)

* Adds copy buttons to website, and better descriptions to API Docs (#5721)

* add missing docstring to highlightedtext

* add description to return types in api_docs

* add copy buttons to docs

* fix up descriptions for filepaths

* add copy buttons to every codeblock

* add changeset

* fix backend tests

* add changeset

* better worded descriptions

* fix color_map description

* fix formatting in code snippets

* add space

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Adjust translation (#5726)

* Adjust translation

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Hannah <hannahblair@users.noreply.github.com>

* Fix for deepcopy errors when running the replica-related logic on Spaces (#5722)

* fix changelogs

* pass

* add changeset

* test

* config

* change

* fixes

* route utils

* add changeset

* add changeset

* add lock

* print

* route url

* replicas

* replicas

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* ensure internal data has updated before dispatching `success` or `then` events (#5705)

* ensure internal data has updated before dispatching then or success events

* ensure internal data has updated before dispatching then or success events

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Add a bare `Component` type to the acceptable type list of `gr.load()`'s `inputs` and `outputs` (#5732)

* Add a bare `Component` type to the acceptable type list of `gr.load()`'s `inputs` and `outputs`

* add changeset

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com>

* chore: update versions (#5712)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Added timeout and error handling for frpc tunnel (#5731)

* added timeout and error handling for frpc tunnel

* add changeset

* lint

* typing

* spell

* tunneling

* lint

* strip

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Ensure images with no caption download in gallery (#5735)

* ensure images with no caption download in gallery

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Add design tokens to storybook (#5750)

* add design tokens to storybook

* tweak

* tweak

* visual tweaks

* add icons

* Improve chatbot accessibility and UX (#5699)

* add a11y changes and css tweaks

* add a11y changes and css tweaks

* change like/dislike/copy buttons ux

* cleanup

* add laout param

* tweak

* add changeset

* fill icon on click

* text alignment tweak

* format + test

* fix browser test

* avatar tweaks

* add stories

* tweak

* tweak

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Set share=True for all Gradio apps in Colab by default (#5767)

* Set share=True for all Gradio apps in Colab by default

* add changeset

* fix tests

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Added support for pandas `Styler` object to `gr.DataFrame` (initially just sets the `display_value`) (#5569)

* adding precision to df

* add changeset

* docstring

* precision

* add changeset

* fix

* fixes

* add changeset

* add visual test

* lint

* fixes

* lint

* format

* add changeset

* ts changes

* analytics

* dataframe typing

* typing

* demo

* fix

* lint

* interactive dataframe

* dataframe

* fix typing

* add test

* upgrade pandas version

* fix pandas version

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Don't raise warnings when returning an updated component in a dictionary (#5766)

* testing

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Fix Gallery `columns` and `rows` params (#5754)

* fix gallery params

* add changeset

* lint

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Fix new line issue in chatbot (#5755)

* fix new line

* add changeset

* line breaks param

* add changeset

* fix test

* Update gradio/components/chatbot.py

* Update gradio/components/dataframe.py

* Update gradio/components/markdown.py

* add changeset

* fix static markdown

* lint

* line breaks

* fixes

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* chore: update versions (#5742)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* add label to changeset pr (#5772)

* Always deploy to spaces (#5777)

* Lite: Websocket queueing (#5124)

* Create a Wasm-emulated WebSocket connection and fix @gradio/client to inject it

* Explicitly set the default response class for the Wasm mode

* add changeset

* Fix is_self_origin() to compare only hosts and rename it to is_self_host()

* Fix Blocks.close() to cancel async tasks in the case of Wasm and call it from wasm_utils.register_app() to dispose an old app instance

* Update comment

* Hold the asyncio.Task objects and cancel them at `Blocks.close()`

* Add try-except to handle the case where `events` is not set to `queue.active_jobs` when `queue.process_events` is called

* Format queueing.py

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* fix pending chatbot message styling and ensure messages with value `None` don't render (#5775)

* fix pending chatbot message styling

* border fixes

* add changeset

* add changeset

* ensure null messages arent shown

* add hide css again

* render loading inside message + add test

* fix test

* add changeset

* add changeset

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* change minor to patch (#5793)

* chore: update versions (#5786)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Adds `change()` event to `gr.Gallery` (#5780)

* add change event to gallery

* revert

* format

* add changeset

* lint

* add tests

* lint

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Throw helpful error when media devices are not found (#5794)

* add test

* add changeset

* tweak copy

* error logic

* add changeset

* copy tweak

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* ensure the client does not depend on `window` when running in a node environment (#5787)

* modify url_params

* add changeset

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Add component <-> server direct communication support, as well as a "file explorer" component (#5672)

* changes

* changes

* add changeset

* add changeset

* Server fns ext (#5760)

* start changes

* changes

* changes

* fix arrows

* add changeset

* rename demo

* fix some ci

* add changeset

* add changeset

* fix

* remove configs

* fix

* fix

* add changeset

* fixes

* linting

* Update gradio/components/file_explorer.py

* notebook

* typing

* tweaks

* fixed class method problem

* fix test

* file explorer

* gr.load

* format

* tweaks

* fix

* fix

* fix

* fix

* final tweaks + changelog

* changelog

* changelog

* changelog

* lint

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: pngwn <hello@pngwn.io>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Update `CONTRIBUTING.md` (#5799)

* updates

* tweak

* tweaks

* tweaks

* add troubleshooting

* storybook tweak

* add review changes

* fe tweak

* Revert replica proxy logic and instead implement using the `root` variable (#5776)

* Revert "Fix for deepcopy errors when running the replica-related logic on Spaces (#5722)"

This reverts commit dba6519.

* Revert "Fully resolve generated filepaths when running on Hugging Face Spaces with multiple replicas (#5668)"

This reverts commit d626c21.

* add changeset

* Trigger local

* add changeset

* add to root

* add changeset

* strip url

* resolve root

* changes

* fix

* format

* logs

* format

* add changeset

* reverse order

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Prevent bokeh from injecting bokeh js multiple times  (#5795)

* remove dep line in demo

* linting

* linting

* fix

* merge

* add changeset

* lint

* notebook:

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Adds the ability to set the `selected_index` in a `gr.Gallery` (#5783)

* selected_index

* Gallery

* changes

* modify

* add changeset

* fix select issue

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* added try except block in `state.py` (#5790)

* added try except block in `state.py`

added try except block in `state.py` which will raise a "ValueError"

* add changeset

* updated `state.py` and added test for deepcopy

updated `state.py` and added test for deepcopy named test_initial_value_deepcopy in `test/test_components.py`

* lint

* test fix

* explain test

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Fix `gr.SelectData` so that the target attribute is correctly attached, and the filedata is included in the data attribute with `gr.Gallery` (#5798)

* fix select

* add changeset

* add changeset

* restore

* refactor

* add pytest

* typo

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* docs: fix website directory in CONTRIBUTING.md (#5810)

* chore: update versions (#5796)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Fix calls to the component server so that `gr.FileExplorer` works on Spaces (#5816)

* changes

* add changeset

* changes

* demo

* file explorer

* lint

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* chore: update versions (#5817)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Lite: Fix Examples.create() to be a normal func so it can be called in the Wasm env (#5821)

* Fix Examples.create() to be a normal func so it can be called in the Wasm env

* add changeset

* Add a comment line

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Convert async methods in the Examples class into normal sync methods (#5822)

* Convert async methods in the Examples class into normal sync methods

* add changeset

* Fix test/test_chat_interface.py

* Fix test/test_helpers.py

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Quick fix: Chatbot change event (#5827)

* fix

* add changeset

* add dequal to dependency

* package

* lint

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Assert refactor in external.py (#5811)

* Refactored assert statements to if statements

* format-addons

* format

* add changeset

* Update gradio/external.py

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* refactored video.py

* refactored all the assert statements with response

* add changeset

* add changeset

* Apply suggestions from code review

* Refactored documentation.py and few more files

* avoid circular

* Replaced all assert statements

* lint

* notebooks

* fix

* minor changes

* final changes according to tests

* Lint

* last fix

* fix

* fix utils test

* fix serialization error

* fix serialization error

---------

Co-authored-by: harry-urek <hariombhardwaj038@gmail.com>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Fix error when scrolling dropdown with scrollbar (#5839)

* Fix error when scrolling dropdown with scrollbar

* added comment

* add changeset

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Mention that audio is normalized when converting to wav in docs (#5835)

* Mention that audio is normalized when converting to wav in docs

* add changeset

---------

Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>

* Add support for gr.Request to gr.ChatInterface (#5819)

* Add support for gr.Request to gr.ChatInterface

* add changeset

* gr.ChatInterface: loose check for gr.Request

* add request test

* update test and chat_interface

* chat interface

* fix test

* formatting

* fixes

* fix examples and add test

* remove .update usage

* revert interface changes

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* Add code

* lint

* Lint

* Radio

---------

Co-authored-by: Hannah <hannahblair@users.noreply.github.com>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Freckles <hellofreckles@163.com>
Co-authored-by: aliabid94 <aabid94@gmail.com>
Co-authored-by: Dawood Khan <dawoodkhan82@gmail.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: Yuichiro Tachibana (Tsuchiya) <t.yic.yt@gmail.com>
Co-authored-by: aliabd <ali.si3luwa@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: D V <77478658+DarhkVoyd@users.noreply.github.com>
Co-authored-by: Hannah <hannahblair@hotmail.co.uk>
Co-authored-by: pngwn <hello@pngwn.io>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Charles Bensimon <charles@huggingface.co>
Co-authored-by: ylhsieh <morpheus.h@gmail.com>
Co-authored-by: Florian Bruggisser <github@broox.ch>
Co-authored-by: gibiee <37574274+gibiee@users.noreply.github.com>
Co-authored-by: Srijan Sahay Srivastava <70461251+SrijanSahaySrivastava@users.noreply.github.com>
Co-authored-by: Regina Reynolds <regina.c.reynolds@gmail.com>
Co-authored-by: Hari Om Bhardwaj <94731227+harry-urek@users.noreply.github.com>
Co-authored-by: harry-urek <hariombhardwaj038@gmail.com>
Co-authored-by: Kit PANG <pangkit888@gmail.com>
Co-authored-by: Aileen Villanueva Lecuona <aileenvl@gmail.com>
@AnyaCoder
Copy link

import gradio as gr
import os
with gr.Blocks() as demo:
    gr.FileExplorer(
        glob="**/*.*",
        ignore_glob="**/__init__.py",
        height=500,
        root=".",
        file_count="multiple"
    )

os.environ["no_proxy"] = "localhost,127.0.0.1,0.0.0.0"

demo.launch()

The code above seems doesn't work well, please help.
image

@freddyaboulton
Copy link
Collaborator

hi @AnyaCoder ! Please create a new issue so we can take a look. Please be sure to include the gradio version you are using

@AnyaCoder
Copy link

hi @AnyaCoder ! Please create a new issue so we can take a look. Please be sure to include the gradio version you are using

thanks, my gradio version is 3.45, the problem is "It is not a directory tree", these files are listed above directly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: highlight A change that we wish to highlight
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Select a folder and then just get the filenames from that folder as a list
8 participants