igraph / python-igraph

Python interface for igraph
GNU General Public License v2.0
1.31k stars 249 forks source link

Progress bar #492

Open iosonofabio opened 2 years ago

iosonofabio commented 2 years ago

What is the feature or improvement you would like to see? There's been a discussion on progress bars in #485 that deserves its own issue.

Use cases for the feature C core, python, ipython, Jupyter notebook, Jupyterlab, Google Colab, Data Bricks, etc.

References

485

szhorvat commented 2 years ago

This is the code I used for out CZI EOSS presentation:

import ipywidgets as widgets
import igraph as ig

prog = widgets.FloatProgress(min=0, max=100)

import math
def update_progress(msg, p):
    if p < prog.value or p >= math.ceil(prog.value):
        prog.value = p    

ig.set_progress_handler(update_progress)

display(prog)
g = ig.Graph.Barabasi(100000,m=2)
g.community_fastgreedy()

Note that you need to install ipywidgets before you start the notebook, otherwise it will not display correctly.

I do remember looking into tqdm, possibly at @vtraag 's suggestion, but ended up not using it. I don't recall why exactly, but I think it only allowed monotonic updates (i.e. increments) instead of setting the progress to arbitrary values, which is required by igraph.

szhorvat commented 2 years ago

Before looking at this seriously for Python, we should make this improvement in the C core: https://github.com/igraph/igraph/issues/1884 It may require changes to the API.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.