update gradio and enhance tracebacks

This commit is contained in:
Vladimir Mandic
2023-04-14 14:20:37 -04:00
parent 463a7811c7
commit 27302938f1
7 changed files with 26 additions and 14 deletions
+2 -2
View File
@@ -6,7 +6,7 @@ import uvicorn
import gradio as gr
from threading import Lock
from io import BytesIO
from gradio.processing_utils import decode_base64_to_file
from gradio_client.utils import decode_base64_to_file
from fastapi import APIRouter, Depends, FastAPI, Request, Response
from fastapi.security import HTTPBasic, HTTPBasicCredentials
from fastapi.exceptions import HTTPException
@@ -570,7 +570,7 @@ class Api:
def create_hypernetwork(self, args: dict):
try:
shared.state.begin()
filename = create_hypernetwork(**args) # create empty embedding
filename = create_hypernetwork(**args) # create empty embedding # pylint: disable=E1111
shared.state.end()
return CreateResponse(info = "create hypernetwork filename: {filename}".format(filename = filename))
except AssertionError as e:
+12 -6
View File
@@ -4,27 +4,33 @@ import starlette
import gradio
from rich import print
from rich.console import Console
from rich.theme import Theme
from rich.pretty import install as pretty_install
from rich.traceback import install as traceback_install
console = Console(log_time=True, log_time_format='%H:%M:%S-%f')
console = Console(log_time=True, log_time_format='%H:%M:%S-%f', theme=Theme({
"traceback.border": "black",
"traceback.border.syntax_error": "black",
"inspect.value.border": "black",
}))
pretty_install(console=console)
traceback_install(console=console, extra_lines=1, width=console.width, word_wrap=False, indent_guides=False, suppress=[anyio, starlette, gradio])
already_displayed = {}
def install():
pretty_install(console=console)
traceback_install(console=console, extra_lines=1, width=console.width, word_wrap=False, indent_guides=False, suppress=[anyio, starlette, gradio])
def print_error_explanation(message):
lines = message.strip().split("\n")
max_len = max([len(x) for x in lines])
print('=' * max_len, file=sys.stderr)
for line in lines:
print(line, file=sys.stderr)
print('=' * max_len, file=sys.stderr)
def display(e: Exception, task):
print(f"{task or 'error'}: {type(e).__name__}", file=sys.stderr)
console.print_exception(show_locals=False, max_frames=2, extra_lines=1, suppress=[anyio, starlette, gradio], word_wrap=False, width=min([console.width, 200]))
console.print_exception(show_locals=False, max_frames=2, extra_lines=1, suppress=[anyio, starlette, gradio], theme="ansi_dark", word_wrap=False, width=min([console.width, 200]))
def display_once(e: Exception, task):
@@ -42,4 +48,4 @@ def run(code, task):
def exception():
console.print_exception(show_locals=False, max_frames=10, extra_lines=2, suppress=[anyio, starlette, gradio], word_wrap=False, width=min([console.width, 200]))
console.print_exception(show_locals=False, max_frames=10, extra_lines=2, suppress=[anyio, starlette, gradio], theme="ansi_dark", word_wrap=False, width=min([console.width, 200]))
+1
View File
@@ -15,6 +15,7 @@ import modules.devices as devices
from modules import script_loading, errors, ui_components, shared_items, cmd_args, errors
from modules.paths_internal import models_path, script_path, data_path, sd_configs_path, sd_default_config, sd_model_file, default_sd_model_file, extensions_dir, extensions_builtin_dir
errors.install()
demo = None
from setup import log as setup_log # pylint: disable=E0611
log = setup_log
+3 -3
View File
@@ -20,6 +20,7 @@ future
gdown
gfpgan
GitPython
gradio_client
httpcore
inflection
jsonmerge
@@ -54,10 +55,9 @@ transformers
voluptuous
yapf
diffusers==0.14.0
diffusers==0.15.0
einops==0.4.1
fastapi==0.94.0
gradio==3.23.0
gradio==3.26.0
numexpr==2.8.4
pandas==1.5.3
protobuf==3.20.3
+6 -2
View File
@@ -29,11 +29,16 @@ def setup_logging():
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s | %(levelname)s | %(pathname)s | %(message)s', filename='setup.log', filemode='a', encoding='utf-8', force=True)
try: # we may not have rich on the first run
from rich import print
from rich.theme import Theme
from rich.logging import RichHandler
from rich.console import Console
from rich.pretty import install as pretty_install
from rich.traceback import install as traceback_install
console = Console(log_time=True, log_time_format='%H:%M:%S-%f')
console = Console(log_time=True, log_time_format='%H:%M:%S-%f', theme=Theme({
"traceback.border": "black",
"traceback.border.syntax_error": "black",
"inspect.value.border": "black",
}))
pretty_install(console=console)
traceback_install(console=console, extra_lines=1, width=console.width, word_wrap=False, indent_guides=False, suppress=[])
rh = RichHandler(show_time=True, omit_repeated_times=False, show_level=True, show_path=False, markup=False, rich_tracebacks=True, log_time_format='%H:%M:%S-%f', level=logging.DEBUG if args.debug else logging.INFO, console=console)
@@ -372,7 +377,6 @@ def run_setup(quick = False):
install_repositories()
install_submodules()
install_extensions()
install_requirements()
if __name__ == "__main__":
+1
View File
@@ -11,6 +11,7 @@ import logging
logging.getLogger("xformers").addFilter(lambda record: 'A matching Triton is not available' not in record.getMessage())
from modules import paths, timer, errors
errors.install()
startup_timer = timer.Timer()
import torch