Migrate imports to SYS package (pipeline/result_table) and update related imports
Some checks failed
smoke-mm / Install & smoke test mm --help (push) Has been cancelled

This commit is contained in:
2025-12-29 23:28:15 -08:00
parent 30d3bf480b
commit ef01ca03a0
60 changed files with 162 additions and 149 deletions

View File

@@ -28,7 +28,7 @@ import httpx
from SYS.logger import log, debug
from SYS.utils import ensure_directory, sha256_file
from API.HTTP import HTTPClient
from models import DownloadError, DownloadOptions, DownloadMediaResult, DebugLogger, ProgressBar
from SYS.models import DownloadError, DownloadOptions, DownloadMediaResult, DebugLogger, ProgressBar
try:
import yt_dlp # type: ignore
@@ -40,7 +40,7 @@ else:
YTDLP_IMPORT_ERROR = None
try:
from metadata import extract_ytdlp_tags
from SYS.metadata import extract_ytdlp_tags
except ImportError:
extract_ytdlp_tags = None

View File

@@ -5,7 +5,7 @@ import inspect
import threading
from pathlib import Path
from rich_display import console_for
from SYS.rich_display import console_for
_DEBUG_ENABLED = False
_thread_local = threading.local()

4134
SYS/metadata.py Normal file

File diff suppressed because it is too large Load Diff

1641
SYS/models.py Normal file

File diff suppressed because it is too large Load Diff

1044
SYS/pipeline.py Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -184,7 +184,7 @@ class PipelineProgress:
return False
try:
from models import PipelineLiveProgress
from SYS.models import PipelineLiveProgress
ui = PipelineLiveProgress([str(label or "pipeline")], enabled=True)
ui.start()

View File

@@ -8,7 +8,7 @@ from __future__ import annotations
import sys
from models import ProgressBar
from SYS.models import ProgressBar
_BAR = ProgressBar()

1763
SYS/result_table.py Normal file

File diff suppressed because it is too large Load Diff

72
SYS/rich_display.py Normal file
View File

@@ -0,0 +1,72 @@
"""Central Rich output helpers.
Opinionated: `rich` is a required dependency.
This module centralizes Console instances so tables/panels render consistently and
so callers can choose stdout vs stderr explicitly (important for pipeline-safe
output).
"""
from __future__ import annotations
import contextlib
import sys
from typing import Any, Iterator, TextIO
from rich.console import Console
# Configure Rich pretty-printing to avoid truncating long strings (hashes/paths).
# This is version-safe: older Rich versions may not support the max_* arguments.
try:
from rich.pretty import install as _pretty_install
try:
_pretty_install(max_string=100_000, max_length=100_000)
except TypeError:
_pretty_install()
except Exception:
pass
_STDOUT_CONSOLE = Console(file=sys.stdout)
_STDERR_CONSOLE = Console(file=sys.stderr)
def stdout_console() -> Console:
return _STDOUT_CONSOLE
def stderr_console() -> Console:
return _STDERR_CONSOLE
def console_for(file: TextIO | None) -> Console:
if file is None or file is sys.stdout:
return _STDOUT_CONSOLE
if file is sys.stderr:
return _STDERR_CONSOLE
return Console(file=file)
def rprint(renderable: Any = "", *, file: TextIO | None = None) -> None:
console_for(file).print(renderable)
@contextlib.contextmanager
def capture_rich_output(*, stdout: TextIO, stderr: TextIO) -> Iterator[None]:
"""Temporarily redirect Rich output helpers to provided streams.
Note: `stdout_console()` / `stderr_console()` use global Console instances,
so `contextlib.redirect_stdout` alone will not capture Rich output.
"""
global _STDOUT_CONSOLE, _STDERR_CONSOLE
previous_stdout = _STDOUT_CONSOLE
previous_stderr = _STDERR_CONSOLE
try:
_STDOUT_CONSOLE = Console(file=stdout)
_STDERR_CONSOLE = Console(file=stderr)
yield
finally:
_STDOUT_CONSOLE = previous_stdout
_STDERR_CONSOLE = previous_stderr