mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-09 02:00:44 +08:00
161a7a8472
* updated PyPi version to 2.9.0b * added to init * moved media_data * formatting * updated PyPi version to 2.9.0b2 * default selected * deprecated keyvalues * fixed a few small issues
32 lines
945 B
Python
32 lines
945 B
Python
"""Writes the config file for any of the demos to an output file
|
|
|
|
Usage: python write_config.py <demo_name> <output_file>
|
|
Example: python write_config.py calculator output.json
|
|
|
|
Assumes:
|
|
- The demo_name is a folder in this directory
|
|
- The demo_name folder contains a run.py file
|
|
- The run.py file defines a Gradio Interface/Blocks instance called `demo`
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import importlib
|
|
import json
|
|
|
|
import gradio as gr
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("demo_name", help="the name of the demo whose config to write")
|
|
parser.add_argument("file_path", help="the path at which to write the config file")
|
|
args = parser.parse_args()
|
|
|
|
# import the run.py file from inside the directory specified by args.demo_name
|
|
run = importlib.import_module(f"{args.demo_name}.run")
|
|
|
|
demo: gr.Blocks = run.demo
|
|
config = demo.get_config_file()
|
|
|
|
json.dump(config, open(args.file_path, "w"), indent=2)
|