rename print_error to report, use it with together with package name

This commit is contained in:
AUTOMATIC 2023-05-31 19:56:37 +03:00
parent d67ef01f62
commit 05933840f0
24 changed files with 69 additions and 90 deletions

View File

@ -2,10 +2,9 @@ import os
from basicsr.utils.download_util import load_file_from_url from basicsr.utils.download_util import load_file_from_url
from modules.errors import print_error
from modules.upscaler import Upscaler, UpscalerData from modules.upscaler import Upscaler, UpscalerData
from ldsr_model_arch import LDSR from ldsr_model_arch import LDSR
from modules import shared, script_callbacks from modules import shared, script_callbacks, errors
import sd_hijack_autoencoder # noqa: F401 import sd_hijack_autoencoder # noqa: F401
import sd_hijack_ddpm_v1 # noqa: F401 import sd_hijack_ddpm_v1 # noqa: F401
@ -51,7 +50,7 @@ class UpscalerLDSR(Upscaler):
try: try:
return LDSR(model, yaml) return LDSR(model, yaml)
except Exception: except Exception:
print_error("Error importing LDSR", exc_info=True) errors.report("Error importing LDSR", exc_info=True)
return None return None
def do_upscale(self, img, path): def do_upscale(self, img, path):

View File

@ -9,10 +9,9 @@ from tqdm import tqdm
from basicsr.utils.download_util import load_file_from_url from basicsr.utils.download_util import load_file_from_url
import modules.upscaler import modules.upscaler
from modules import devices, modelloader, script_callbacks from modules import devices, modelloader, script_callbacks, errors
from scunet_model_arch import SCUNet as net from scunet_model_arch import SCUNet as net
from modules.errors import print_error
from modules.shared import opts from modules.shared import opts
@ -39,7 +38,7 @@ class UpscalerScuNET(modules.upscaler.Upscaler):
scaler_data = modules.upscaler.UpscalerData(name, file, self, 4) scaler_data = modules.upscaler.UpscalerData(name, file, self, 4)
scalers.append(scaler_data) scalers.append(scaler_data)
except Exception: except Exception:
print_error(f"Error loading ScuNET model: {file}", exc_info=True) errors.report(f"Error loading ScuNET model: {file}", exc_info=True)
if add_model2: if add_model2:
scaler_data2 = modules.upscaler.UpscalerData(self.model_name2, self.model_url2, self) scaler_data2 = modules.upscaler.UpscalerData(self.model_name2, self.model_url2, self)
scalers.append(scaler_data2) scalers.append(scaler_data2)

View File

@ -14,9 +14,8 @@ from fastapi.encoders import jsonable_encoder
from secrets import compare_digest from secrets import compare_digest
import modules.shared as shared import modules.shared as shared
from modules import sd_samplers, deepbooru, sd_hijack, images, scripts, ui, postprocessing from modules import sd_samplers, deepbooru, sd_hijack, images, scripts, ui, postprocessing, errors
from modules.api import models from modules.api import models
from modules.errors import print_error
from modules.shared import opts from modules.shared import opts
from modules.processing import StableDiffusionProcessingTxt2Img, StableDiffusionProcessingImg2Img, process_images from modules.processing import StableDiffusionProcessingTxt2Img, StableDiffusionProcessingImg2Img, process_images
from modules.textual_inversion.textual_inversion import create_embedding, train_embedding from modules.textual_inversion.textual_inversion import create_embedding, train_embedding
@ -145,7 +144,7 @@ def api_middleware(app: FastAPI):
print(message) print(message)
console.print_exception(show_locals=True, max_frames=2, extra_lines=1, suppress=[anyio, starlette], word_wrap=False, width=min([console.width, 200])) console.print_exception(show_locals=True, max_frames=2, extra_lines=1, suppress=[anyio, starlette], word_wrap=False, width=min([console.width, 200]))
else: else:
print_error(message, exc_info=True) errors.report(message, exc_info=True)
return JSONResponse(status_code=vars(e).get('status_code', 500), content=jsonable_encoder(err)) return JSONResponse(status_code=vars(e).get('status_code', 500), content=jsonable_encoder(err))
@app.middleware("http") @app.middleware("http")

View File

