Progress#
Progress callbacks for monitoring build operations.
You can implement the ProgressCallback protocol to receive progress updates,
or use one of the built-in implementations.
from rattler_build.progress import (
ProgressCallback,
SimpleProgressCallback,
RichProgressCallback,
create_callback,
)
Creating Callbacks#
create_callback#
Create a progress callback of the specified style.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
style
|
Literal['simple', 'rich'] | None
|
Style of callback - "simple", "rich", or None for no output |
'simple'
|
show_logs
|
bool
|
Show logs in rich output (only used with style="rich") |
True
|
show_details
|
bool
|
Show detailed progress information (only used with style="rich") |
False
|
Returns:
| Type | Description |
|---|---|
ProgressCallback
|
A progress callback instance |
Built-in Callbacks#
SimpleProgressCallback#
Simple console-based progress callback.
Prints progress updates to the console with simple formatting.
Example
on_download_progress #
Print download progress (only at 25% intervals to avoid spam).
RichProgressCallback#
Rich-based progress callback with beautiful terminal output.
Automatically creates progress bars for long-running operations by parsing log messages. Shows spinners for operations and bars for downloads.
Requires the 'rich' library to be installed: pip install rich
Example
__init__ #
Initialize the Rich progress callback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
show_logs
|
bool
|
Whether to display all log messages (default: True - recommended for debugging) |
True
|
show_details
|
bool
|
Whether to show detailed logs like index operations (default: False) |
False
|
Protocol#
ProgressCallback#
Bases: Protocol
Protocol for progress callbacks.
Implement this protocol to receive progress updates during builds. All methods are optional - only implement the ones you need.
Example
on_download_start #
Called when a download starts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
DownloadStartEvent
|
Event containing download URL and expected total bytes |
required |
on_download_progress #
Called periodically during download to report progress.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
DownloadProgressEvent
|
Event containing bytes downloaded and total bytes |
required |
on_download_complete #
Called when a download completes successfully.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
DownloadCompleteEvent
|
Event containing the download URL |
required |
on_build_step #
Called when a new build step begins.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
BuildStepEvent
|
Event containing step name and message |
required |