Skip to content

Commit

Permalink
Fix all demos custom components (#5555)
Browse files Browse the repository at this point in the history
* Fix all_demos

* Fix issues
  • Loading branch information
freddyaboulton authored Sep 14, 2023
1 parent 5ae1f03 commit 0fbf03e
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches:
- main
- v4

jobs:
comment-spaces-start:
Expand Down
1 change: 0 additions & 1 deletion demo/kitchen_sink_random/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
)
),
gr.State(value=lambda: random.choice(string.ascii_lowercase)),
gr.Button(value=lambda: random.choice(["Run", "Go", "predict"])),
gr.ColorPicker(value=lambda: random.choice(["#000000", "#ff0000", "#0000FF"])),
gr.Label(value=lambda: random.choice(["Pedestrian", "Car", "Cyclist"])),
gr.HighlightedText(
Expand Down
2 changes: 1 addition & 1 deletion gradio/components/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def get_config(self):
}
if self.info:
config["info"] = self.info
config["custom_component"] = not self.__module__.startswith("gradio.components")
config["custom_component"] = not self.__module__.startswith("gradio")
return config

@property
Expand Down
3 changes: 0 additions & 3 deletions gradio/components/clear_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from gradio_client.documentation import document, set_documentation_group

from gradio.components import Button, Component
from gradio.data_classes import GradioModel, GradioRootModel

set_documentation_group("component")

Expand Down Expand Up @@ -71,8 +70,6 @@ def add(self, components: None | Component | list[Component]) -> ClearButton:
none_values = []
for component in components:
none = component.postprocess(None)
if isinstance(none, (GradioModel, GradioRootModel)):
none = none.model_dump()
none_values.append(none)
clear_values = json.dumps(none_values)
self.click(None, [], components, _js=f"() => {clear_values}")
Expand Down
2 changes: 1 addition & 1 deletion gradio/components/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def __init__(
[datatype] * self.col_count[0] if isinstance(datatype, str) else datatype
)
self.empty_input = {
"headers": ["a"],
"headers": ["a", "b", "c"],
"data": [
[values[c] for c in column_dtypes] for _ in range(self.row_count[0])
],
Expand Down
2 changes: 1 addition & 1 deletion gradio/components/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def preprocess(

def postprocess(
self, y: np.ndarray | _Image.Image | str | Path | None
) -> str | None:
) -> FileData | str | None:
"""
Parameters:
y: image as a numpy array, PIL Image, string/Path filepath, or string URL
Expand Down
5 changes: 4 additions & 1 deletion gradio/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def __init__(
allow_flagging: str | None = None,
flagging_options: list[str] | list[tuple[str, str]] | None = None,
flagging_dir: str = "flagged",
flagging_callback: FlaggingCallback = CSVLogger(),
flagging_callback: FlaggingCallback | None = None,
analytics_enabled: bool | None = None,
batch: bool = False,
max_batch_size: int = 4,
Expand Down Expand Up @@ -356,8 +356,11 @@ def __init__(
"flagging_options must be a list of strings or list of (string, string) tuples."
)

if not flagging_callback:
flagging_callback = CSVLogger()
self.flagging_callback = flagging_callback
self.flagging_dir = flagging_dir

self.batch = batch
self.max_batch_size = max_batch_size
self.allow_duplication = allow_duplication
Expand Down

0 comments on commit 0fbf03e

Please sign in to comment.