@ -2,8 +2,7 @@ import html
import threading import threading
import time import time
from modules import shared, progress from modules import shared, progress, errors
from modules.errors import print_error
queue_lock = threading.Lock() queue_lock = threading.Lock()
@ -62,7 +61,7 @@ def wrap_gradio_call(func, extra_outputs=None, add_stats=False):
arg_str = f"Arguments: {args} {kwargs}"[:max_debug_str_len] arg_str = f"Arguments: {args} {kwargs}"[:max_debug_str_len]
if len(arg_str) > max_debug_str_len: if len(arg_str) > max_debug_str_len:
arg_str += f" (Argument list truncated at {max_debug_str_len}/{len(arg_str)} characters)" arg_str += f" (Argument list truncated at {max_debug_str_len}/{len(arg_str)} characters)"
print_error(f"{message}\n{arg_str}", exc_info=True) errors.report(f"{message}\n{arg_str}", exc_info=True)
shared.state.job = "" shared.state.job = ""
shared.state.job_count = 0 shared.state.job_count = 0

View File

@ -5,8 +5,7 @@ import torch
import modules.face_restoration import modules.face_restoration
import modules.shared import modules.shared
from modules import shared, devices, modelloader from modules import shared, devices, modelloader, errors
from modules.errors import print_error
from modules.paths import models_path from modules.paths import models_path
# codeformer people made a choice to include modified basicsr library to their project which makes # codeformer people made a choice to include modified basicsr library to their project which makes
@ -105,7 +104,7 @@ def setup_model(dirname):
del output del output
torch.cuda.empty_cache() torch.cuda.empty_cache()
except Exception: except Exception:
print_error('Failed inference for CodeFormer', exc_info=True) errors.report('Failed inference for CodeFormer', exc_info=True)
restored_face = tensor2img(cropped_face_t, rgb2bgr=True, min_max=(-1, 1)) restored_face = tensor2img(cropped_face_t, rgb2bgr=True, min_max=(-1, 1))
restored_face = restored_face.astype('uint8') restored_face = restored_face.astype('uint8')
@ -134,6 +133,6 @@ def setup_model(dirname):
shared.face_restorers.append(codeformer) shared.face_restorers.append(codeformer)
except Exception: except Exception:
print_error("Error setting up CodeFormer", exc_info=True) errors.report("Error setting up CodeFormer", exc_info=True)
# sys.path = stored_sys_path # sys.path = stored_sys_path

View File

@ -11,8 +11,7 @@ from datetime import datetime
from collections import OrderedDict from collections import OrderedDict
import git import git
from modules import shared, extensions from modules import shared, extensions, errors
from modules.errors import print_error
from modules.paths_internal import script_path, config_states_dir from modules.paths_internal import script_path, config_states_dir
@ -52,7 +51,7 @@ def get_webui_config():
if os.path.exists(os.path.join(script_path, ".git")): if os.path.exists(os.path.join(script_path, ".git")):
webui_repo = git.Repo(script_path) webui_repo = git.Repo(script_path)
except Exception: except Exception:
print_error(f"Error reading webui git info from {script_path}", exc_info=True) errors.report(f"Error reading webui git info from {script_path}", exc_info=True)
webui_remote = None webui_remote = None
webui_commit_hash = None webui_commit_hash = None
@ -132,7 +131,7 @@ def restore_webui_config(config):
if os.path.exists(os.path.join(script_path, ".git")): if os.path.exists(os.path.join(script_path, ".git")):
webui_repo = git.Repo(script_path) webui_repo = git.Repo(script_path)
except Exception: except Exception:
print_error(f"Error reading webui git info from {script_path}", exc_info=True) errors.report(f"Error reading webui git info from {script_path}", exc_info=True)
return return
try: try:
@ -140,7 +139,7 @@ def restore_webui_config(config):
webui_repo.git.reset(webui_commit_hash, hard=True) webui_repo.git.reset(webui_commit_hash, hard=True)
print(f"* Restored webui to commit {webui_commit_hash}.") print(f"* Restored webui to commit {webui_commit_hash}.")
except Exception: except Exception:
print_error(f"Error restoring webui to commit{webui_commit_hash}") errors.report(f"Error restoring webui to commit{webui_commit_hash}")
def restore_extension_config(config): def restore_extension_config(config):

View File

