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

p_tqdm support #12

Closed
ohjho opened this issue Oct 18, 2021 · 2 comments
Closed

p_tqdm support #12

ohjho opened this issue Oct 18, 2021 · 2 comments

Comments

@ohjho
Copy link

ohjho commented Oct 18, 2021

Love this project and have been using it all the time with any ST apps I build.

just wondering if there's any plan to wrap stqdm on top of the equally amazing p_tqdm

@Wirg
Copy link
Owner

Wirg commented Oct 27, 2021

Hi @ohjho ,

Honnestly, I don't plan on this and I don't think I will ever.
However, I plan on adding a way to replace tqdm calls by stqdm ones.
This may be a way for you to achieve this.

Waiting for this, here are 2 ways that will probably do the trick for you :

  • do your own multiprocessing and use the resulting imap in stqdm :
from multiprocessing import Pool # you can probably call pathos in the same way
from time import sleep


def sleep_and_return(i):
    sleep(0.5)
    return i


N = 100
with Pool(processes=5) as pool:
    for i in stqdm(pool.imap(sleep_and_return, range(N)), total=N):
        st.write(i)

If you don't care about the order, you can call imap_unordered instead

  • Monkey patching tqdm in p_tqdm module by calling something like :
from stqdm import stqdm
from p_tqdm import p_tqdm as p_tqdm_base
p_tqdm_base.tqdm = stqdm

@Wirg
Copy link
Owner

Wirg commented Dec 11, 2021

Closing as stale and there are some workaround and a future for this.

@Wirg Wirg closed this as completed Dec 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants