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

Editable gr.JSON component #10156

Open
1 task done
anirbanbasu opened this issue Dec 8, 2024 · 0 comments
Open
1 task done

Editable gr.JSON component #10156

anirbanbasu opened this issue Dec 8, 2024 · 0 comments
Labels
enhancement New feature or request needs designing The proposed feature needs to be discussed and designed before being implemented

Comments

@anirbanbasu
Copy link
Contributor

  • I have searched to see if a similar issue already exists.

Is your feature request related to a problem? Please describe.
I frequently use the gr.JSON component to display data dictionaries and JSON (as text). However, the component does not allow editing the dictionary that the component displays. The capability to edit may be desirable in some use-cases.

For example, while a gr.Dataframe component can render a Polars data frame and even allows it to be edited, the Polars dataframe may contain the data type Struct. This type of data is best rendered through the gr.JSON component, when viewed per row. Editing the Polars data frame then necessitates editing the rendered JSON for columns that Polars parses as Struct.

Describe the solution you'd like
I do not have a well thought out solution to this. I think one clear problem will be data validation.

One solution (to data validation) could be to detect the data type of every dictionary key and and its corresponding value (excluding nested tuples, lists and dictionaries) and typecast the newly edited data to the detected data type. On the other hand, if the dictionary being displayed is the output (i.e., model_dump) of a Pydantic model then use the Pydantic validator to depend on any complex validation that needs to take place on the edited data.

Additional context
Check the "Dataset" tab at https://huggingface.co/spaces/anirbanbasu/gradio-experiments. Try to upload some data as CSV, JSON or Parquet to render it as a Polars dataframe. Click any row of the displayed data frame to see the row rendered as JSON. he The ability to edit the data through the JSON component ensures that it can still be edited even if columns of the data frame are not simple types.

@abidlabs abidlabs added enhancement New feature or request needs designing The proposed feature needs to be discussed and designed before being implemented labels Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs designing The proposed feature needs to be discussed and designed before being implemented
Projects
None yet
Development

No branches or pull requests

2 participants