Skip to content

Commit

Permalink
Merge branch 'main' into 3495-jsclient-node
Browse files Browse the repository at this point in the history
  • Loading branch information
pngwn authored Mar 29, 2023
2 parents c29d7c5 + df98c44 commit cce146c
Show file tree
Hide file tree
Showing 15 changed files with 219 additions and 27 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,49 @@ env:
NODE_OPTIONS: "--max-old-space-size=4096"

jobs:
client-test:
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest"]
python-version: ["3.9"]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: client/python
steps:
- uses: actions/checkout@v3
- name: Cache python deps
id: cache-python
uses: actions/cache@v3
with:
path: ./venv
key: pythondeps-${{ matrix.python-version }}-${{ github.ref }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('test/requirements.txt') }}
- name: Install Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install pip
run: python -m pip install build requests virtualenv
- name: venv activate Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
python -m virtualenv venv
source venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
- name: venv activate Windows
if: ${{ matrix.os == 'windows-latest' }}
run: |
python -m virtualenv venv
./venv/Scripts/Activate.ps1
echo "PATH=$env:PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Install Client
run: |
pip install -e .
pip install -r test/requirements.txt
- name: Tests
shell: bash
run: |
bash scripts/ci.sh
test:
strategy:
matrix:
Expand Down
17 changes: 11 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@
- Fixed bug where text for altair plots was not legible in dark mode by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3555](https://github.com/gradio-app/gradio/pull/3555)
- Fixes `Chatbot` and `Image` components so that files passed during processing are added to a directory where they can be served from, by [@abidlabs](https://github.com/abidlabs) in [PR 3523](https://github.com/gradio-app/gradio/pull/3523)
- Use Gradio API server to send telemetry using `huggingface_hub` [@dawoodkhan82](https://github.com/dawoodkhan82) in [PR 3488](https://github.com/gradio-app/gradio/pull/3488)
- Fixes an issue where if the Blocks scope was not exited, then State could be shared across sessions, by [@abidlabs](https://github.com/abidlabs) in [PR 3600](https://github.com/gradio-app/gradio/pull/3600)
- Fixes an an issue where if the Blocks scope was not exited, then State could be shared across sessions, by [@abidlabs](https://github.com/abidlabs) in [PR 3600](https://github.com/gradio-app/gradio/pull/3600)
- Ensures that `gr.load()` loads and applies the upstream theme, by [@abidlabs](https://github.com/abidlabs) in [PR 3641](https://github.com/gradio-app/gradio/pull/3641)
- Fixed bug where "or" was not being localized in file upload text by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3599](https://github.com/gradio-app/gradio/pull/3599)
- Fixed bug where chatbot does not autoscroll inside of a tab, row or column by [@dawoodkhan82](https://github.com/dawoodkhan82) in [PR 3637](https://github.com/gradio-app/gradio/pull/3637)
- Fixed bug where textbox shrinks when `lines` set to larger than 20 by [@dawoodkhan82](https://github.com/dawoodkhan82) in [PR 3637](https://github.com/gradio-app/gradio/pull/3637)
- Ensure CSS has fully loaded before rendering the application, by [@pngwn](https://github.com/pngwn) in [PR 3573](https://github.com/gradio-app/gradio/pull/3573)
- Support using an empty list as `gr.Dataframe` value, by [@space-nuko](https://github.com/space-nuko) in [PR 3646](https://github.com/gradio-app/gradio/pull/3646)
- Correct the documentation of `gr.File` component to state that its preprocessing method converts the uploaded file to a temporary file, by @RussellLuo in [PR 3660](https://github.com/gradio-app/gradio/pull/3660)
- Fixed bug in Serializer ValueError text by [@osanseviero](https://github.com/osanseviero) in [PR 3669](https://github.com/gradio-app/gradio/pull/3669)
- Fix default parameter argument and `gr.Progress` used in same function, by [@space-nuko](https://github.com/space-nuko) in [PR 3671](https://github.com/gradio-app/gradio/pull/3671)
- Hide `Remove All` button in `gr.Dropdown` single-select mode by [@space-nuko](https://github.com/space-nuko) in [PR 3678](https://github.com/gradio-app/gradio/pull/3678)

## Documentation Changes:

Expand All @@ -36,11 +40,12 @@ No changes to highlight.

## Full Changelog:

* Mobile responsive iframes in themes guide by [@aliabd](https://github.com/aliabd) in [PR 3562](https://github.com/gradio-app/gradio/pull/3562)
* Remove extra $demo from theme guide by [@aliabd](https://github.com/aliabd) in [PR 3563](https://github.com/gradio-app/gradio/pull/3563)
* Set the theme name to be the upstream repo name when loading from the hub by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3595](https://github.com/gradio-app/gradio/pull/3595)
* Copy everything in website Dockerfile, fix build issues by [@aliabd](https://github.com/aliabd) in [PR 3659](https://github.com/gradio-app/gradio/pull/3659)
* Raise error when an event is queued but the queue is not configured by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3640](https://github.com/gradio-app/gradio/pull/3640)
- Mobile responsive iframes in themes guide by [@aliabd](https://github.com/aliabd) in [PR 3562](https://github.com/gradio-app/gradio/pull/3562)
- Remove extra $demo from theme guide by [@aliabd](https://github.com/aliabd) in [PR 3563](https://github.com/gradio-app/gradio/pull/3563)
- Set the theme name to be the upstream repo name when loading from the hub by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3595](https://github.com/gradio-app/gradio/pull/3595)
- Copy everything in website Dockerfile, fix build issues by [@aliabd](https://github.com/aliabd) in [PR 3659](https://github.com/gradio-app/gradio/pull/3659)
- Raise error when an event is queued but the queue is not configured by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 3640](https://github.com/gradio-app/gradio/pull/3640)
- Allows users to apss in a string name for a built-in theme, by [@abidlabs](https://github.com/abidlabs) in [PR 3641](https://github.com/gradio-app/gradio/pull/3641)


## Contributors Shoutout:
Expand Down
2 changes: 1 addition & 1 deletion client/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ job.result()

If you already have a recent version of `gradio`, then the `gradio_client` is included as a dependency.

Otherwise, the lightweight `gradio_client` package can be installed from pip (or pip3) and works with Python versions 3.7 or higher:
Otherwise, the lightweight `gradio_client` package can be installed from pip (or pip3) and works with Python versions 3.9 or higher:

```bash
$ pip install gradio_client
Expand Down
5 changes: 3 additions & 2 deletions client/python/gradio_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
import huggingface_hub
import requests
import websockets
from gradio_client import serializing, utils
from gradio_client.serializing import Serializable
from huggingface_hub.utils import build_hf_headers, send_telemetry
from packaging import version

from gradio_client import serializing, utils
from gradio_client.serializing import Serializable


class Client:
def __init__(
Expand Down
2 changes: 1 addition & 1 deletion client/python/gradio_client/serializing.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def deserialize(
file_name = utils.decode_base64_to_file(x["data"], dir=save_dir).name
else:
raise ValueError(
f"A FileSerializable component cannot only deserialize a string or a dict, not a: {type(x)}"
f"A FileSerializable component can only deserialize a string or a dict, not a: {type(x)}"
)
return file_name

Expand Down
2 changes: 1 addition & 1 deletion client/python/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ requests
websockets
packaging
fsspec
huggingface_hub>=0.13.0
huggingface_hub>=0.13.0
4 changes: 4 additions & 0 deletions client/python/test/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def pytest_configure(config):
config.addinivalue_line(
"markers", "flaky: mark test as flaky. Failure will not cause te"
)
6 changes: 6 additions & 0 deletions client/python/test/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
black==22.6.0
flake8==4.0.1
isort==5.10.1
pytest==7.1.2
gradio>=3.23.0
pytest-asyncio
38 changes: 24 additions & 14 deletions gradio/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@

from gradio.components import Component

BUILT_IN_THEMES: Dict[str, Theme] = {
t.name: t
for t in [
themes.Base(),
themes.Default(),
themes.Monochrome(),
themes.Soft(),
themes.Glass(),
]
}


class Block:
def __init__(
Expand Down Expand Up @@ -495,6 +506,7 @@ def __init__(
):
"""
Parameters:
theme: a Theme object or a string representing a theme. If a string, will look for a built-in theme with that name (e.g. "soft" or "default"), or will attempt to load a theme from the HF Hub (e.g. "gradio/monochrome"). If None, will use the Default theme.
analytics_enabled: whether to allow basic telemetry. If None, will use GRADIO_ANALYTICS_ENABLED environment variable or default to True.
mode: a human-friendly name for the kind of Blocks or Interface being created.
title: The tab title to display when this is opened in a browser window.
Expand All @@ -506,11 +518,14 @@ def __init__(
if theme is None:
theme = DefaultTheme()
elif isinstance(theme, str):
try:
theme = Theme.from_hub(theme)
except Exception as e:
warnings.warn(f"Cannot load {theme}. Caught Exception: {str(e)}")
theme = DefaultTheme()
if theme.lower() in BUILT_IN_THEMES:
theme = BUILT_IN_THEMES[theme.lower()]
else:
try:
theme = Theme.from_hub(theme)
except Exception as e:
warnings.warn(f"Cannot load {theme}. Caught Exception: {str(e)}")
theme = DefaultTheme()
if not isinstance(theme, Theme):
warnings.warn("Theme should be a class loaded from gradio.themes")
theme = DefaultTheme()
Expand Down Expand Up @@ -570,16 +585,9 @@ def __init__(
self.file_directories = []

if self.analytics_enabled:
built_in_themes = [
themes.Base(),
themes.Default(),
themes.Monochrome(),
themes.Soft(),
themes.Glass(),
]
is_custom_theme = not any(
self.theme.to_dict() == built_in_theme.to_dict()
for built_in_theme in built_in_themes
for built_in_theme in BUILT_IN_THEMES.values()
)
data = {
"mode": self.mode,
Expand Down Expand Up @@ -607,6 +615,7 @@ def from_config(
"""
config = copy.deepcopy(config)
components_config = config["components"]
theme = config.get("theme", "default")
original_mapping: Dict[int, Block] = {}

def get_block_instance(id: int) -> Block:
Expand Down Expand Up @@ -644,7 +653,7 @@ def iterate_over_children(children_list):

derived_fields = ["types"]

with Blocks() as blocks:
with Blocks(theme=theme) as blocks:
# ID 0 should be the root Blocks component
original_mapping[0] = Context.root_block or blocks

Expand Down Expand Up @@ -1138,6 +1147,7 @@ def get_config_file(self):
"is_colab": utils.colab_check(),
"stylesheets": self.stylesheets,
"root": self.root,
"theme": self.theme.name,
}

def getLayout(block):
Expand Down
3 changes: 3 additions & 0 deletions gradio/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,9 @@ def special_args(
event_data_index = i
if inputs is not None and event_data is not None:
inputs.insert(i, param.annotation(event_data.target, event_data._data))
elif param.default is not param.empty:
if inputs is not None and len(inputs) <= i:
inputs.insert(i, param.default)
if inputs is not None:
while len(inputs) < len(positional_args):
i = len(inputs)
Expand Down
3 changes: 3 additions & 0 deletions gradio/test_data/blocks_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"mode": "blocks",
"dev_mode": True,
"analytics_enabled": False,
"theme": "default",
"components": [
{
"id": 1,
Expand Down Expand Up @@ -260,6 +261,7 @@
"mode": "blocks",
"dev_mode": True,
"analytics_enabled": False,
"theme": "default",
"components": [
{
"id": 1,
Expand Down Expand Up @@ -516,6 +518,7 @@
"mode": "blocks",
"dev_mode": True,
"analytics_enabled": False,
"theme": "default",
"components": [
{
"id": 1,
Expand Down
2 changes: 1 addition & 1 deletion gradio/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.23.1b1
3.23.1b3
6 changes: 5 additions & 1 deletion js/form/src/Dropdown.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
on:keyup={handleKeyup}
/>
<div
class:hide={!value?.length || disabled}
class:hide={!multiselect || !value?.length || disabled}
class="token-remove remove-all"
title="Remove All"
on:click={remove_all}
Expand Down Expand Up @@ -281,4 +281,8 @@
width: 20px;
height: 20px;
}
.hide {
display: none;
}
</style>
Loading

0 comments on commit cce146c

Please sign in to comment.