@ -3,11 +3,7 @@ import textwrap
import traceback import traceback
def print_error( def report(message: str, *, exc_info: bool = False) -> None:
message: str,
*,
exc_info: bool = False,
) -> None:
""" """
Print an error message to stderr, with optional traceback. Print an error message to stderr, with optional traceback.
""" """
@ -15,7 +11,7 @@ def print_error(
print("***", line, file=sys.stderr) print("***", line, file=sys.stderr)
if exc_info: if exc_info:
print(textwrap.indent(traceback.format_exc(), " "), file=sys.stderr) print(textwrap.indent(traceback.format_exc(), " "), file=sys.stderr)
print("---") print("---", file=sys.stderr)
def print_error_explanation(message): def print_error_explanation(message):

View File

@ -1,8 +1,7 @@
import os import os
import threading import threading
from modules import shared from modules import shared, errors
from modules.errors import print_error
from modules.gitpython_hack import Repo from modules.gitpython_hack import Repo
from modules.paths_internal import extensions_dir, extensions_builtin_dir, script_path # noqa: F401 from modules.paths_internal import extensions_dir, extensions_builtin_dir, script_path # noqa: F401
@ -54,7 +53,7 @@ class Extension:
if os.path.exists(os.path.join(self.path, ".git")): if os.path.exists(os.path.join(self.path, ".git")):
repo = Repo(self.path) repo = Repo(self.path)
except Exception: except Exception:
print_error(f"Error reading github repository info from {self.path}", exc_info=True) errors.report(f"Error reading github repository info from {self.path}", exc_info=True)
if repo is None or repo.bare: if repo is None or repo.bare:
self.remote = None self.remote = None
@ -70,7 +69,7 @@ class Extension:
self.version = self.commit_hash[:8] self.version = self.commit_hash[:8]
except Exception: except Exception:
print_error(f"Failed reading extension data from Git repository ({self.name})", exc_info=True) errors.report(f"Failed reading extension data from Git repository ({self.name})", exc_info=True)
self.remote = None self.remote = None
self.have_info_from_repo = True self.have_info_from_repo = True

View File

@ -4,8 +4,7 @@ import facexlib
import gfpgan import gfpgan
import modules.face_restoration import modules.face_restoration
from modules import paths, shared, devices, modelloader from modules import paths, shared, devices, modelloader, errors
from modules.errors import print_error
model_dir = "GFPGAN" model_dir = "GFPGAN"
user_path = None user_path = None
@ -111,4 +110,4 @@ def setup_model(dirname):
shared.face_restorers.append(FaceRestorerGFPGAN()) shared.face_restorers.append(FaceRestorerGFPGAN())
except Exception: except Exception:
print_error("Error setting up GFPGAN", exc_info=True) errors.report("Error setting up GFPGAN", exc_info=True)

View File

@ -9,8 +9,7 @@ import torch
import tqdm import tqdm
from einops import rearrange, repeat from einops import rearrange, repeat
from ldm.util import default from ldm.util import default
from modules import devices, processing, sd_models, shared, sd_samplers, hashes, sd_hijack_checkpoint from modules import devices, processing, sd_models, shared, sd_samplers, hashes, sd_hijack_checkpoint, errors
from modules.errors import print_error
from modules.textual_inversion import textual_inversion, logging from modules.textual_inversion import textual_inversion, logging
from modules.textual_inversion.learn_schedule import LearnRateScheduler from modules.textual_inversion.learn_schedule import LearnRateScheduler
from torch import einsum from torch import einsum
@ -329,7 +328,7 @@ def load_hypernetwork(name):
hypernetwork.load(path) hypernetwork.load(path)
return hypernetwork return hypernetwork
except Exception: except Exception:
print_error(f"Error loading hypernetwork {path}", exc_info=True) errors.report(f"Error loading hypernetwork {path}", exc_info=True)
return None return None
@ -766,7 +765,7 @@ Last saved image: {html.escape(last_saved_image)}<br/>
</p> </p>
""" """
except Exception: except Exception:
print_error("Exception in training hypernetwork", exc_info=True) errors.report("Exception in training hypernetwork", exc_info=True)
finally: finally:
pbar.leave = False pbar.leave = False
pbar.close() pbar.close()

View File

@ -16,7 +16,6 @@ import json
import hashlib import hashlib
from modules import sd_samplers, shared, script_callbacks, errors from modules import sd_samplers, shared, script_callbacks, errors
from modules.errors import print_error
from modules.paths_internal import roboto_ttf_file from modules.paths_internal import roboto_ttf_file
from modules.shared import opts from modules.shared import opts
@ -463,7 +462,7 @@ class FilenameGenerator:
replacement = fun(self, *pattern_args) replacement = fun(self, *pattern_args)
except Exception: except Exception:
replacement = None replacement = None
print_error(f"Error adding [{pattern}] to filename", exc_info=True) errors.report(f"Error adding [{pattern}] to filename", exc_info=True)
if replacement == NOTHING_AND_SKIP_PREVIOUS_TEXT: if replacement == NOTHING_AND_SKIP_PREVIOUS_TEXT:
continue continue
@ -698,7 +697,7 @@ def read_info_from_image(image):
Negative prompt: {json_info["uc"]} Negative prompt: {json_info["uc"]}
Steps: {json_info["steps"]}, Sampler: {sampler}, CFG scale: {json_info["scale"]}, Seed: {json_info["seed"]}, Size: {image.width}x{image.height}, Clip skip: 2, ENSD: 31337""" Steps: {json_info["steps"]}, Sampler: {sampler}, CFG scale: {json_info["scale"]}, Seed: {json_info["seed"]}, Size: {image.width}x{image.height}, Clip skip: 2, ENSD: 31337"""
except Exception: except Exception:
print_error("Error parsing NovelAI image generation parameters", exc_info=True) errors.report("Error parsing NovelAI image generation parameters", exc_info=True)
return geninfo, items return geninfo, items

View File

@ -11,7 +11,6 @@ from torchvision import transforms
from torchvision.transforms.functional import InterpolationMode from torchvision.transforms.functional import InterpolationMode
from modules import devices, paths, shared, lowvram, modelloader, errors from modules import devices, paths, shared, lowvram, modelloader, errors
from modules.errors import print_error
blip_image_eval_size = 384 blip_image_eval_size = 384
clip_model_name = 'ViT-L/14' clip_model_name = 'ViT-L/14'
@ -216,7 +215,7 @@ class InterrogateModels:
res += f", {match}" res += f", {match}"
except Exception: except Exception:
print_error("Error interrogating", exc_info=True) errors.report("Error interrogating", exc_info=True)
res += "<error>" res += "<error>"
self.unload() self.unload()

View File

@ -7,8 +7,7 @@ import platform
import json import json
from functools import lru_cache from functools import lru_cache
from modules import cmd_args from modules import cmd_args, errors
from modules.errors import print_error
from modules.paths_internal import script_path, extensions_dir from modules.paths_internal import script_path, extensions_dir
args, _ = cmd_args.parser.parse_known_args() args, _ = cmd_args.parser.parse_known_args()
@ -189,7 +188,7 @@ def run_extension_installer(extension_dir):
print(run(f'"{python}" "{path_installer}"', errdesc=f"Error running install.py for extension {extension_dir}", custom_env=env)) print(run(f'"{python}" "{path_installer}"', errdesc=f"Error running install.py for extension {extension_dir}", custom_env=env))
except Exception as e: except Exception as e:
print_error(str(e)) errors.report(str(e))
def list_extensions(settings_file): def list_extensions(settings_file):
@ -200,7 +199,7 @@ def list_extensions(settings_file):
with open(settings_file, "r", encoding="utf8") as file: with open(settings_file, "r", encoding="utf8") as file:
settings = json.load(file) settings = json.load(file)
except Exception: except Exception:
print_error("Could not load settings", exc_info=True) errors.report("Could not load settings", exc_info=True)
disabled_extensions = set(settings.get('disabled_extensions', [])) disabled_extensions = set(settings.get('disabled_extensions', []))
disable_all_extensions = settings.get('disable_all_extensions', 'none') disable_all_extensions = settings.get('disable_all_extensions', 'none')

View File

@ -1,7 +1,7 @@
import json import json
import os import os
from modules.errors import print_error from modules import errors
localizations = {} localizations = {}
@ -30,6 +30,6 @@ def localization_js(current_localization_name: str) -> str:
with open(fn, "r", encoding="utf8") as file: with open(fn, "r", encoding="utf8") as file:
data = json.load(file) data = json.load(file)
except Exception: except Exception:
print_error(f"Error loading localization from {fn}", exc_info=True) errors.report(f"Error loading localization from {fn}", exc_info=True)
return f"window.localization = {json.dumps(data)}" return f"window.localization = {json.dumps(data)}"

View File

@ -5,10 +5,10 @@ from PIL import Image
from basicsr.utils.download_util import load_file_from_url from basicsr.utils.download_util import load_file_from_url
from realesrgan import RealESRGANer from realesrgan import RealESRGANer
from modules.errors import print_error
from modules.upscaler import Upscaler, UpscalerData from modules.upscaler import Upscaler, UpscalerData
from modules.shared import cmd_opts, opts from modules.shared import cmd_opts, opts
from modules import modelloader from modules import modelloader, errors
class UpscalerRealESRGAN(Upscaler): class UpscalerRealESRGAN(Upscaler):
def __init__(self, path): def __init__(self, path):
@ -35,7 +35,7 @@ class UpscalerRealESRGAN(Upscaler):
self.scalers.append(scaler) self.scalers.append(scaler)
except Exception: except Exception:
print_error("Error importing Real-ESRGAN", exc_info=True) errors.report("Error importing Real-ESRGAN", exc_info=True)
self.enable = False self.enable = False
self.scalers = [] self.scalers = []
@ -75,7 +75,7 @@ class UpscalerRealESRGAN(Upscaler):
return info return info
except Exception: except Exception:
print_error("Error making Real-ESRGAN models list", exc_info=True) errors.report("Error making Real-ESRGAN models list", exc_info=True)
return None return None
def load_models(self, _): def load_models(self, _):
@ -132,4 +132,4 @@ def get_realesrgan_models(scaler):
] ]
return models return models
except Exception: except Exception:
print_error("Error making Real-ESRGAN models list", exc_info=True) errors.report("Error making Real-ESRGAN models list", exc_info=True)

