From 81ae7663b303ac7738bc216d9bf916f0515dd22e Mon Sep 17 00:00:00 2001 From: Ali Abdalla Date: Wed, 12 Jun 2024 11:15:09 -0700 Subject: [PATCH] Many small fixes to website and docs (#8537) * change banner * replace Sequence with list * fix capitilization issues in nav * fix demo for gr.Examples * show respective install from main commands for clients * only upload versioned demos on a new version release * formatting * add changeset * add changeset --------- Co-authored-by: gradio-pr-bot --- .changeset/true-places-post.md | 6 ++++++ gradio/helpers.py | 2 +- js/_website/generate_jsons/generate.py | 7 ++++++- js/_website/generate_jsons/src/docs/__init__.py | 6 ++++++ js/_website/src/lib/components/DocsNav.svelte | 2 -- .../src/lib/components/EventListeners.svelte | 5 ++++- .../src/lib/components/FunctionDoc.svelte | 4 +++- js/_website/src/lib/components/Header.svelte | 16 ++++++---------- js/_website/src/lib/components/ParamTable.svelte | 2 +- .../routes/[[version]]/docs/+layout.server.ts | 2 -- .../[[version]]/docs/gradio/[doc]/+page.svelte | 5 +++-- .../[[version]]/docs/js-client/+page.server.ts | 3 ++- .../[[version]]/docs/js-client/+page.svelte | 15 +++++++++++++++ .../docs/python-client/[doc]/+page.svelte | 14 ++++++-------- scripts/upload_website_demos.py | 4 ++-- 15 files changed, 61 insertions(+), 32 deletions(-) create mode 100644 .changeset/true-places-post.md diff --git a/.changeset/true-places-post.md b/.changeset/true-places-post.md new file mode 100644 index 0000000000..fa52b077e2 --- /dev/null +++ b/.changeset/true-places-post.md @@ -0,0 +1,6 @@ +--- +"gradio": patch +"website": patch +--- + +fix:Many small fixes to website and docs diff --git a/gradio/helpers.py b/gradio/helpers.py index c00c24da8a..0df85af994 100644 --- a/gradio/helpers.py +++ b/gradio/helpers.py @@ -83,7 +83,7 @@ class Examples: assigns event listener so that clicking on an example populates the input/output components. Optionally handles example caching for fast inference. - Demos: fake_gan + Demos: calculator_blocks Guides: more-on-examples-and-flagging, using-hugging-face-integrations, image-classification-in-pytorch, image-classification-in-tensorflow, image-classification-with-vision-transformers, create-your-own-friends-with-a-gan """ diff --git a/js/_website/generate_jsons/generate.py b/js/_website/generate_jsons/generate.py index a43a0c5c1f..ed153fefab 100644 --- a/js/_website/generate_jsons/generate.py +++ b/js/_website/generate_jsons/generate.py @@ -9,6 +9,7 @@ from src import changelog, demos, docs, guides WEBSITE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) GRADIO_DIR = os.path.abspath(os.path.join(WEBSITE_DIR, "..", "..", "gradio")) +ROOT_DIR = os.path.abspath(os.path.join(WEBSITE_DIR, "..", "..")) def make_dir(root, path): return os.path.abspath(os.path.join(root, path)) @@ -26,6 +27,8 @@ def download_from_s3(bucket_name, s3_folder, local_dir): def get_latest_release(): + with open(make_dir(ROOT_DIR, "client/js/package.json")) as f: + js_client_version = json.load(f)["version"] with open(make_dir(GRADIO_DIR, "package.json")) as f: version = json.load(f)["version"] with open(make_dir(WEBSITE_DIR, "src/lib/json/version.json"), "w+") as j: @@ -35,7 +38,9 @@ def get_latest_release(): with open(make_dir(WEBSITE_DIR, "src/lib/json/wheel.json"), "w+") as j: sha = run(["git", "log", "-1", "--format='%H'"], capture_output=True).stdout.decode("utf-8").strip("'\n") json.dump({ - "wheel": f"https://gradio-builds.s3.amazonaws.com/{sha}/gradio-{version}-py3-none-any.whl" + "gradio_install": f"pip install https://gradio-builds.s3.amazonaws.com/{sha}/gradio-{version}-py3-none-any.whl", + "gradio_py_client_install": f"pip install 'gradio-client @ git+https://github.com/gradio-app/gradio@{sha}#subdirectory=client/python'", + "gradio_js_client_install": f"npm install https://gradio-builds.s3.amazonaws.com/{sha}/gradio-client-{js_client_version}.tgz", }, j) if not os.path.exists(make_dir(WEBSITE_DIR, f"src/lib/templates_{version.replace('.', '-')}")): download_from_s3("gradio-docs-json", f"{version}/templates/", make_dir(WEBSITE_DIR, f"src/lib/templates_{version.replace('.', '-')}")) diff --git a/js/_website/generate_jsons/src/docs/__init__.py b/js/_website/generate_jsons/src/docs/__init__.py index a88db9e5e4..3f092c4b47 100644 --- a/js/_website/generate_jsons/src/docs/__init__.py +++ b/js/_website/generate_jsons/src/docs/__init__.py @@ -183,6 +183,12 @@ def organize_docs(d): if page_name.lower().endswith(".svx"): page_name = page_name[:-4] pretty_page_name = " ".join([word[0].upper() + word[1:] for word in page_name.split("-")]) + for library in organized: + for category in organized[library]: + if page_name in organized[library][category]: + return index, page_name, organized[library][category][page_name]["name"], page_path + if page_name == "chatinterface": + pretty_page_name = "ChatInterface" return index, page_name, pretty_page_name, page_path diff --git a/js/_website/src/lib/components/DocsNav.svelte b/js/_website/src/lib/components/DocsNav.svelte index ac7e202bb0..b3667cf346 100644 --- a/js/_website/src/lib/components/DocsNav.svelte +++ b/js/_website/src/lib/components/DocsNav.svelte @@ -3,9 +3,7 @@ import { clickOutside } from "./clickOutside.js"; export let library_pages: any; - export let current_nav_link = ""; - let docs_type = "python"; let show_nav = false; let searchTerm = ""; diff --git a/js/_website/src/lib/components/EventListeners.svelte b/js/_website/src/lib/components/EventListeners.svelte index d97c5b18f5..3a0cee2d2c 100644 --- a/js/_website/src/lib/components/EventListeners.svelte +++ b/js/_website/src/lib/components/EventListeners.svelte @@ -82,7 +82,10 @@ {param["name"]} -

{param["annotation"]}

+

+ {param["annotation"].replace("Sequence[", "list[")} +

+ {#if "default" in param}

default: {param["default"]} diff --git a/js/_website/src/lib/components/FunctionDoc.svelte b/js/_website/src/lib/components/FunctionDoc.svelte index 93e7719483..817a10af66 100644 --- a/js/_website/src/lib/components/FunctionDoc.svelte +++ b/js/_website/src/lib/components/FunctionDoc.svelte @@ -107,7 +107,9 @@ {param["name"]} -

{param["annotation"]}

+

+ {param["annotation"].replace("Sequence[", "list[")} +

{#if "default" in param}

default: {param["default"]} diff --git a/js/_website/src/lib/components/Header.svelte b/js/_website/src/lib/components/Header.svelte index 0f1a592baf..435f96d5eb 100644 --- a/js/_website/src/lib/components/Header.svelte +++ b/js/_website/src/lib/components/Header.svelte @@ -12,26 +12,22 @@

-
+
-

- Introducing Gradio ClientsJoin us on Thursday, 9am PST +

+ Introducing Gradio Clients

Livestream Watch
-
+

- {param["annotation"]} + {param["annotation"].replace("Sequence[", "list[")}

{#if "default" in param}

diff --git a/js/_website/src/routes/[[version]]/docs/+layout.server.ts b/js/_website/src/routes/[[version]]/docs/+layout.server.ts index 34304fa1ed..1f2b9f105b 100644 --- a/js/_website/src/routes/[[version]]/docs/+layout.server.ts +++ b/js/_website/src/routes/[[version]]/docs/+layout.server.ts @@ -6,7 +6,6 @@ export const prerender = true; const DOCS_BUCKET = "https://gradio-docs-json.s3.us-west-2.amazonaws.com"; const VERSION = version.version; -const WHEEL = wheel.wheel; async function load_release_docs( version: string @@ -34,7 +33,6 @@ export async function load({ params, url }) { let js_pages = docs_json.js_pages || []; let js_client = docs_json.js_client; let on_main = params.version === "main"; - let wheel: string = WHEEL; let pages: any = docs_json.pages; let url_version = params?.version || VERSION; diff --git a/js/_website/src/routes/[[version]]/docs/gradio/[doc]/+page.svelte b/js/_website/src/routes/[[version]]/docs/gradio/[doc]/+page.svelte index a67a740b28..034afc9147 100644 --- a/js/_website/src/routes/[[version]]/docs/gradio/[doc]/+page.svelte +++ b/js/_website/src/routes/[[version]]/docs/gradio/[doc]/+page.svelte @@ -8,7 +8,8 @@ let name: string = data.name; let on_main: boolean; - let wheel: string = data.wheel; + let wheel: any = data.wheel; + let install_command: string = wheel.gradio_install; let url_version: string = data.url_version; let y: number; @@ -126,7 +127,7 @@

pip install {wheel}{install_command}

diff --git a/js/_website/src/routes/[[version]]/docs/js-client/+page.server.ts b/js/_website/src/routes/[[version]]/docs/js-client/+page.server.ts index 7c6ff41ac6..ff3ffc1662 100644 --- a/js/_website/src/routes/[[version]]/docs/js-client/+page.server.ts +++ b/js/_website/src/routes/[[version]]/docs/js-client/+page.server.ts @@ -121,6 +121,7 @@ export async function load({ parent }) { helpers, modals, routes, - py_client + py_client, + wheel }; } diff --git a/js/_website/src/routes/[[version]]/docs/js-client/+page.svelte b/js/_website/src/routes/[[version]]/docs/js-client/+page.svelte index d2fc951a1e..b7d95ec9c6 100644 --- a/js/_website/src/routes/[[version]]/docs/js-client/+page.svelte +++ b/js/_website/src/routes/[[version]]/docs/js-client/+page.svelte @@ -10,6 +10,8 @@ let modals = data.modals; let routes = data.routes; let py_client = data.py_client; + let wheel: any = data.wheel; + let install_command: string = wheel.gradio_js_client_install; let readme_html = data.readme_html; $: components = data.components; @@ -17,6 +19,7 @@ $: modals = data.modals; $: routes = data.routes; $: py_client = data.py_client; + $: on_main = data.on_main; Release History

+
+

+ To install the Gradio JS Client from main, run the following command: +

+
+
{install_command}
+
+
diff --git a/js/_website/src/routes/[[version]]/docs/python-client/[doc]/+page.svelte b/js/_website/src/routes/[[version]]/docs/python-client/[doc]/+page.svelte index 56e4d41dbd..a41010b72f 100644 --- a/js/_website/src/routes/[[version]]/docs/python-client/[doc]/+page.svelte +++ b/js/_website/src/routes/[[version]]/docs/python-client/[doc]/+page.svelte @@ -8,7 +8,8 @@ let name: string = data.name; let on_main: boolean; - let wheel: string = data.wheel; + let wheel: any = data.wheel; + let install_command: string = wheel.gradio_py_client_install; let url_version: string = data.url_version; let module = data.module.default; @@ -142,17 +143,14 @@ class="bg-gray-100 border border-gray-200 text-gray-800 px-3 py-1 mt-4 rounded-lg lg:ml-10" >

- To install Gradio from main, run the following command: + To install the Gradio Python Client from main, run the following + command:

-
+
pip install {wheel}{install_command}
-

- *Note: Setting share=True in - launch() will not work. -

{/if} diff --git a/scripts/upload_website_demos.py b/scripts/upload_website_demos.py index 0e8f479864..cf5da75339 100644 --- a/scripts/upload_website_demos.py +++ b/scripts/upload_website_demos.py @@ -128,6 +128,6 @@ if __name__ == "__main__": if args.AUTH_TOKEN is not None: hello_world_version = str(huggingface_hub.space_info("gradio/hello_world").cardData["sdk_version"]) for demo in demos: - # if hello_world_version != args.GRADIO_VERSION: - upload_demo_to_space(demo_name=demo, space_id="gradio/" + demo, hf_token=args.AUTH_TOKEN, gradio_version=args.GRADIO_VERSION) + if hello_world_version != args.GRADIO_VERSION: + upload_demo_to_space(demo_name=demo, space_id="gradio/" + demo, hf_token=args.AUTH_TOKEN, gradio_version=args.GRADIO_VERSION) upload_demo_to_space(demo_name=demo, space_id="gradio/" + demo + "_main", hf_token=args.AUTH_TOKEN, gradio_version=args.GRADIO_VERSION, gradio_wheel_url=gradio_wheel_url, gradio_client_url=args.CLIENT_URL)