Renders an auto-updating progress bar(s). Args: console (Console, optional): Optional Console instance. Defaults to an internal Console instance writing to stdout. auto_refresh (bool, optional): Enable auto refresh. If disabled, you will need to call `refresh()`. refresh
| 1059 | |
| 1060 | |
| 1061 | class Progress(JupyterMixin): |
| 1062 | """Renders an auto-updating progress bar(s). |
| 1063 | |
| 1064 | Args: |
| 1065 | console (Console, optional): Optional Console instance. Defaults to an internal Console instance writing to stdout. |
| 1066 | auto_refresh (bool, optional): Enable auto refresh. If disabled, you will need to call `refresh()`. |
| 1067 | refresh_per_second (float, optional): Number of times per second to refresh the progress information. Defaults to 10. |
| 1068 | speed_estimate_period: (float, optional): Period (in seconds) used to calculate the speed estimate. Defaults to 30. |
| 1069 | transient: (bool, optional): Clear the progress on exit. Defaults to False. |
| 1070 | redirect_stdout: (bool, optional): Enable redirection of stdout, so ``print`` may be used. Defaults to True. |
| 1071 | redirect_stderr: (bool, optional): Enable redirection of stderr. Defaults to True. |
| 1072 | get_time: (Callable, optional): A callable that gets the current time, or None to use Console.get_time. Defaults to None. |
| 1073 | disable (bool, optional): Disable progress display. Defaults to False |
| 1074 | expand (bool, optional): Expand tasks table to fit width. Defaults to False. |
| 1075 | """ |
| 1076 | |
| 1077 | def __init__( |
| 1078 | self, |
| 1079 | *columns: Union[str, ProgressColumn], |
| 1080 | console: Optional[Console] = None, |
| 1081 | auto_refresh: bool = True, |
| 1082 | refresh_per_second: float = 10, |
| 1083 | speed_estimate_period: float = 30.0, |
| 1084 | transient: bool = False, |
| 1085 | redirect_stdout: bool = True, |
| 1086 | redirect_stderr: bool = True, |
| 1087 | get_time: Optional[GetTimeCallable] = None, |
| 1088 | disable: bool = False, |
| 1089 | expand: bool = False, |
| 1090 | ) -> None: |
| 1091 | assert refresh_per_second > 0, "refresh_per_second must be > 0" |
| 1092 | self._lock = RLock() |
| 1093 | self.columns = columns or self.get_default_columns() |
| 1094 | self.speed_estimate_period = speed_estimate_period |
| 1095 | |
| 1096 | self.disable = disable |
| 1097 | self.expand = expand |
| 1098 | self._tasks: Dict[TaskID, Task] = {} |
| 1099 | self._task_index: TaskID = TaskID(0) |
| 1100 | self.live = Live( |
| 1101 | console=console or get_console(), |
| 1102 | auto_refresh=auto_refresh, |
| 1103 | refresh_per_second=refresh_per_second, |
| 1104 | transient=transient, |
| 1105 | redirect_stdout=redirect_stdout, |
| 1106 | redirect_stderr=redirect_stderr, |
| 1107 | get_renderable=self.get_renderable, |
| 1108 | ) |
| 1109 | self.get_time = get_time or self.console.get_time |
| 1110 | self.print = self.console.print |
| 1111 | self.log = self.console.log |
| 1112 | |
| 1113 | @classmethod |
| 1114 | def get_default_columns(cls) -> Tuple[ProgressColumn, ...]: |
| 1115 | """Get the default columns used for a new Progress instance: |
| 1116 | - a text column for the description (TextColumn) |
| 1117 | - the bar itself (BarColumn) |
| 1118 | - a text column showing completion percentage (TextColumn) |
no outgoing calls