File size: 2,259 Bytes
0ad74ed |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
import argparse
import os
import pathlib
import shutil
import textwrap
def copy_all_demos(source_dir: str, dest_dir: str):
demos_to_copy = [
"audio_debugger",
"blocks_essay",
"blocks_group",
"blocks_js_methods",
"blocks_layout",
"blocks_multiple_event_triggers",
"blocks_update",
"calculator",
"cancel_events",
"chatbot_multimodal",
"chatinterface_streaming_echo",
"clear_components",
"code",
"fake_gan",
"fake_diffusion_with_gif",
"file_explorer_component_events",
"gradio_pdf_demo",
"image_mod_default_image",
"image_editor_events",
"image_segmentation",
"interface_random_slider",
"kitchen_sink",
"kitchen_sink_random",
"login_with_huggingface",
"matrix_transpose",
"mini_leaderboard",
"model3D",
"native_plots",
"reverse_audio",
"stt_or_tts",
"stream_audio",
"stream_audio_out",
"stream_frames",
"video_component",
"zip_files",
]
for demo in demos_to_copy:
shutil.copytree(
os.path.join(source_dir, demo),
os.path.join(dest_dir, demo),
dirs_exist_ok=True,
)
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Copy all demos to all_demos and update requirements"
)
parser.add_argument("gradio_version", type=str, help="Gradio")
parser.add_argument("gradio_client_version", type=str, help="Gradio Client Version")
args = parser.parse_args()
source_dir = pathlib.Path(pathlib.Path(__file__).parent, "..", "demo")
dest_dir = pathlib.Path(
pathlib.Path(__file__).parent, "..", "demo", "all_demos", "demos"
)
copy_all_demos(source_dir, dest_dir)
reqs_file_path = pathlib.Path(
pathlib.Path(__file__).parent, "..", "demo", "all_demos", "requirements.txt"
)
requirements = f"""
gradio_client=={args.gradio_client_version}
gradio=={args.gradio_version}
matplotlib
pypistats==1.1.0
plotly
altair
vega_datasets
"""
pathlib.Path(reqs_file_path).write_text(textwrap.dedent(requirements))
|