Progress: Switch to Rich
Rich is a more mature library for displaying progress bars, logging, and console output. This should help properly align progress bars within the terminal. Side note: "We're Rich!" Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
parent
39617adb65
commit
fe0ff240e7
6 changed files with 55 additions and 24 deletions
|
|
@ -2,6 +2,14 @@
|
|||
|
||||
import traceback
|
||||
from pydantic import BaseModel
|
||||
from rich.progress import (
|
||||
Progress,
|
||||
TextColumn,
|
||||
BarColumn,
|
||||
TimeRemainingColumn,
|
||||
TaskProgressColumn,
|
||||
MofNCompleteColumn,
|
||||
)
|
||||
from typing import Optional
|
||||
|
||||
from common.logger import init_logger
|
||||
|
|
@ -58,6 +66,18 @@ def get_sse_packet(json_data: str):
|
|||
return f"data: {json_data}\n\n"
|
||||
|
||||
|
||||
def get_loading_progress_bar():
|
||||
"""Gets a pre-made progress bar for loading tasks."""
|
||||
|
||||
return Progress(
|
||||
TextColumn("[progress.description]{task.description}"),
|
||||
BarColumn(),
|
||||
TaskProgressColumn(),
|
||||
MofNCompleteColumn(),
|
||||
TimeRemainingColumn(),
|
||||
)
|
||||
|
||||
|
||||
def unwrap(wrapped, default=None):
|
||||
"""Unwrap function for Optionals."""
|
||||
if wrapped is None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue