Prettier Parallel logs if the number of tasks is known - #1608
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1608 +/- ##
==========================================
+ Coverage 95.24% 95.76% +0.52%
==========================================
Files 45 46 +1
Lines 7719 7799 +80
==========================================
+ Hits 7352 7469 +117
+ Misses 367 330 -37
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
tomMoral
left a comment
There was a problem hiding this comment.
Just one question, why not directly display Done XXX out of YYY when it is known?
Suggestion from tomMoral Co-authored-by: Thomas Moreau <[email protected]>
Huh that's a good point 😅 |
Suggestion from tomMoral Co-authored-by: Thomas Moreau <[email protected]>
tomMoral
left a comment
There was a problem hiding this comment.
Just a last comment but otherwise, good to go for me :)
Thanks for the PR!
|
I hate to be a downer, but this PR encourages an anti-pattern: using a list rather than an iterator will create a temporary object (the list) that can get large. Overall, IMHO, we should push people not to use lists, but iterators, in which case the number of tasks is not known.
|
|
Yes I agree that using a list is not the pattern we want to promote. But there are some instances where we can implement both lazy inputs and a from tqdm import tqdm
it = tqdm(range(100), total=100)
len(it) # 100while not materializing the tasks. The same is possible with |
|
So I am in favor of making this small change to improve the output, while still not advocating for using list of tasks.
+1
|
tomMoral
left a comment
There was a problem hiding this comment.
A last nitpick. Also, if you could add a test and an entry in the change log , that would be great.
Once again, thanks for the contrib!
Where should I add an entry in the changelog? |
And I'm not sure how integrate the test in vert_pos = {}
for line in PROCESS_OUTPUT_LINES:
if "|" in line:
vert_pos.add(line.find("|"))
assert len(vert_pos) in [0, 1]to make sure the |
Note that if you are not familiar with |
tomMoral
left a comment
There was a problem hiding this comment.
LGTM! I did a few change to integrate the test better with the test_parallel.py but otherwise it is good to go!
Thanks a lot :)
This PR makes the execution logs of
Parallel.print_progressmore aligned if the number of tasks is known. An example is worth 1e3 words:Before:
After:
Note that if the jobs are submitted as a generator instead of a list or tuple
then the logs are the same as before. In other words, the generator is not "unrolled" just to know the number of tasks.