Track progress by iterating over a sequence. You can also track progress of an iterable, which might require that you additionally specify ``total``. Args: sequence (Iterable[ProgressType]): Values you wish to iterate over and track progress. description (str, optional): De
(
sequence: Iterable[ProgressType],
description: str = "Working...",
total: Optional[float] = None,
completed: int = 0,
auto_refresh: bool = True,
console: Optional[Console] = None,
transient: bool = False,
get_time: Optional[Callable[[], float]] = None,
refresh_per_second: float = 10,
style: StyleType = "bar.back",
complete_style: StyleType = "bar.complete",
finished_style: StyleType = "bar.finished",
pulse_style: StyleType = "bar.pulse",
update_period: float = 0.1,
disable: bool = False,
show_speed: bool = True,
)
| 102 | |
| 103 | |
| 104 | def track( |
| 105 | sequence: Iterable[ProgressType], |
| 106 | description: str = "Working...", |
| 107 | total: Optional[float] = None, |
| 108 | completed: int = 0, |
| 109 | auto_refresh: bool = True, |
| 110 | console: Optional[Console] = None, |
| 111 | transient: bool = False, |
| 112 | get_time: Optional[Callable[[], float]] = None, |
| 113 | refresh_per_second: float = 10, |
| 114 | style: StyleType = "bar.back", |
| 115 | complete_style: StyleType = "bar.complete", |
| 116 | finished_style: StyleType = "bar.finished", |
| 117 | pulse_style: StyleType = "bar.pulse", |
| 118 | update_period: float = 0.1, |
| 119 | disable: bool = False, |
| 120 | show_speed: bool = True, |
| 121 | ) -> Iterable[ProgressType]: |
| 122 | """Track progress by iterating over a sequence. |
| 123 | |
| 124 | You can also track progress of an iterable, which might require that you additionally specify ``total``. |
| 125 | |
| 126 | Args: |
| 127 | sequence (Iterable[ProgressType]): Values you wish to iterate over and track progress. |
| 128 | description (str, optional): Description of task show next to progress bar. Defaults to "Working". |
| 129 | total: (float, optional): Total number of steps. Default is len(sequence). |
| 130 | completed (int, optional): Number of steps completed so far. Defaults to 0. |
| 131 | auto_refresh (bool, optional): Automatic refresh, disable to force a refresh after each iteration. Default is True. |
| 132 | transient: (bool, optional): Clear the progress on exit. Defaults to False. |
| 133 | console (Console, optional): Console to write to. Default creates internal Console instance. |
| 134 | refresh_per_second (float): Number of times per second to refresh the progress information. Defaults to 10. |
| 135 | style (StyleType, optional): Style for the bar background. Defaults to "bar.back". |
| 136 | complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete". |
| 137 | finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished". |
| 138 | pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse". |
| 139 | update_period (float, optional): Minimum time (in seconds) between calls to update(). Defaults to 0.1. |
| 140 | disable (bool, optional): Disable display of progress. |
| 141 | show_speed (bool, optional): Show speed if total isn't known. Defaults to True. |
| 142 | Returns: |
| 143 | Iterable[ProgressType]: An iterable of the values in the sequence. |
| 144 | |
| 145 | """ |
| 146 | |
| 147 | columns: List["ProgressColumn"] = ( |
| 148 | [TextColumn("[progress.description]{task.description}")] if description else [] |
| 149 | ) |
| 150 | columns.extend( |
| 151 | ( |
| 152 | BarColumn( |
| 153 | style=style, |
| 154 | complete_style=complete_style, |
| 155 | finished_style=finished_style, |
| 156 | pulse_style=pulse_style, |
| 157 | ), |
| 158 | TaskProgressColumn(show_speed=show_speed), |
| 159 | TimeRemainingColumn(elapsed_when_finished=True), |
| 160 | ) |
| 161 | ) |