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

Use progress bar in tqdm #264

Merged
merged 3 commits into from
Jun 8, 2021
Merged

Use progress bar in tqdm #264

merged 3 commits into from
Jun 8, 2021

Conversation

cphyc
Copy link
Contributor

@cphyc cphyc commented May 5, 2017

This PR add the possibility to have the progress bar using tqdm (https://github.com/noamraph/tqdm) to show the progress as asked in #176 .

@basnijholt
Copy link
Contributor

I am just leaving this snippet here for anyone in the future to Google tqdm and ipyparallel in the future (like I did now). This is a non-blocking way of doing so:

def live_info(ar, *, update_interval=0.1):
    import asyncio
    from tqdm import tqdm_notebook
    pbar = tqdm_notebook(total=len(ar.msg_ids))
    async def update():
        val = 0
        while not ar.ready():
            new_val = ar.progress
            pbar.update(new_val - val)
            val = new_val
            await asyncio.sleep(update_interval)
        pbar.update(pbar.total - pbar.n)

    asyncio.get_event_loop().create_task(update())

@minrk minrk merged commit 854ff2e into ipython:main Jun 8, 2021
@minrk
Copy link
Member

minrk commented Jun 8, 2021

Woo, merged after only four years. Sorry for the wait, @cphyc!

@minrk minrk changed the title Support for progress bar when found Use progress bar in tqdm Jun 8, 2021
@GF-Huang
Copy link

The progress bar seems based on task number (CPU count), how to make it base on the sequences/collection/iteration while using DirectView? I know LoadBalancedView works, but due to #539 I can't use LoadBalancedView.

For example I have a list: items = range(100000), how to make the progress bar count based on 100000 rather than 8 (my computer CPU count).

@minrk
Copy link
Member

minrk commented Aug 2, 2021

The progress bar is based on the number of 'tasks' (messages). IPython doesn't have any view into fractions of messages. In a DirectView, that's always one per engine. In a LoadBalancedView, that's one per item by default, but controllable via the chunksize argument.

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

Successfully merging this pull request may close these issues.

4 participants