Skip to content

Commit

Permalink
Merge branch 'main' into asynchat
Browse files Browse the repository at this point in the history
  • Loading branch information
abidlabs committed Aug 8, 2023
2 parents e961fa8 + eaa1ce1 commit a6b47fd
Show file tree
Hide file tree
Showing 27 changed files with 245 additions and 19,738 deletions.
6 changes: 6 additions & 0 deletions .changeset/early-bees-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/client": patch
"gradio": patch
---

feat:Update dependency esbuild to ^0.19.0
6 changes: 6 additions & 0 deletions .changeset/fluffy-ties-sink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/colorpicker": patch
"gradio": patch
---

fix:Add `interactive` args to `gr.ColorPicker`
4 changes: 4 additions & 0 deletions .changeset/gold-radios-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

fix:Update typing info for `gr.CheckboxGroup` and `gr.Radio`
6 changes: 6 additions & 0 deletions .changeset/good-years-ask.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/textbox": patch
"gradio": patch
---

fix:Reset textbox value to empty string when value is None
5 changes: 5 additions & 0 deletions .changeset/true-camels-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gradio": minor
---

fix:[Spaces] ZeroGPU Queue fix
6 changes: 6 additions & 0 deletions .changeset/two-beers-pick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/app": minor
"gradio": minor
---

feat:Enhancing Tamil Translation: Language Refinement 🌟
6 changes: 6 additions & 0 deletions .changeset/wise-cooks-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"gradio": patch
"website": patch
---

