mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-27 01:40:20 +08:00
5310782ed9
* started pathlib * blocks.py * more changes * fixes * typing * formatting * typing * renaming files * changelog * script * changelog * lint * routes * renamed * state * formatting * state * type check script * remove strictness * switched to pyright * switched to pyright * fixed flaky tests * fixed test xray * fixed load test * fixed blocks tests * formatting * fixed components test * uncomment tests * fixed interpretation tests * formatting * last tests hopefully * argh lint * component * fixed based on review * refactor * components.py t yping * components.py * formatting * lint script * merge * merge * lint * pathlib * lint * events too * lint script * fixing tests * lint * examples * serializing * more files * formatting * flagging.py * added to lint script * fixed tab * attempt fix * serialize fix * formatting * all demos queue * addressed review comments * formatting
36 lines
965 B
Python
36 lines
965 B
Python
import importlib
|
|
import gradio as gr
|
|
import os
|
|
import sys
|
|
import copy
|
|
import pathlib
|
|
|
|
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
|
|
|
demo_dir = pathlib.Path(__file__).parent / "demos"
|
|
|
|
|
|
all_demos = []
|
|
demo_module = None
|
|
for p in sorted(os.listdir("./demos")):
|
|
old_path = copy.deepcopy(sys.path)
|
|
sys.path = [os.path.join(demo_dir, p)] + sys.path
|
|
try: # Some demos may not be runnable because of 429 timeouts, etc.
|
|
if demo_module is None:
|
|
demo_module = importlib.import_module(f"run")
|
|
else:
|
|
demo_module = importlib.reload(demo_module)
|
|
all_demos.append((p, demo_module.demo))
|
|
except Exception as e:
|
|
p = p + " ❌"
|
|
with gr.Blocks() as demo:
|
|
gr.Markdown(f"Error loading demo: {e}")
|
|
all_demos.append((p, demo))
|
|
|
|
with gr.Blocks() as mega_demo:
|
|
for demo_name, demo in all_demos:
|
|
with gr.Tab(demo_name):
|
|
demo.render()
|
|
|
|
mega_demo.queue().launch()
|