configurable tracebacks

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-01-31 10:02:21 -05:00
parent 3dcb70e8a2
commit 3a6471d984
4 changed files with 42 additions and 27 deletions
+7 -2
View File
@@ -1,11 +1,16 @@
# Change Log for SD.Next
## Update for 2025-01-30
## Update for 2025-01-31
- **Torch**:
- for cuda environemnts set default to `torch==2.6.0+cu126`
- add support for torch **tunable ops**, this can speed up operations by up to 10-30% on some platforms
*note*: to avoid disruptions sdnext does not perform torch install during in-place upgrades
to force torch upgrade, either start with new installation or use `--reinstall` flag
- add support for torch **tunable ops**, this can speed up operations by up to *10-30%* on some platforms
*set in settings -> backend settings -> torch* and *paths -> tunable ops cache*
- enhanced error logging
- **Refactor**:
- unified trace handler with configurable tracebacks
- **Fixes**:
- photomaker with offloading
- photomaker with refine
+30 -4
View File
@@ -67,6 +67,25 @@ except Exception:
ts = lambda *args, **kwargs: None # pylint: disable=unnecessary-lambda-assignment
def install_traceback(suppress: list = []):
from rich.traceback import install as traceback_install
from rich.pretty import install as pretty_install
traceback_install(
console=console,
extra_lines=os.environ.get('SD_TRACELINES', 1),
max_frames=os.environ.get('SD_TRACEFRAMES', 16),
width=os.environ.get('SD_TRACEWIDTH', console.width),
code_width=os.environ.get('SD_TRACEWIDTH', console.width) - 12,
word_wrap=os.environ.get('SD_TRACEWRAP', False),
indent_guides=os.environ.get('SD_TRACEINDENT', False),
show_locals=os.environ.get('SD_TRACELOCALS', False),
locals_hide_dunder=os.environ.get('SD_TRACEDUNDER', True),
locals_hide_sunder=os.environ.get('SD_TRACESUNDER', None),
suppress=suppress,
)
pretty_install(console=console)
# setup console and file logging
def setup_logging():
@@ -101,7 +120,6 @@ def setup_logging():
from rich.console import Console
from rich import print as rprint
from rich.pretty import install as pretty_install
from rich.traceback import install as traceback_install
if args.log:
global log_file # pylint: disable=global-statement
@@ -116,17 +134,25 @@ def setup_logging():
log.setLevel(logging.DEBUG) # log to file is always at level debug for facility `sd`
log.print = rprint
global console # pylint: disable=global-statement
console = Console(log_time=True, log_time_format='%H:%M:%S-%f', theme=Theme({
theme = Theme({
"traceback.border": "black",
"traceback.border.syntax_error": "black",
"inspect.value.border": "black",
"logging.level.info": "blue_violet",
"logging.level.debug": "purple4",
"logging.level.trace": "dark_blue",
}))
})
console = Console(
log_time=True,
log_time_format='%H:%M:%S-%f',
tab_size=4,
soft_wrap=True,
safe_box=True,
theme=theme,
)
logging.basicConfig(level=logging.ERROR, format='%(asctime)s | %(name)s | %(levelname)s | %(module)s | %(message)s', handlers=[logging.NullHandler()]) # redirect default logger to null
pretty_install(console=console)
traceback_install(console=console, extra_lines=1, max_frames=16, width=console.width, word_wrap=False, indent_guides=False, suppress=[])
install_traceback()
while log.hasHandlers() and len(log.handlers) > 0:
log.removeHandler(log.handlers[0])
+4 -20
View File
@@ -1,33 +1,17 @@
import logging
import warnings
from installer import log as installer_log, setup_logging
from installer import log, console, setup_logging, install_traceback
setup_logging()
log = installer_log
from rich.console import Console # pylint: disable=wrong-import-order
from rich.theme import Theme # pylint: disable=wrong-import-order
from rich.pretty import install as pretty_install # pylint: disable=wrong-import-order
from rich.traceback import install as traceback_install # pylint: disable=wrong-import-order
console = Console(log_time=True, tab_size=4, log_time_format='%H:%M:%S-%f', soft_wrap=True, safe_box=True, 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, max_frames=16)
install_traceback()
already_displayed = {}
def install(suppress=[]):
warnings.filterwarnings("ignore", category=UserWarning)
pretty_install(console=console)
traceback_install(console=console, extra_lines=1, width=console.width, word_wrap=False, indent_guides=False, suppress=suppress)
install_traceback(suppress=suppress)
logging.basicConfig(level=logging.ERROR, format='%(asctime)s | %(levelname)s | %(pathname)s | %(message)s')
# for handler in logging.getLogger().handlers:
# handler.setLevel(logging.INFO)
def print_error_explanation(message):
+1 -1
Submodule wiki updated: 4cd60a379d...484f2af70e