Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
doc
  • Loading branch information
grundprinzip committed Mar 22, 2024
commit 7cedd98cc4acc4bc1e93d19d7404df1b3eb759a8
15 changes: 13 additions & 2 deletions python/pyspark/sql/connect/shell/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def __init__(
char str the Default character to be used for printing the bar.
min_width numeric The minimum width of the progress bar
output file The output device to write the progress bar to.
enabled bool Whether the progress bar printing should be enabled or not.
handlers list A list of handlers that will be called when the progress bar is updated.
"""
self._ticks = 0
self._tick = 0
Expand Down Expand Up @@ -98,7 +100,16 @@ def _notify(self, done: bool = False):
def update_ticks(self, ticks: int, current: int, bytes_read: int, inflight_tasks: int) -> None:
"""This method is called from the execution to update the progress bar with a new total
tick counter and the current position. This is necessary in case new stages get added with
new tasks and so the total task number will be updated as well."""
new tasks and so the total task number will be updated as well.

Parameters
==========
ticks int The total number of ticks to be processed
current int The current tick position
bytes_read int The number of bytes read
inflight_tasks int The number of tasks that are currently running

"""
if ticks > 0 and current != self._tick:
self._ticks = ticks
self._tick = current
Expand All @@ -109,7 +120,7 @@ def update_ticks(self, ticks: int, current: int, bytes_read: int, inflight_tasks
self._notify(False)

def finish(self):
"""Clear the last line"""
"""Clear the last line. Called when the processing is done."""
self._notify(True)
if self._enabled:
print("\r" + " " * self._max_printed, end="", flush=True, file=self._out)
Expand Down