fix:Add icon and link to DuplicateButton
2 changes: 1 addition & 1 deletion client/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"devDependencies": {
"@types/ws": "^8.5.4",
"esbuild": "^0.18.0"
"esbuild": "^0.19.0"
},
"scripts": {
"bundle": "vite build --ssr",
Expand Down
8 changes: 6 additions & 2 deletions gradio/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
TupleNoPrint,
check_function_inputs_match,
component_or_layout_class,
concurrency_count_warning,
delete_none,
get_cancel_function,
get_continuous_fn,
Expand Down Expand Up @@ -1583,6 +1584,7 @@ def clear(self):
self.children = []
return self

@concurrency_count_warning
@document()
def queue(
self,
Expand Down Expand Up @@ -1624,12 +1626,14 @@ def queue(
warn_deprecation(
"The client_position_to_load_data parameter is deprecated."
)
max_size_default = self.max_threads if utils.is_zero_gpu_space() else None
if utils.is_zero_gpu_space():
concurrency_count = self.max_threads
max_size = 1 if max_size is None else max_size
self._queue = queueing.Queue(
live_updates=status_update_rate == "auto",
concurrency_count=concurrency_count,
update_intervals=status_update_rate if status_update_rate != "auto" else 1,
max_size=max_size_default if max_size is None else max_size,
max_size=max_size,
blocks_dependencies=self.dependencies,
)
self.config = self.get_config_file()
Expand Down
22 changes: 12 additions & 10 deletions gradio/components/checkboxgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ class CheckboxGroup(
):
"""
Creates a set of checkboxes of which a subset can be checked.
Preprocessing: passes the list of checked checkboxes as a {List[str]} or their indices as a {List[int]} into the function, depending on `type`.
Postprocessing: expects a {List[str]}, each element of which becomes a checked checkbox.
Examples-format: a {List[str]} representing the values to be checked.
Preprocessing: passes the list of checked checkboxes as a {List[str | int | float]} or their indices as a {List[int]} into the function, depending on `type`.
Postprocessing: expects a {List[str | int | float]}, each element of which becomes a checked checkbox.
Examples-format: a {List[str | int | float]} representing the values to be checked.
Demos: sentence_builder, titanic_survival
"""

def __init__(
self,
choices: list[str] | None = None,
choices: list[str | float | int] | None = None,
*,
value: list[str] | str | Callable | None = None,
value: list[str | float | int] | str | float | int | Callable | None = None,
type: Literal["value", "index"] = "value",
label: str | None = None,
info: str | None = None,
Expand All @@ -54,8 +54,8 @@ def __init__(
):
"""
Parameters:
choices: list of options to select from.
value: default selected list of options. If callable, the function will be called whenever the app loads to set the initial value of the component.
choices: list of (string or numeric) options to select from.
value: default selected list of options. If a single choice is selected, it can be passed in as a string or numeric type. If callable, the function will be called whenever the app loads to set the initial value of the component.
type: Type of value to be returned by component. "value" returns the list of strings of the choices selected, "index" returns the list of indices of the choices selected.
label: component name in interface.
info: additional component description.
Expand Down Expand Up @@ -115,7 +115,7 @@ def example_inputs(self) -> dict[str, Any]:

@staticmethod
def update(
value: list[str]
value: list[str | int | float]
| str
| Literal[_Keywords.NO_VALUE]
| None = _Keywords.NO_VALUE,
Expand Down Expand Up @@ -143,7 +143,7 @@ def update(
"__type__": "update",
}

def preprocess(self, x: list[str]) -> list[str] | list[int]:
def preprocess(self, x: list[str | int | float]) -> list[str | int | float]:
"""
Parameters:
x: list of selected choices
Expand All @@ -159,7 +159,9 @@ def preprocess(self, x: list[str]) -> list[str] | list[int]:
f"Unknown type: {self.type}. Please choose from: 'value', 'index'."
)

def postprocess(self, y: list[str] | str | None) -> list[str]:
def postprocess(
self, y: list[str | int | float] | str | int | float | None
) -> list[str | int | float]:
"""
Any postprocessing needed to be performed on function output.
Parameters:
Expand Down
18 changes: 18 additions & 0 deletions gradio/components/duplicate_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def __init__(
value: str = "Duplicate Space",
variant: Literal["primary", "secondary", "stop"] = "secondary",
size: Literal["sm", "lg"] | None = "sm",
icon: str | None = None,
link: str | None = None,
visible: bool = True,
interactive: bool = True,
elem_id: str | None = None,
Expand All @@ -37,10 +39,26 @@ def __init__(
_activate: bool = True,
**kwargs,
):
"""
Parameters:
value: Default text for the button to display. If callable, the function will be called whenever the app loads to set the initial value of the component.
variant: 'primary' for main call-to-action, 'secondary' for a more subdued style, 'stop' for a stop button.
size: Size of the button. Can be "sm" or "lg".
icon: URL or path to the icon file to display within the button. If None, no icon will be displayed.
link: URL to open when the button is clicked. If None, no link will be used.
visible: If False, component will be hidden.
interactive: If False, the Button will be in a disabled state.
elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
elem_classes: An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
scale: relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.
min_width: minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.
"""
super().__init__(
value,
variant=variant,
size=size,
icon=icon,
link=link,
visible=visible,
interactive=interactive,
elem_id=elem_id,
Expand Down
20 changes: 12 additions & 8 deletions gradio/components/radio.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ class Radio(
NeighborInterpretable,
):
"""
Creates a set of radio buttons of which only one can be selected.
Preprocessing: passes the value of the selected radio button as a {str} or its index as an {int} into the function, depending on `type`.
Postprocessing: expects a {str} corresponding to the value of the radio button to be selected.
Creates a set of (string or numeric type) radio buttons of which only one can be selected.
Preprocessing: passes the value of the selected radio button as a {str} or {int} or {float} or its index as an {int} into the function, depending on `type`.
Postprocessing: expects a {str} or {int} or {float} corresponding to the value of the radio button to be selected.
Examples-format: a {str} representing the radio option to select.
Demos: sentence_builder, titanic_survival, blocks_essay
"""

def __init__(
self,
choices: list[str] | None = None,
choices: list[str | int | float] | None = None,
*,
value: str | Callable | None = None,
value: str | int | float | Callable | None = None,
type: str = "value",
label: str | None = None,
info: str | None = None,
Expand Down Expand Up @@ -116,8 +116,12 @@ def example_inputs(self) -> dict[str, Any]:

@staticmethod
def update(
value: Any | Literal[_Keywords.NO_VALUE] | None = _Keywords.NO_VALUE,
choices: list[str] | None = None,
value: str
| int
| float
| Literal[_Keywords.NO_VALUE]
| None = _Keywords.NO_VALUE,
choices: list[str | int | float] | None = None,
label: str | None = None,
info: str | None = None,
show_label: bool | None = None,
Expand All @@ -141,7 +145,7 @@ def update(
"__type__": "update",
}

def preprocess(self, x: str | None) -> str | int | None:
def preprocess(self, x: str | int | float | None) -> str | int | float | None:
"""
Parameters:
x: selected choice
Expand Down
19 changes: 19 additions & 0 deletions gradio/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from mdit_py_plugins.dollarmath.index import dollarmath_plugin
from mdit_py_plugins.footnote.index import footnote_plugin
from pydantic import BaseModel, parse_obj_as
from typing_extensions import ParamSpec

import gradio
from gradio.context import Context
Expand All @@ -53,6 +54,7 @@
(pkgutil.get_data(__name__, "version.txt") or b"").decode("ascii").strip()
)

P = ParamSpec("P")
T = TypeVar("T")


Expand Down Expand Up @@ -843,6 +845,23 @@ def check_function_inputs_match(fn: Callable, inputs: list, inputs_as_dict: bool
)


def concurrency_count_warning(queue: Callable[P, T]) -> Callable[P, T]:
@functools.wraps(queue)
def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
_self, *positional = args
if is_zero_gpu_space() and (
len(positional) >= 1 or "concurrency_count" in kwargs
):
warnings.warn(
"Queue concurrency_count on ZeroGPU Spaces cannot be overriden "
"and is always equal to Block's max_threads. "
"Consider setting max_threads value on the Block instead"
)
return queue(*args, **kwargs)

return wrapper


class TupleNoPrint(tuple):
# To remove printing function return in notebook
def __repr__(self):
Expand Down
4 changes: 1 addition & 3 deletions js/_website/src/routes/changelog/changelog.json

Large diffs are not rendered by default.

0 comments on commit a6b47fd

Please sign in to comment.