Skip to content

progress_panel

anomaly_match_ui.widgets.progress_panel

Reusable progress bar with status label and ETA tracking.

ProgressPanel(bar_color=ESA_GREEN)

A progress bar with a status label and a waiting spinner.

Parameters:

Name Type Description Default
bar_color str

Initial color of the progress bar.

ESA_GREEN
Source code in anomaly_match_ui/widgets/progress_panel.py
def __init__(self, bar_color: str = ESA_GREEN) -> None:
    self.progress_bar = widgets.FloatProgress(
        value=0.0,
        min=0.0,
        max=1.0,
        layout=widgets.Layout(background_color=BG_COLOR),
        style={"bar_color": bar_color},
    )

    # Shown from start() until the bar first moves: subprocess startup
    # (model load, Cutana orchestrator init, first tile stream) can take
    # minutes with the bar at 0, which otherwise looks like a hang.
    self.spinner = widgets.HTML(value="", layout=widgets.Layout(width="20px"))
    self._waiting = False
    self.progress_bar.observe(self._on_value_change, names="value")

    self.status_label = widgets.Label(
        value="",
        layout=widgets.Layout(background_color=BG_COLOR),
        style={"color": "white"},
    )

set_color(color)

Change the progress bar color.

Parameters:

Name Type Description Default
color str

CSS color string.

required
Source code in anomaly_match_ui/widgets/progress_panel.py
def set_color(self, color: str) -> None:
    """Change the progress bar color.

    Args:
        color: CSS color string.
    """
    self.progress_bar.style = {"bar_color": color}

start(message)

Reset the bar for a new run and spin until the first progress.

Parameters:

Name Type Description Default
message str

Status text to display while waiting.

required
Source code in anomaly_match_ui/widgets/progress_panel.py
def start(self, message: str) -> None:
    """Reset the bar for a new run and spin until the first progress.

    Args:
        message: Status text to display while waiting.
    """
    self.update(0.0, message)
    self._set_waiting(True)

stop()

End the waiting spinner: the run finished, failed or was stopped.

Source code in anomaly_match_ui/widgets/progress_panel.py
def stop(self) -> None:
    """End the waiting spinner: the run finished, failed or was stopped."""
    self._set_waiting(False)

update(value, message)

Update progress value and status message.

Parameters:

Name Type Description Default
value float

Progress fraction between 0.0 and 1.0.

required
message str

Status text to display.

required
Source code in anomaly_match_ui/widgets/progress_panel.py
def update(self, value: float, message: str) -> None:
    """Update progress value and status message.

    Args:
        value: Progress fraction between 0.0 and 1.0.
        message: Status text to display.
    """
    self.progress_bar.value = value
    self.status_label.value = message