Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding an asyncio.gather() replacement for tqdm #1136

Merged
merged 5 commits into from Mar 5, 2021

Conversation

SpangleLabs
Copy link
Contributor

tqdm's as_completed() is helpful, but does mean results are not in the same order as inputs, which can be frustrating.

I've tried writing a wrapper which emulates the behaviour of asyncio.gather, though I'm not sure whether this conforms to the ideas of the project. (I'm not sure the typing import will be well appreciated, at the very least)

@codecov
Copy link

codecov bot commented Mar 2, 2021

Codecov Report

Merging #1136 (94009b5) into master (0ed778e) will increase coverage by 0.06%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1136      +/-   ##
==========================================
+ Coverage   84.75%   84.81%   +0.06%     
==========================================
  Files          24       24              
  Lines        1620     1627       +7     
  Branches      267      270       +3     
==========================================
+ Hits         1373     1380       +7     
  Misses        209      209              
  Partials       38       38              

@SpangleLabs
Copy link
Contributor Author

I'm not too sure how to make this work for older python versions, or whether it's possible, sorry! If someone could point me in the right direction, I might be able to make whatever changes are required

@casperdcl casperdcl self-assigned this Mar 3, 2021
@casperdcl casperdcl added this to the Non-breaking milestone Mar 3, 2021
@casperdcl casperdcl added p3-enhancement 🔥 Much new such feature question/docs ‽ Documentation clarification candidate submodule ⊂ Periphery/subclasses synchronisation ⇶ Multi-thread/processing to-review 🔍 Awaiting final confirmation labels Mar 3, 2021
@casperdcl casperdcl added c1-quick 🕐 Complexity low to-merge ↰ Imminent and removed question/docs ‽ Documentation clarification candidate to-review 🔍 Awaiting final confirmation labels Mar 3, 2021
@casperdcl
Copy link
Sponsor Member

thanks for this. Made a few changes:

  • require py3.6+ so await works in list comprehensions
  • update test
    • actually verify order of gather() results
    • speed up (no need to sleep())
  • tidy syntax
    • e.g. use enumerate()
    • remove typing (would be fine with this in a stub file, tqdm/asyncio.pyi if you want in a separate PR)

@SpangleLabs
Copy link
Contributor Author

Oh that's amazing! I didn't expect that you would fix it all up and neaten it yourself, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c1-quick 🕐 Complexity low p3-enhancement 🔥 Much new such feature submodule ⊂ Periphery/subclasses synchronisation ⇶ Multi-thread/processing to-merge ↰ Imminent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants