MCPcopy Index your code
hub / github.com/dask/dask / ProgressBar

Class ProgressBar

dask/diagnostics/progress.py:32–153  ·  view source on GitHub ↗

A progress bar for dask. Parameters ---------- minimum : int, optional Minimum time threshold in seconds before displaying a progress bar. Default is 0 (always display) width : int, optional Width of the bar dt : float, optional Update resolution

Source from the content-addressed store, hash-verified

30
31
32class ProgressBar(Callback):
33 """A progress bar for dask.
34
35 Parameters
36 ----------
37 minimum : int, optional
38 Minimum time threshold in seconds before displaying a progress bar.
39 Default is 0 (always display)
40 width : int, optional
41 Width of the bar
42 dt : float, optional
43 Update resolution in seconds, default is 0.1 seconds
44 out : file object, optional
45 File object to which the progress bar will be written
46 It can be ``sys.stdout``, ``sys.stderr`` or any other file object able to write ``str`` objects
47 Default is ``sys.stdout``
48
49 Examples
50 --------
51
52 Below we create a progress bar with a minimum threshold of 1 second before
53 displaying. For cheap computations nothing is shown:
54
55 >>> with ProgressBar(minimum=1.0): # doctest: +SKIP
56 ... out = some_fast_computation.compute()
57
58 But for expensive computations a full progress bar is displayed:
59
60 >>> with ProgressBar(minimum=1.0): # doctest: +SKIP
61 ... out = some_slow_computation.compute()
62 [########################################] | 100% Completed | 10.4 s
63
64 The duration of the last computation is available as an attribute
65
66 >>> pbar = ProgressBar() # doctest: +SKIP
67 >>> with pbar: # doctest: +SKIP
68 ... out = some_computation.compute()
69 [########################################] | 100% Completed | 10.4 s
70 >>> pbar.last_duration # doctest: +SKIP
71 10.4
72
73 You can also register a progress bar so that it displays for all
74 computations:
75
76 >>> pbar = ProgressBar() # doctest: +SKIP
77 >>> pbar.register() # doctest: +SKIP
78 >>> some_slow_computation.compute() # doctest: +SKIP
79 [########################################] | 100% Completed | 10.4 s
80 """
81
82 def __init__(self, minimum=0, width=40, dt=0.1, out=None):
83 if out is None:
84 # Warning, on windows, stdout can still be None if
85 # an application is started as GUI Application
86 # https://docs.python.org/3/library/sys.html#sys.__stderr__
87 out = sys.stdout
88 self._minimum = minimum
89 self._width = width

Callers 9

test_array_computeFunction · 0.90
test_progressbarFunction · 0.90
test_minimum_timeFunction · 0.90
test_clean_exitFunction · 0.90
test_registerFunction · 0.90
test_no_tasksFunction · 0.90
test_with_cacheFunction · 0.90
test_with_aliasFunction · 0.90
test_store_timeFunction · 0.90

Calls

no outgoing calls

Tested by 9

test_array_computeFunction · 0.72
test_progressbarFunction · 0.72
test_minimum_timeFunction · 0.72
test_clean_exitFunction · 0.72
test_registerFunction · 0.72
test_no_tasksFunction · 0.72
test_with_cacheFunction · 0.72
test_with_aliasFunction · 0.72
test_store_timeFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…