Reload fix (#1392)

* updated PyPi version to 3.0.6

* updated PyPi version to 3.0.6b1

* updated reload.py

* updated PyPi version to 3.0.6b2

* fixed abs path issue

* updated PyPi version to 3.0.6b3

* formatting

* testing

* testing

* reload-fix

- tweaks

* reload-fix

- refornat

* reload-fix
- tweaks on comments

Co-authored-by: Ömer Faruk Özdemir <farukozderim@gmail.com>
This commit is contained in:
Abubakar Abid 2022-05-29 00:18:23 -04:00 committed by GitHub
parent 3a10ed894b
commit 22e551392f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 11 deletions

View File

@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: gradio
Version: 3.0.6
Version: 3.0.6b3
Summary: Python library for easily interacting with trained machine learning models
Home-page: https://github.com/gradio-app/gradio
Author: Abubakar Abid, Ali Abid, Ali Abdalla, Dawood Khan, Ahsen Khaliq, Pete Allen, Ömer Faruk Özdemir

View File

@ -2,10 +2,8 @@
Contains the functions that run when `gradio` is called from the command line. Specifically, allows
$ gradio app.py, to run app.py in user reload mode where any changes in the app.py reload the demo.
$ gradio-dev app.py, to run app.py in developer reload mode where any changes in the Gradio library reloads the demo.
$ gradio app.py, to run app.py in reload mode where any changes in the app.py file or Gradio library reloads the demo.
$ gradio app.py my_demo, to use variable names other than "demo"
$ gradio-dev app.py my_demo, to use variable names other than "demo"
"""
import inspect
import os
@ -25,13 +23,14 @@ def run_in_reload_mode():
demo_name = args[1]
original_path = args[0]
abs_original_path = os.path.abspath(original_path)
path = os.path.normpath(original_path)
path = path.replace("/", ".")
path = path.replace("\\", ".")
gradio_folder = os.path.dirname(inspect.getfile(gradio))
filename = os.path.splitext(path)[0]
gradio_folder = os.path.dirname(inspect.getfile(gradio))
port = networking.get_first_available_port(
networking.INITIAL_PORT_VALUE,
networking.INITIAL_PORT_VALUE + networking.TRY_NUM_PORTS,
@ -39,6 +38,20 @@ def run_in_reload_mode():
print(
f"\nLaunching in *reload mode* on: http://{networking.LOCALHOST_NAME}:{port} (Press CTRL+C to quit)\n"
)
os.system(
f"uvicorn {filename}:{demo_name}.app --reload --port {port} --log-level warning --reload-dir {gradio_folder} --reload-dir {os.path.dirname(original_path)}"
)
command = f"uvicorn {filename}:{demo_name}.app --reload --port {port} --log-level warning "
message = "Watching:"
message_change_count = 0
if gradio_folder.strip():
command += f'--reload-dir "{gradio_folder}" '
message += f" '{gradio_folder}'"
message_change_count += 1
if os.path.dirname(abs_original_path).strip():
command += f'--reload-dir "{os.path.dirname(abs_original_path)}"'
if message_change_count == 1:
message += ","
message += f" '{os.path.dirname(abs_original_path)}'"
print(message + "\n")
os.system(command)

View File

@ -1 +1 @@
3.0.6
3.0.6b3

View File

@ -9,7 +9,7 @@ long_description = (this_directory / "README.md").read_text(encoding='utf8')
setup(
name="gradio",
version="3.0.6",
version="3.0.6b3",
include_package_data=True,
description="Python library for easily interacting with trained machine learning models",
long_description=long_description,