cs-progress 20240412__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cs.progress-20240412/MANIFEST.in +1 -0
- cs.progress-20240412/PKG-INFO +597 -0
- cs.progress-20240412/README.md +578 -0
- cs.progress-20240412/lib/python/cs/progress.py +1117 -0
- cs.progress-20240412/lib/python/cs.progress.egg-info/PKG-INFO +597 -0
- cs.progress-20240412/lib/python/cs.progress.egg-info/SOURCES.txt +9 -0
- cs.progress-20240412/lib/python/cs.progress.egg-info/dependency_links.txt +1 -0
- cs.progress-20240412/lib/python/cs.progress.egg-info/requires.txt +9 -0
- cs.progress-20240412/lib/python/cs.progress.egg-info/top_level.txt +1 -0
- cs.progress-20240412/pyproject.toml +635 -0
- cs.progress-20240412/setup.cfg +4 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include README.md
|
|
@@ -0,0 +1,597 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: cs.progress
|
|
3
|
+
Version: 20240412
|
|
4
|
+
Summary: A progress tracker with methods for throughput, ETA and update notification; also a compound progress meter composed from other progress meters.
|
|
5
|
+
Author-email: Cameron Simpson <cs@cskk.id.au>
|
|
6
|
+
License: GNU General Public License v3 or later (GPLv3+)
|
|
7
|
+
Project-URL: URL, https://bitbucket.org/cameron_simpson/css/commits/all
|
|
8
|
+
Keywords: python2,python3
|
|
9
|
+
Platform: UNKNOWN
|
|
10
|
+
Classifier: Programming Language :: Python
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
16
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
A progress tracker with methods for throughput, ETA and update notification;
|
|
20
|
+
also a compound progress meter composed from other progress meters.
|
|
21
|
+
|
|
22
|
+
*Latest release 20240412*:
|
|
23
|
+
* BaseProgress.status: fixes for the arrow_width computation.
|
|
24
|
+
* BaseProgress.bar: drop existing UpdProxy support, drop deferred, implement update_period using a ticker Thread.
|
|
25
|
+
* BaseProgress.bar: set update_period=DEFAULT_UPDATE_PERIOD by default.
|
|
26
|
+
* Progress.iterbar: drop preexisting UpdProxy support, update_frequency and update_min_size support.
|
|
27
|
+
* Progress: new advance_total(delta) method so that we have a callable for this.
|
|
28
|
+
* BaseProgress.bar: new optional poll parameter accepting a callable accepting a BaseProgress to update the state before updating the bar display.
|
|
29
|
+
* BaseProgress.bar: new stalled='stalled' parameter to specify the term for no recent throughput, workers might prefer 'idle'.
|
|
30
|
+
* progressbar() updated to match.
|
|
31
|
+
|
|
32
|
+
## Function `auto_progressbar(*da, **dkw)`
|
|
33
|
+
|
|
34
|
+
Decorator for a function accepting an optional `progress`
|
|
35
|
+
keyword parameter.
|
|
36
|
+
If `progress` is `None` and the default `Upd` is not disabled,
|
|
37
|
+
run the function with a progress bar.
|
|
38
|
+
|
|
39
|
+
## Class `BaseProgress`
|
|
40
|
+
|
|
41
|
+
The base class for `Progress` and `OverProcess`
|
|
42
|
+
with various common methods.
|
|
43
|
+
|
|
44
|
+
Note that durations are in seconds
|
|
45
|
+
and that absolute time is in seconds since the UNIX epoch
|
|
46
|
+
(the basis of `time.time()`).
|
|
47
|
+
|
|
48
|
+
*Method `BaseProgress.__init__(self, name=None, start_time=None, units_scale=None)`*:
|
|
49
|
+
Initialise a progress instance.
|
|
50
|
+
|
|
51
|
+
Parameters:
|
|
52
|
+
* `name`: optional name
|
|
53
|
+
* `start_time`: optional UNIX epoch start time, default from `time.time()`
|
|
54
|
+
* `units_scale`: a scale for use with `cs.units.transcribe`,
|
|
55
|
+
default `BINARY_BYTES_SCALE`
|
|
56
|
+
|
|
57
|
+
*Method `BaseProgress.__eq__(self, other)`*:
|
|
58
|
+
A Progress is equal to another object `other`
|
|
59
|
+
if its position equals `int(other)`.
|
|
60
|
+
|
|
61
|
+
*Method `BaseProgress.__ge__(self, other, NotImplemented=NotImplemented)`*:
|
|
62
|
+
Return a >= b. Computed by @total_ordering from (not a < b).
|
|
63
|
+
|
|
64
|
+
*Method `BaseProgress.__gt__(self, other, NotImplemented=NotImplemented)`*:
|
|
65
|
+
Return a > b. Computed by @total_ordering from (not a < b) and (a != b).
|
|
66
|
+
|
|
67
|
+
*Method `BaseProgress.__int__(self)`*:
|
|
68
|
+
`int(Progress)` returns the current position.
|
|
69
|
+
|
|
70
|
+
*Method `BaseProgress.__le__(self, other, NotImplemented=NotImplemented)`*:
|
|
71
|
+
Return a <= b. Computed by @total_ordering from (a < b) or (a == b).
|
|
72
|
+
|
|
73
|
+
*Method `BaseProgress.__lt__(self, other)`*:
|
|
74
|
+
A Progress is less then another object `other`
|
|
75
|
+
if its position is less than `int(other)`.
|
|
76
|
+
|
|
77
|
+
*Method `BaseProgress.arrow(self, width, no_padding=False)`*:
|
|
78
|
+
Construct a progress arrow representing completion
|
|
79
|
+
to fit in the specified `width`.
|
|
80
|
+
|
|
81
|
+
*Method `BaseProgress.bar(*a, upd: Optional[cs.upd.Upd] = <function uses_upd.<locals>.<lambda> at 0x110fbd6c0>, **kw)`*:
|
|
82
|
+
A context manager to create and withdraw a progress bar.
|
|
83
|
+
It returns the `UpdProxy` which displays the progress bar.
|
|
84
|
+
|
|
85
|
+
Parameters:
|
|
86
|
+
* `label`: a label for the progress bar,
|
|
87
|
+
default from `self.name`.
|
|
88
|
+
* `statusfunc`: an optional function to compute the progress bar text
|
|
89
|
+
accepting `(self,label,width)`.
|
|
90
|
+
* `width`: an optional width expressing how wide the progress bar
|
|
91
|
+
text may be.
|
|
92
|
+
The default comes from the `proxy.width` property.
|
|
93
|
+
* `recent_window`: optional timeframe to define "recent" in seconds;
|
|
94
|
+
if the default `statusfunc` (`Progress.status`) is used
|
|
95
|
+
this is passed to it
|
|
96
|
+
* `report_print`: optional `print` compatible function
|
|
97
|
+
with which to write a report on completion;
|
|
98
|
+
this may also be a `bool`, which if true will use `Upd.print`
|
|
99
|
+
in order to interoperate with `Upd`.
|
|
100
|
+
* `stalled`: optional string to replace the word `'stalled'`
|
|
101
|
+
in the status line; for a worked this might be betteer as `'idle'`
|
|
102
|
+
* `insert_pos`: where to insert the progress bar, default `1`
|
|
103
|
+
* `poll`: an optional callable accepting a `BaseProgress`
|
|
104
|
+
which can be used to update the progress state before
|
|
105
|
+
updating the progress bar display
|
|
106
|
+
|
|
107
|
+
Example use:
|
|
108
|
+
|
|
109
|
+
# display progress reporting during upload_filename()
|
|
110
|
+
# which updates the supplied Progress instance
|
|
111
|
+
# during its operation
|
|
112
|
+
P = Progress(name=label)
|
|
113
|
+
with P.bar(report_print=True):
|
|
114
|
+
upload_filename(src, progress=P)
|
|
115
|
+
|
|
116
|
+
*Property `BaseProgress.elapsed_time`*:
|
|
117
|
+
Time elapsed since `start_time`.
|
|
118
|
+
|
|
119
|
+
*Property `BaseProgress.eta`*:
|
|
120
|
+
The projected time of completion: now + `remaining_time`.
|
|
121
|
+
|
|
122
|
+
If `remaining_time` is `None`, this is also `None`.
|
|
123
|
+
|
|
124
|
+
*Method `BaseProgress.format_counter(self, value, scale=None, max_parts=2, sep=',', **kw)`*:
|
|
125
|
+
Format `value` accoridng to `scale` and `max_parts`
|
|
126
|
+
using `cs.units.transcribe`.
|
|
127
|
+
|
|
128
|
+
*Method `BaseProgress.iterbar(self, it, label=None, *, itemlenfunc=None, incfirst=False, update_period=0.3, **bar_kw)`*:
|
|
129
|
+
An iterable progress bar: a generator yielding values
|
|
130
|
+
from the iterable `it` while updating a progress bar.
|
|
131
|
+
|
|
132
|
+
Parameters:
|
|
133
|
+
* `it`: the iterable to consume and yield.
|
|
134
|
+
* `label`: a label for the progress bar,
|
|
135
|
+
default from `self.name`.
|
|
136
|
+
* `itemlenfunc`: an optional function returning the "size" of each item
|
|
137
|
+
from `it`, used to advance `self.position`.
|
|
138
|
+
The default is to assume a size of `1`.
|
|
139
|
+
A convenient alternative choice may be the builtin function `len`.
|
|
140
|
+
* `incfirst`: whether to advance `self.position` before we
|
|
141
|
+
`yield` an item from `it` or afterwards.
|
|
142
|
+
This reflects whether it is considered that progress is
|
|
143
|
+
made as items are obtained or only after items are processed
|
|
144
|
+
by whatever is consuming this generator.
|
|
145
|
+
The default is `False`, advancing after processing.
|
|
146
|
+
* `update_period`: default `DEFAULT_UPDATE_PERIOD`; if `0`
|
|
147
|
+
then update on every iteration, otherwise every `update_period`
|
|
148
|
+
seconds
|
|
149
|
+
Other parameters are passed to `Progress.bar`.
|
|
150
|
+
|
|
151
|
+
Example use:
|
|
152
|
+
|
|
153
|
+
from cs.units import DECIMAL_SCALE
|
|
154
|
+
rows = [some list of data]
|
|
155
|
+
P = Progress(total=len(rows), units_scale=DECIMAL_SCALE)
|
|
156
|
+
for row in P.iterbar(rows, incfirst=True):
|
|
157
|
+
... do something with each row ...
|
|
158
|
+
|
|
159
|
+
f = open(data_filename, 'rb')
|
|
160
|
+
datalen = os.stat(f).st_size
|
|
161
|
+
def readfrom(f):
|
|
162
|
+
while True:
|
|
163
|
+
bs = f.read(65536)
|
|
164
|
+
if not bs:
|
|
165
|
+
break
|
|
166
|
+
yield bs
|
|
167
|
+
P = Progress(total=datalen)
|
|
168
|
+
for bs in P.iterbar(readfrom(f), itemlenfunc=len):
|
|
169
|
+
... process the file data in bs ...
|
|
170
|
+
|
|
171
|
+
*Property `BaseProgress.ratio`*:
|
|
172
|
+
The fraction of progress completed: `(position-start)/(total-start)`.
|
|
173
|
+
Returns `None` if `total` is `None` or `total<=start`.
|
|
174
|
+
|
|
175
|
+
Example:
|
|
176
|
+
|
|
177
|
+
>>> P = Progress()
|
|
178
|
+
P.ratio
|
|
179
|
+
>>> P.total = 16
|
|
180
|
+
>>> P.ratio
|
|
181
|
+
0.0
|
|
182
|
+
>>> P.update(4)
|
|
183
|
+
>>> P.ratio
|
|
184
|
+
0.25
|
|
185
|
+
|
|
186
|
+
*Property `BaseProgress.remaining_time`*:
|
|
187
|
+
The projected time remaining to end
|
|
188
|
+
based on the `throughput` and `total`.
|
|
189
|
+
|
|
190
|
+
If `total` is `None`, this is `None`.
|
|
191
|
+
|
|
192
|
+
*Method `BaseProgress.status(self, label, width, recent_window=None, stalled=None)`*:
|
|
193
|
+
A progress string of the form:
|
|
194
|
+
*label*`: `*pos*`/`*total*` ==> ETA '*time*
|
|
195
|
+
|
|
196
|
+
Parameters:
|
|
197
|
+
* `label`: the label for the status line;
|
|
198
|
+
if `None` use `self.name`
|
|
199
|
+
* `width`: the available width for the status line;
|
|
200
|
+
if not an `int` use `width.width`
|
|
201
|
+
* `recent_window`: optional timeframe to define "recent" in seconds,
|
|
202
|
+
default : `5`
|
|
203
|
+
* `stalled`: the label to indicate no throughput, default `'stalled'`;
|
|
204
|
+
for a worker this might often b better as `'idle'`
|
|
205
|
+
|
|
206
|
+
*Method `BaseProgress.text_pos_of_total(self, fmt=None, fmt_pos=None, fmt_total=None, pos_first=False)`*:
|
|
207
|
+
Return a "total:position" or "position/total" style progress string.
|
|
208
|
+
|
|
209
|
+
Parameters:
|
|
210
|
+
* `fmt`: format string interpolating `pos_text` and `total_text`.
|
|
211
|
+
Default: `"{pos_text}/{total_text}"` if `pos_first`,
|
|
212
|
+
otherwise `"{total_text}:{pos_text}"`
|
|
213
|
+
* `fmt_pos`: formatting function for `self.position`,
|
|
214
|
+
default `self.format_counter`
|
|
215
|
+
* `fmt_total`: formatting function for `self.total`,
|
|
216
|
+
default from `fmt_pos`
|
|
217
|
+
* `pos_first`: put the position first if true (default `False`),
|
|
218
|
+
only consulted if `fmt` is `None`
|
|
219
|
+
|
|
220
|
+
*Property `BaseProgress.throughput`*:
|
|
221
|
+
The overall throughput: `self.throughput_overall()`.
|
|
222
|
+
|
|
223
|
+
By comparison,
|
|
224
|
+
the `Progress.throughput` property is `self.throughput_recent`
|
|
225
|
+
if the `throughput_window` is not `None`,
|
|
226
|
+
otherwise it falls back to `throughput_overall`.
|
|
227
|
+
|
|
228
|
+
*Method `BaseProgress.throughput_overall(self)`*:
|
|
229
|
+
The overall throughput from `start` to `position`
|
|
230
|
+
during `elapsed_time`.
|
|
231
|
+
|
|
232
|
+
*Method `BaseProgress.throughput_recent(self, time_window)`*:
|
|
233
|
+
The recent throughput. Implemented by subclasses.
|
|
234
|
+
|
|
235
|
+
## Class `CheckPoint(builtins.tuple)`
|
|
236
|
+
|
|
237
|
+
CheckPoint(time, position)
|
|
238
|
+
|
|
239
|
+
*Property `CheckPoint.position`*:
|
|
240
|
+
Alias for field number 1
|
|
241
|
+
|
|
242
|
+
*Property `CheckPoint.time`*:
|
|
243
|
+
Alias for field number 0
|
|
244
|
+
|
|
245
|
+
## Class `OverProgress(BaseProgress)`
|
|
246
|
+
|
|
247
|
+
A `Progress`-like class computed from a set of subsidiary `Progress`es.
|
|
248
|
+
|
|
249
|
+
AN OverProgress instance has an attribute ``notify_update`` which
|
|
250
|
+
is a set of callables.
|
|
251
|
+
Whenever the position of a subsidiary `Progress` is updated,
|
|
252
|
+
each of these will be called with the `Progress` instance and `None`.
|
|
253
|
+
|
|
254
|
+
Example:
|
|
255
|
+
|
|
256
|
+
>>> P = OverProgress(name="over")
|
|
257
|
+
>>> P1 = Progress(name="progress1", position=12)
|
|
258
|
+
>>> P1.total = 100
|
|
259
|
+
>>> P1.advance(7)
|
|
260
|
+
>>> P2 = Progress(name="progress2", position=20)
|
|
261
|
+
>>> P2.total = 50
|
|
262
|
+
>>> P2.advance(9)
|
|
263
|
+
>>> P.add(P1)
|
|
264
|
+
>>> P.add(P2)
|
|
265
|
+
>>> P1.total
|
|
266
|
+
100
|
|
267
|
+
>>> P2.total
|
|
268
|
+
50
|
|
269
|
+
>>> P.total
|
|
270
|
+
150
|
|
271
|
+
>>> P1.start
|
|
272
|
+
12
|
|
273
|
+
>>> P2.start
|
|
274
|
+
20
|
|
275
|
+
>>> P.start
|
|
276
|
+
0
|
|
277
|
+
>>> P1.position
|
|
278
|
+
19
|
|
279
|
+
>>> P2.position
|
|
280
|
+
29
|
|
281
|
+
>>> P.position
|
|
282
|
+
16
|
|
283
|
+
|
|
284
|
+
*Method `OverProgress.add(self, subprogress)`*:
|
|
285
|
+
Add a subsidairy `Progress` to the contributing set.
|
|
286
|
+
|
|
287
|
+
*Property `OverProgress.eta`*:
|
|
288
|
+
The `eta` is the maximum of the subsidiary etas.
|
|
289
|
+
|
|
290
|
+
*Property `OverProgress.position`*:
|
|
291
|
+
The `position` is the sum off the subsidiary position offsets
|
|
292
|
+
from their respective starts.
|
|
293
|
+
|
|
294
|
+
*Method `OverProgress.remove(self, subprogress, accrue=False)`*:
|
|
295
|
+
Remove a subsidairy `Progress` from the contributing set.
|
|
296
|
+
|
|
297
|
+
*Property `OverProgress.start`*:
|
|
298
|
+
We always return a starting value of 0.
|
|
299
|
+
|
|
300
|
+
*Property `OverProgress.throughput`*:
|
|
301
|
+
The `throughput` is the sum of the subsidiary throughputs.
|
|
302
|
+
|
|
303
|
+
*Method `OverProgress.throughput_recent(self, time_window)`*:
|
|
304
|
+
The `throughput_recent` is the sum of the subsidiary throughput_recentss.
|
|
305
|
+
|
|
306
|
+
*Property `OverProgress.total`*:
|
|
307
|
+
The `total` is the sum of the subsidiary totals.
|
|
308
|
+
|
|
309
|
+
## Class `Progress(BaseProgress)`
|
|
310
|
+
|
|
311
|
+
A progress counter to track task completion with various utility methods.
|
|
312
|
+
|
|
313
|
+
Example:
|
|
314
|
+
|
|
315
|
+
>>> P = Progress(name="example")
|
|
316
|
+
>>> P #doctest: +ELLIPSIS
|
|
317
|
+
Progress(name='example',start=0,position=0,start_time=...,throughput_window=None,total=None):[CheckPoint(time=..., position=0)]
|
|
318
|
+
>>> P.advance(5)
|
|
319
|
+
>>> P #doctest: +ELLIPSIS
|
|
320
|
+
Progress(name='example',start=0,position=5,start_time=...,throughput_window=None,total=None):[CheckPoint(time=..., position=0), CheckPoint(time=..., position=5)]
|
|
321
|
+
>>> P.total = 100
|
|
322
|
+
>>> P #doctest: +ELLIPSIS
|
|
323
|
+
Progress(name='example',start=0,position=5,start_time=...,throughput_window=None,total=100):[CheckPoint(time=..., position=0), CheckPoint(time=..., position=5)]
|
|
324
|
+
|
|
325
|
+
A Progress instance has an attribute ``notify_update`` which
|
|
326
|
+
is a set of callables. Whenever the position is updated, each
|
|
327
|
+
of these will be called with the `Progress` instance and the
|
|
328
|
+
latest `CheckPoint`.
|
|
329
|
+
|
|
330
|
+
`Progress` objects also make a small pretense of being an integer.
|
|
331
|
+
The expression `int(progress)` returns the current position,
|
|
332
|
+
and `+=` and `-=` adjust the position.
|
|
333
|
+
|
|
334
|
+
This is convenient for coding, but importantly it is also
|
|
335
|
+
useful for discretionary use of a Progress with some other
|
|
336
|
+
object.
|
|
337
|
+
If you want to make a lightweight `Progress` capable class
|
|
338
|
+
you can set a position attribute to an `int`
|
|
339
|
+
and manipulate it carefully using `+=` and `-=` entirely.
|
|
340
|
+
If you decide to incur the cost of maintaining a `Progress` object
|
|
341
|
+
you can slot it in:
|
|
342
|
+
|
|
343
|
+
# initial setup with just an int
|
|
344
|
+
my_thing.amount = 0
|
|
345
|
+
|
|
346
|
+
# later, or on some option, use a Progress instance
|
|
347
|
+
my_thing.amount = Progress(my_thing.amount)
|
|
348
|
+
|
|
349
|
+
*Method `Progress.__init__(self, name: Optional[str] = None, *, position: Optional[float] = None, start: Optional[float] = None, start_time: Optional[float] = None, throughput_window: Optional[int] = None, total: Optional[float] = None, units_scale=None)`*:
|
|
350
|
+
Initialise the Progesss object.
|
|
351
|
+
|
|
352
|
+
Parameters:
|
|
353
|
+
* `position`: initial position, default `0`.
|
|
354
|
+
* `name`: optional name for this instance.
|
|
355
|
+
* `start`: starting position of progress range,
|
|
356
|
+
default from `position`.
|
|
357
|
+
* `start_time`: start time of the process, default now.
|
|
358
|
+
* `throughput_window`: length of throughput time window in seconds,
|
|
359
|
+
default None.
|
|
360
|
+
* `total`: expected completion value, default None.
|
|
361
|
+
|
|
362
|
+
*Method `Progress.__iadd__(self, delta)`*:
|
|
363
|
+
Operator += form of advance().
|
|
364
|
+
|
|
365
|
+
>>> P = Progress()
|
|
366
|
+
>>> P.position
|
|
367
|
+
0
|
|
368
|
+
>>> P += 4
|
|
369
|
+
>>> P.position
|
|
370
|
+
4
|
|
371
|
+
>>> P += 4
|
|
372
|
+
>>> P.position
|
|
373
|
+
8
|
|
374
|
+
|
|
375
|
+
*Method `Progress.__isub__(self, delta)`*:
|
|
376
|
+
Operator -= form of advance().
|
|
377
|
+
|
|
378
|
+
>>> P = Progress()
|
|
379
|
+
>>> P.position
|
|
380
|
+
0
|
|
381
|
+
>>> P += 4
|
|
382
|
+
>>> P.position
|
|
383
|
+
4
|
|
384
|
+
>>> P -= 4
|
|
385
|
+
>>> P.position
|
|
386
|
+
0
|
|
387
|
+
|
|
388
|
+
*Method `Progress.advance(self, delta, update_time=None)`*:
|
|
389
|
+
Record more progress, return the advanced position.
|
|
390
|
+
|
|
391
|
+
>>> P = Progress()
|
|
392
|
+
>>> P.position
|
|
393
|
+
0
|
|
394
|
+
>>> P.advance(4)
|
|
395
|
+
>>> P.position
|
|
396
|
+
4
|
|
397
|
+
>>> P.advance(4)
|
|
398
|
+
>>> P.position
|
|
399
|
+
8
|
|
400
|
+
|
|
401
|
+
*Method `Progress.advance_total(self, delta)`*:
|
|
402
|
+
Function form of addition to the total.
|
|
403
|
+
|
|
404
|
+
*Property `Progress.latest`*:
|
|
405
|
+
Latest datum.
|
|
406
|
+
|
|
407
|
+
*Property `Progress.position`*:
|
|
408
|
+
Latest position.
|
|
409
|
+
|
|
410
|
+
*Property `Progress.throughput`*:
|
|
411
|
+
Current throughput per second.
|
|
412
|
+
|
|
413
|
+
If `self.throughput_window` is not `None`,
|
|
414
|
+
calls `self.throughput_recent(throughput_window)`.
|
|
415
|
+
Otherwise call `self.throughput_overall()`.
|
|
416
|
+
|
|
417
|
+
*Method `Progress.throughput_recent(self, time_window)`*:
|
|
418
|
+
Recent throughput per second within a time window in seconds.
|
|
419
|
+
|
|
420
|
+
The time span overlapping the start of the window is included
|
|
421
|
+
on a flat pro rata basis.
|
|
422
|
+
|
|
423
|
+
*Property `Progress.total`*:
|
|
424
|
+
Return the current total.
|
|
425
|
+
|
|
426
|
+
*Method `Progress.update(self, new_position, update_time=None)`*:
|
|
427
|
+
Record more progress.
|
|
428
|
+
|
|
429
|
+
>>> P = Progress()
|
|
430
|
+
>>> P.position
|
|
431
|
+
0
|
|
432
|
+
>>> P.update(12)
|
|
433
|
+
>>> P.position
|
|
434
|
+
12
|
|
435
|
+
|
|
436
|
+
## Function `progressbar(*a, upd: Optional[cs.upd.Upd] = <function uses_upd.<locals>.<lambda> at 0x110fbedd0>, **kw)`
|
|
437
|
+
|
|
438
|
+
Convenience function to construct and run a `Progress.iterbar`
|
|
439
|
+
wrapping the iterable `it`,
|
|
440
|
+
issuing and withdrawning a progress bar during the iteration.
|
|
441
|
+
|
|
442
|
+
Parameters:
|
|
443
|
+
* `it`: the iterable to consume
|
|
444
|
+
* `label`: optional label, doubles as the `Progress.name`
|
|
445
|
+
* `position`: optional starting position
|
|
446
|
+
* `total`: optional value for `Progress.total`,
|
|
447
|
+
default from `len(it)` if supported.
|
|
448
|
+
* `units_scale`: optional units scale for `Progress`,
|
|
449
|
+
default `UNSCALED_SCALE`
|
|
450
|
+
|
|
451
|
+
If `total` is `None` and `it` supports `len()`
|
|
452
|
+
then the `Progress.total` is set from it.
|
|
453
|
+
|
|
454
|
+
All arguments are passed through to `Progress.iterbar`.
|
|
455
|
+
|
|
456
|
+
Example use:
|
|
457
|
+
|
|
458
|
+
for row in progressbar(rows):
|
|
459
|
+
... do something with row ...
|
|
460
|
+
|
|
461
|
+
## Function `selftest(argv)`
|
|
462
|
+
|
|
463
|
+
Exercise some of the functionality.
|
|
464
|
+
|
|
465
|
+
# Release Log
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
*Release 20240412*:
|
|
470
|
+
* BaseProgress.status: fixes for the arrow_width computation.
|
|
471
|
+
* BaseProgress.bar: drop existing UpdProxy support, drop deferred, implement update_period using a ticker Thread.
|
|
472
|
+
* BaseProgress.bar: set update_period=DEFAULT_UPDATE_PERIOD by default.
|
|
473
|
+
* Progress.iterbar: drop preexisting UpdProxy support, update_frequency and update_min_size support.
|
|
474
|
+
* Progress: new advance_total(delta) method so that we have a callable for this.
|
|
475
|
+
* BaseProgress.bar: new optional poll parameter accepting a callable accepting a BaseProgress to update the state before updating the bar display.
|
|
476
|
+
* BaseProgress.bar: new stalled='stalled' parameter to specify the term for no recent throughput, workers might prefer 'idle'.
|
|
477
|
+
* progressbar() updated to match.
|
|
478
|
+
|
|
479
|
+
*Release 20230401*:
|
|
480
|
+
progressbar, BaseProgress.iterbar: use @uses_upd to provide a context Upd instance.
|
|
481
|
+
|
|
482
|
+
*Release 20230212*:
|
|
483
|
+
BaseProgress: new update_period=0.2 parameter to constraint updates by elapsed time.
|
|
484
|
+
|
|
485
|
+
*Release 20221207*:
|
|
486
|
+
* BaseProgress.format_counter: accept arbitrary keyword arguments to pass to cs.units.transcribe.
|
|
487
|
+
* Progress.__init__: accept floats instead of just ints.
|
|
488
|
+
|
|
489
|
+
*Release 20220918*:
|
|
490
|
+
Progress.iterbar: wrap the iteration in a try/finally for cleanup.
|
|
491
|
+
|
|
492
|
+
*Release 20211208*:
|
|
493
|
+
* Progress.__init__: make the first optional positional parameter be "name", make other parameters keyword only.
|
|
494
|
+
* Progress.bar: make "label" the first optional positional parameter, make others keyword only.
|
|
495
|
+
|
|
496
|
+
*Release 20210803*:
|
|
497
|
+
* progressbar,iterbar: accept optional RunState to cancel iteration.
|
|
498
|
+
* BaseProgress.iterbar: make update_min_size properly optional, was making update_frequency ineffective.
|
|
499
|
+
|
|
500
|
+
*Release 20210730*:
|
|
501
|
+
When there is no total just report position and no ETA.
|
|
502
|
+
|
|
503
|
+
*Release 20210717*:
|
|
504
|
+
Minor tweaks.
|
|
505
|
+
|
|
506
|
+
*Release 20210316*:
|
|
507
|
+
* Progress.iterbar: only update the status line once per iteration, either before or after the yield according to incfirst.
|
|
508
|
+
* Progress.iterbar: fix the meaning of update_frequency to count iterations, add update_min_size to count progress advance.
|
|
509
|
+
|
|
510
|
+
*Release 20210306*:
|
|
511
|
+
progressbar: accept new optional `position` parameter, used to initialise the Progress.
|
|
512
|
+
|
|
513
|
+
*Release 20201102.1*:
|
|
514
|
+
DISTINFO: fix module dependencies.
|
|
515
|
+
|
|
516
|
+
*Release 20201102*:
|
|
517
|
+
* Format/layout changes for the default status line.
|
|
518
|
+
* Progress.throughtput_recent: return None if no new positions beyond the starting position.
|
|
519
|
+
* BaseProgress.status: accept label=None (default to self.name) and width=UpdProxy (uses width.width).
|
|
520
|
+
* BaseProgress.status: new optional window parameter, default 5, defining the recent throughput window size in seconds.
|
|
521
|
+
* A few bugfixes.
|
|
522
|
+
|
|
523
|
+
*Release 20201025*:
|
|
524
|
+
* Some formatting improvements.
|
|
525
|
+
* BaseProgress.bar: new insert_pos parameter to position the progress bar, default still 1.
|
|
526
|
+
* BaseProgress.bar: new deferred parameter putting off the status bar until the first update.
|
|
527
|
+
* BaseProgress.bar: accept new optional `proxy` parameter to use (and not delete) an existing UpdProxy for display.
|
|
528
|
+
* Progress.text_pos_of_total: new `pos_first=False` parameter, rendering the total before the position by default (less progress bar noise).
|
|
529
|
+
* New @auto_progressbar decorator to provide a progress bar and initialise progress= parameter to functions which can use a Progress for reporting.
|
|
530
|
+
* Assorted fixes.
|
|
531
|
+
|
|
532
|
+
*Release 20200718.3*:
|
|
533
|
+
BaseProgress.bar, progressbar: new optional report_print parameter for reporting on completion.
|
|
534
|
+
|
|
535
|
+
*Release 20200718.2*:
|
|
536
|
+
Bugfix: BaseProgress.status: handle throughput=0 when total=None.
|
|
537
|
+
|
|
538
|
+
*Release 20200718.1*:
|
|
539
|
+
BaseProgress.bar, progressbar: new optional update_frequency parameter for less frequent updates.
|
|
540
|
+
|
|
541
|
+
*Release 20200718*:
|
|
542
|
+
* Readability improvement for default status line.
|
|
543
|
+
* progressbar: default units_scale=UNSCALED_SCALE.
|
|
544
|
+
|
|
545
|
+
*Release 20200716.1*:
|
|
546
|
+
BaseProgress.status: round throughput to an int if >=10.
|
|
547
|
+
|
|
548
|
+
*Release 20200716*:
|
|
549
|
+
* BaseProgress.status: distinguish "idle" (position >= total) from "stalled" (position < total).
|
|
550
|
+
* BaseProgress.status: make the status very short if the progress is idle.
|
|
551
|
+
|
|
552
|
+
*Release 20200627*:
|
|
553
|
+
* BaseProgress.status: handle throughput=None (before any activity).
|
|
554
|
+
* BaseProgress: drop count_of_total_bytes_text, superceded by format_counter (which honours the units_scale).
|
|
555
|
+
|
|
556
|
+
*Release 20200626*:
|
|
557
|
+
* New Progress.bar generator method iterating over an iterable while displaying a progress bar.
|
|
558
|
+
* New convenience function progressbar(it,...) which rolls its own Progress instance.
|
|
559
|
+
* Progress: always support a throughput window, default to DEFAULT_THROUGHPUT_WINDOW = 5s.
|
|
560
|
+
* Improve the default progress bar render returned by Progress.status().
|
|
561
|
+
|
|
562
|
+
*Release 20200613*:
|
|
563
|
+
* BaseProgress, Progress and OverProgress now accept an optional units_scale, such as cs.units.UNSCALED_SCALE, to use when expressing progress - the default remains BINARY_SCALE.
|
|
564
|
+
* New arrow(), format_counter() and text_pos_of_total() methods to produce components of the status string for tuning or external reuse.
|
|
565
|
+
|
|
566
|
+
*Release 20200520*:
|
|
567
|
+
OverProgress: throughput and eta implementations.
|
|
568
|
+
|
|
569
|
+
*Release 20200129.3*:
|
|
570
|
+
Test __version__ machinery again.
|
|
571
|
+
|
|
572
|
+
*Release 20200129.2*:
|
|
573
|
+
set __version__ to '20200129.2'
|
|
574
|
+
|
|
575
|
+
*Release 20200129.1*:
|
|
576
|
+
Dummy release to test new __version__.
|
|
577
|
+
|
|
578
|
+
*Release 20200129*:
|
|
579
|
+
New Progress.count_of_total_bytes_text property presenting "3kB/40MB" style text.
|
|
580
|
+
|
|
581
|
+
*Release 20190812*:
|
|
582
|
+
* New OverProgress class which is a composite of a set of subsidiary Progress instances.
|
|
583
|
+
* Assorted other small updates.
|
|
584
|
+
|
|
585
|
+
*Release 20190220*:
|
|
586
|
+
* Progress: be somewhat like an int.
|
|
587
|
+
* New status() method returning a convenient one line progress status report.
|
|
588
|
+
|
|
589
|
+
*Release 20180703.2*:
|
|
590
|
+
Progress: make .total into a property in order to fire the update notifications.
|
|
591
|
+
|
|
592
|
+
*Release 20180703.1*:
|
|
593
|
+
Progress: additions and changes to API: new .ratio, .elapsed_time, rename .projected to .remaining_time.
|
|
594
|
+
|
|
595
|
+
*Release 20180703*:
|
|
596
|
+
Initial release of cs.progress.
|
|
597
|
+
|