View File

@ -9,9 +9,10 @@ import _codecs
import zipfile import zipfile
import re import re
from modules.errors import print_error
# PyTorch 1.13 and later have _TypedStorage renamed to TypedStorage # PyTorch 1.13 and later have _TypedStorage renamed to TypedStorage
from modules import errors
TypedStorage = torch.storage.TypedStorage if hasattr(torch.storage, 'TypedStorage') else torch.storage._TypedStorage TypedStorage = torch.storage.TypedStorage if hasattr(torch.storage, 'TypedStorage') else torch.storage._TypedStorage
def encode(*args): def encode(*args):
@ -136,7 +137,7 @@ def load_with_extra(filename, extra_handler=None, *args, **kwargs):
check_pt(filename, extra_handler) check_pt(filename, extra_handler)
except pickle.UnpicklingError: except pickle.UnpicklingError:
print_error( errors.report(
f"Error verifying pickled file from {filename}\n" f"Error verifying pickled file from {filename}\n"
"-----> !!!! The file is most likely corrupted !!!! <-----\n" "-----> !!!! The file is most likely corrupted !!!! <-----\n"
"You can skip this check with --disable-safe-unpickle commandline argument, but that is not going to help you.\n\n", "You can skip this check with --disable-safe-unpickle commandline argument, but that is not going to help you.\n\n",
@ -144,7 +145,7 @@ def load_with_extra(filename, extra_handler=None, *args, **kwargs):
) )
return None return None
except Exception: except Exception:
print_error( errors.report(
f"Error verifying pickled file from {filename}\n" f"Error verifying pickled file from {filename}\n"
f"The file may be malicious, so the program is not going to read it.\n" f"The file may be malicious, so the program is not going to read it.\n"
f"You can skip this check with --disable-safe-unpickle commandline argument.\n\n", f"You can skip this check with --disable-safe-unpickle commandline argument.\n\n",

View File

@ -5,11 +5,11 @@ from typing import Optional, Dict, Any
from fastapi import FastAPI from fastapi import FastAPI
from gradio import Blocks from gradio import Blocks
from modules.errors import print_error from modules import errors
def report_exception(c, job): def report_exception(c, job):
print_error(f"Error executing callback {job} for {c.script}", exc_info=True) errors.report(f"Error executing callback {job} for {c.script}", exc_info=True)
class ImageSaveParams: class ImageSaveParams:

View File

@ -1,7 +1,7 @@
import os import os
import importlib.util import importlib.util
from modules.errors import print_error from modules import errors
def load_module(path): def load_module(path):
@ -27,4 +27,4 @@ def preload_extensions(extensions_dir, parser):
module.preload(parser) module.preload(parser)
except Exception: except Exception:
print_error(f"Error running preload() for {preload_script}", exc_info=True) errors.report(f"Error running preload() for {preload_script}", exc_info=True)

View File

@ -5,8 +5,7 @@ from collections import namedtuple
import gradio as gr import gradio as gr
from modules import shared, paths, script_callbacks, extensions, script_loading, scripts_postprocessing from modules import shared, paths, script_callbacks, extensions, script_loading, scripts_postprocessing, errors
from modules.errors import print_error
AlwaysVisible = object() AlwaysVisible = object()
@ -264,7 +263,7 @@ def load_scripts():
register_scripts_from_module(script_module) register_scripts_from_module(script_module)
except Exception: except Exception:
print_error(f"Error loading script: {scriptfile.filename}", exc_info=True) errors.report(f"Error loading script: {scriptfile.filename}", exc_info=True)
finally: finally:
sys.path = syspath sys.path = syspath
@ -281,7 +280,7 @@ def wrap_call(func, filename, funcname, *args, default=None, **kwargs):
try: try:
return func(*args, **kwargs) return func(*args, **kwargs)
except Exception: except Exception:
print_error(f"Error calling: {filename}/{funcname}", exc_info=True) errors.report(f"Error calling: {filename}/{funcname}", exc_info=True)
return default return default
@ -447,7 +446,7 @@ class ScriptRunner:
script_args = p.script_args[script.args_from:script.args_to] script_args = p.script_args[script.args_from:script.args_to]
script.process(p, *script_args) script.process(p, *script_args)
except Exception: except Exception:
print_error(f"Error running process: {script.filename}", exc_info=True) errors.report(f"Error running process: {script.filename}", exc_info=True)
def before_process_batch(self, p, **kwargs): def before_process_batch(self, p, **kwargs):
for script in self.alwayson_scripts: for script in self.alwayson_scripts:
@ -455,7 +454,7 @@ class ScriptRunner:
script_args = p.script_args[script.args_from:script.args_to] script_args = p.script_args[script.args_from:script.args_to]
script.before_process_batch(p, *script_args, **kwargs) script.before_process_batch(p, *script_args, **kwargs)
except Exception: except Exception:
print_error(f"Error running before_process_batch: {script.filename}", exc_info=True) errors.report(f"Error running before_process_batch: {script.filename}", exc_info=True)
def process_batch(self, p, **kwargs): def process_batch(self, p, **kwargs):
for script in self.alwayson_scripts: for script in self.alwayson_scripts:
@ -463,7 +462,7 @@ class ScriptRunner:
script_args = p.script_args[script.args_from:script.args_to] script_args = p.script_args[script.args_from:script.args_to]
script.process_batch(p, *script_args, **kwargs) script.process_batch(p, *script_args, **kwargs)
except Exception: except Exception:
print_error(f"Error running process_batch: {script.filename}", exc_info=True) errors.report(f"Error running process_batch: {script.filename}", exc_info=True)
def postprocess(self, p, processed): def postprocess(self, p, processed):
for script in self.alwayson_scripts: for script in self.alwayson_scripts:
@ -471,7 +470,7 @@ class ScriptRunner:
script_args = p.script_args[script.args_from:script.args_to] script_args = p.script_args[script.args_from:script.args_to]
script.postprocess(p, processed, *script_args) script.postprocess(p, processed, *script_args)
except Exception: except Exception:
print_error(f"Error running postprocess: {script.filename}", exc_info=True) errors.report(f"Error running postprocess: {script.filename}", exc_info=True)
def postprocess_batch(self, p, images, **kwargs): def postprocess_batch(self, p, images, **kwargs):
for script in self.alwayson_scripts: for script in self.alwayson_scripts:
@ -479,7 +478,7 @@ class ScriptRunner:
script_args = p.script_args[script.args_from:script.args_to] script_args = p.script_args[script.args_from:script.args_to]
script.postprocess_batch(p, *script_args, images=images, **kwargs) script.postprocess_batch(p, *script_args, images=images, **kwargs)
except Exception: except Exception:
print_error(f"Error running postprocess_batch: {script.filename}", exc_info=True) errors.report(f"Error running postprocess_batch: {script.filename}", exc_info=True)
def postprocess_image(self, p, pp: PostprocessImageArgs): def postprocess_image(self, p, pp: PostprocessImageArgs):
for script in self.alwayson_scripts: for script in self.alwayson_scripts:
@ -487,21 +486,21 @@ class ScriptRunner:
script_args = p.script_args[script.args_from:script.args_to] script_args = p.script_args[script.args_from:script.args_to]
script.postprocess_image(p, pp, *script_args) script.postprocess_image(p, pp, *script_args)
except Exception: except Exception:
print_error(f"Error running postprocess_image: {script.filename}", exc_info=True) errors.report(f"Error running postprocess_image: {script.filename}", exc_info=True)
def before_component(self, component, **kwargs): def before_component(self, component, **kwargs):
for script in self.scripts: for script in self.scripts:
try: try:
script.before_component(component, **kwargs) script.before_component(component, **kwargs)
except Exception: except Exception:
print_error(f"Error running before_component: {script.filename}", exc_info=True) errors.report(f"Error running before_component: {script.filename}", exc_info=True)
def after_component(self, component, **kwargs): def after_component(self, component, **kwargs):
for script in self.scripts: for script in self.scripts:
try: try:
script.after_component(component, **kwargs) script.after_component(component, **kwargs)
except Exception: except Exception:
print_error(f"Error running after_component: {script.filename}", exc_info=True) errors.report(f"Error running after_component: {script.filename}", exc_info=True)
def reload_sources(self, cache): def reload_sources(self, cache):
for si, script in list(enumerate(self.scripts)): for si, script in list(enumerate(self.scripts)):

View File

@ -9,7 +9,6 @@ from ldm.util import default
from einops import rearrange from einops import rearrange
from modules import shared, errors, devices, sub_quadratic_attention from modules import shared, errors, devices, sub_quadratic_attention
from modules.errors import print_error
from modules.hypernetworks import hypernetwork from modules.hypernetworks import hypernetwork
import ldm.modules.attention import ldm.modules.attention
@ -139,7 +138,7 @@ if shared.cmd_opts.xformers or shared.cmd_opts.force_enable_xformers:
import xformers.ops import xformers.ops
shared.xformers_available = True shared.xformers_available = True
except Exception: except Exception:
print_error("Cannot import xformers", exc_info=True) errors.report("Cannot import xformers", exc_info=True)
def get_available_vram(): def get_available_vram():

View File

@ -12,9 +12,8 @@ import numpy as np
from PIL import Image, PngImagePlugin from PIL import Image, PngImagePlugin
from torch.utils.tensorboard import SummaryWriter from torch.utils.tensorboard import SummaryWriter
from modules import shared, devices, sd_hijack, processing, sd_models, images, sd_samplers, sd_hijack_checkpoint from modules import shared, devices, sd_hijack, processing, sd_models, images, sd_samplers, sd_hijack_checkpoint, errors
import modules.textual_inversion.dataset import modules.textual_inversion.dataset
from modules.errors import print_error
from modules.textual_inversion.learn_schedule import LearnRateScheduler from modules.textual_inversion.learn_schedule import LearnRateScheduler
from modules.textual_inversion.image_embedding import embedding_to_b64, embedding_from_b64, insert_image_data_embed, extract_image_data_embed, caption_image_overlay from modules.textual_inversion.image_embedding import embedding_to_b64, embedding_from_b64, insert_image_data_embed, extract_image_data_embed, caption_image_overlay
@ -219,7 +218,7 @@ class EmbeddingDatabase:
self.load_from_file(fullfn, fn) self.load_from_file(fullfn, fn)
except Exception: except Exception:
print_error(f"Error loading embedding {fn}", exc_info=True) errors.report(f"Error loading embedding {fn}", exc_info=True)
continue continue
def load_textual_inversion_embeddings(self, force_reload=False): def load_textual_inversion_embeddings(self, force_reload=False):
@ -643,7 +642,7 @@ Last saved image: {html.escape(last_saved_image)}<br/>
filename = os.path.join(shared.cmd_opts.embeddings_dir, f'{embedding_name}.pt') filename = os.path.join(shared.cmd_opts.embeddings_dir, f'{embedding_name}.pt')
save_embedding(embedding, optimizer, checkpoint, embedding_name, filename, remove_cached_checksum=True) save_embedding(embedding, optimizer, checkpoint, embedding_name, filename, remove_cached_checksum=True)
except Exception: except Exception:
print_error("Error training embedding", exc_info=True) errors.report("Error training embedding", exc_info=True)
finally: finally:
pbar.leave = False pbar.leave = False
pbar.close() pbar.close()

View File

@ -12,8 +12,7 @@ import numpy as np
from PIL import Image, PngImagePlugin # noqa: F401 from PIL import Image, PngImagePlugin # noqa: F401
from modules.call_queue import wrap_gradio_gpu_call, wrap_queued_call, wrap_gradio_call from modules.call_queue import wrap_gradio_gpu_call, wrap_queued_call, wrap_gradio_call
from modules import sd_hijack, sd_models, localization, script_callbacks, ui_extensions, deepbooru, sd_vae, extra_networks, ui_common, ui_postprocessing, progress, ui_loadsave from modules import sd_hijack, sd_models, localization, script_callbacks, ui_extensions, deepbooru, sd_vae, extra_networks, ui_common, ui_postprocessing, progress, ui_loadsave, errors
from modules.errors import print_error
from modules.ui_components import FormRow, FormGroup, ToolButton, FormHTML from modules.ui_components import FormRow, FormGroup, ToolButton, FormHTML
from modules.paths import script_path, data_path from modules.paths import script_path, data_path
@ -232,7 +231,7 @@ def connect_reuse_seed(seed: gr.Number, reuse_seed: gr.Button, generation_info:
except json.decoder.JSONDecodeError: except json.decoder.JSONDecodeError:
if gen_info_string: if gen_info_string:
print_error(f"Error parsing JSON generation info: {gen_info_string}") errors.report(f"Error parsing JSON generation info: {gen_info_string}")
return [res, gr_show(False)] return [res, gr_show(False)]
@ -1752,7 +1751,7 @@ def create_ui():
try: try:
results = modules.extras.run_modelmerger(*args) results = modules.extras.run_modelmerger(*args)
except Exception as e: except Exception as e:
print_error("Error loading/saving model file", exc_info=True) errors.report("Error loading/saving model file", exc_info=True)
modules.sd_models.list_models() # to remove the potentially missing models from the list modules.sd_models.list_models() # to remove the potentially missing models from the list
return [*[gr.Dropdown.update(choices=modules.sd_models.checkpoint_tiles()) for _ in range(4)], f"Error merging checkpoints: {e}"] return [*[gr.Dropdown.update(choices=modules.sd_models.checkpoint_tiles()) for _ in range(4)], f"Error merging checkpoints: {e}"]
return results return results

View File

@ -11,8 +11,7 @@ import html
import shutil import shutil
import errno import errno
from modules import extensions, shared, paths, config_states from modules import extensions, shared, paths, config_states, errors
from modules.errors import print_error
from modules.paths_internal import config_states_dir from modules.paths_internal import config_states_dir
from modules.call_queue import wrap_gradio_gpu_call from modules.call_queue import wrap_gradio_gpu_call
@ -45,7 +44,7 @@ def apply_and_restart(disable_list, update_list, disable_all):
try: try:
ext.fetch_and_reset_hard() ext.fetch_and_reset_hard()
except Exception: except Exception:
print_error(f"Error getting updates for {ext.name}", exc_info=True) errors.report(f"Error getting updates for {ext.name}", exc_info=True)
shared.opts.disabled_extensions = disabled shared.opts.disabled_extensions = disabled
shared.opts.disable_all_extensions = disable_all shared.opts.disable_all_extensions = disable_all
@ -111,7 +110,7 @@ def check_updates(id_task, disable_list):
if 'FETCH_HEAD' not in str(e): if 'FETCH_HEAD' not in str(e):
raise raise
except Exception: except Exception:
print_error(f"Error checking updates for {ext.name}", exc_info=True) errors.report(f"Error checking updates for {ext.name}", exc_info=True)
shared.state.nextjob() shared.state.nextjob()

View File

@ -5,8 +5,7 @@ import shlex
import modules.scripts as scripts import modules.scripts as scripts
import gradio as gr import gradio as gr
from modules import sd_samplers from modules import sd_samplers, errors
from modules.errors import print_error
from modules.processing import Processed, process_images from modules.processing import Processed, process_images
from modules.shared import state from modules.shared import state
@ -135,7 +134,7 @@ class Script(scripts.Script):
try: try:
args = cmdargs(line) args = cmdargs(line)
except Exception: except Exception:
print_error(f"Error parsing line {line} as commandline", exc_info=True) errors.report(f"Error parsing line {line} as commandline", exc_info=True)
args = {"prompt": line} args = {"prompt": line}
else: else:
args = {"prompt": line} args = {"prompt": line}