mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-21 01:01:05 +08:00
Temporary fix to be able to load themes from Hub (#6311)
* Add code * push temporary fix for tags * temp fix * add changeset * reduce * trigger ci --------- Co-authored-by: freddyaboulton <alfonsoboulton@gmail.com> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
parent
7ab73df48e
commit
176c4d1400
5
.changeset/neat-cups-jump.md
Normal file
5
.changeset/neat-cups-jump.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"gradio": patch
|
||||
---
|
||||
|
||||
fix:Temporary fix to be able to load themes from Hub
|
@ -17,8 +17,9 @@ class ThemeAsset:
|
||||
|
||||
|
||||
def get_theme_assets(space_info: huggingface_hub.hf_api.SpaceInfo) -> list[ThemeAsset]:
|
||||
if "gradio-theme" not in getattr(space_info, "tags", []):
|
||||
raise ValueError(f"{space_info.id} is not a valid gradio-theme space!")
|
||||
# Commenting out as it seems that the `huggingface_hub` library is not parsing tags
|
||||
# if "gradio-theme" not in getattr(space_info, "tags", []):
|
||||
# raise ValueError(f"{space_info.id} is not a valid gradio-theme space!")
|
||||
|
||||
return [
|
||||
ThemeAsset(filename.rfilename)
|
||||
|
@ -18,6 +18,7 @@ test("Gallery preview mode displays all images correctly.", async ({
|
||||
test("Gallery select event returns the right value", async ({ page }) => {
|
||||
await page.getByRole("button", { name: "Run" }).click();
|
||||
await page.getByLabel("Thumbnail 2 of 3").click();
|
||||
await page.waitForTimeout(200);
|
||||
expect(await page.getByLabel("Select Data")).toHaveValue(
|
||||
"https://gradio-builds.s3.amazonaws.com/assets/lite-logo.png"
|
||||
);
|
||||
|
@ -252,17 +252,22 @@ class TestGetThemeAssets:
|
||||
assert gr.Theme._theme_version_exists(space_info, "0.1.1")
|
||||
assert not gr.Theme._theme_version_exists(space_info, "2.0.0")
|
||||
|
||||
def test_raises_if_space_not_properly_tagged(self):
|
||||
space_info = huggingface_hub.hf_api.SpaceInfo(
|
||||
id="freddyaboulton/dracula", tags=["gradio"]
|
||||
)
|
||||
@pytest.mark.flaky
|
||||
def test_load_space_from_hub_works(self):
|
||||
theme = gr.Theme.from_hub("gradio/seafoam")
|
||||
assert isinstance(theme, gr.Theme)
|
||||
|
||||
with pytest.raises(
|
||||
ValueError,
|
||||
match="freddyaboulton/dracula is not a valid gradio-theme space!",
|
||||
):
|
||||
with patch("huggingface_hub.HfApi.space_info", return_value=space_info):
|
||||
get_theme_assets(space_info)
|
||||
# def test_raises_if_space_not_properly_tagged(self):
|
||||
# space_info = huggingface_hub.hf_api.SpaceInfo(
|
||||
# id="freddyaboulton/dracula", tags=["gradio"]
|
||||
# )
|
||||
|
||||
# with pytest.raises(
|
||||
# ValueError,
|
||||
# match="freddyaboulton/dracula is not a valid gradio-theme space!",
|
||||
# ):
|
||||
# with patch("huggingface_hub.HfApi.space_info", return_value=space_info):
|
||||
# get_theme_assets(space_info)
|
||||
|
||||
|
||||
class TestBuiltInThemes:
|
||||
|
Loading…
Reference in New Issue
Block a user