Skip to content

Conversation

lrq3000
Copy link
Member

@lrq3000 lrq3000 commented Jun 7, 2016

The main goal is to allow the parent application to manage the progress bar display itself. For example, if an application with a GUI (such as moviepy?) wants to use tqdm on both its console and GUI displays without having to make a dedicated module (that won't be reusable for any other module but theirs). This is way easier than subclassing tqdm and should be pretty much as fast performance-wise.

Todo:

  • test on real cases (not yet tested at all, beware!)
  • unit test

@codecov-io
Copy link

codecov-io commented Jun 7, 2016

Current coverage is 85.30% (diff: 66.66%)

Merging #181 into master will decrease coverage by 5.26%

@@             master       #181   diff @@
==========================================
  Files             7          8     +1   
  Lines           477        524    +47   
  Methods           0          0          
  Messages          0          0          
  Branches         85         97    +12   
==========================================
+ Hits            432        447    +15   
- Misses           44         77    +33   
+ Partials          1          0     -1   

Powered by Codecov. Last update 02cbd9c...cff7413

@coveralls
Copy link

coveralls commented Jun 7, 2016

Coverage Status

Coverage decreased (-0.1%) to 82.061% when pulling cff7413 on bar_format_callback into c2941fb on master.

@casperdcl
Copy link
Member

ah, nice... an update callback wrapped by another update callback.

@lrq3000
Copy link
Member Author

lrq3000 commented Jun 8, 2016

Ah you're right, I didn't give it enough thought, this code probably
doesn't work as it is.

I think it would be better to just provide a special value to format_meter
so that it returns the dict to status_printer, so users would just have to
overload tqdm.status_printer with their bar display code, and tqdm.init
to call format_meter with the special argument like bar_format=True.

The idea is to avoid forcing the user to recode the rate, remaining and
percentage computation codes that are done in format_meter. If they have a
GUI bar, they can't just overload status_printer, as
status_printer.print_status() expects a string, and a GUI usually breaks
down the different parts of the bar into different widgets.

2016-06-08 19:36 GMT+02:00 Casper da Costa-Luis notifications@github.com:

ah, nice... an update callback wrapped by another update callback.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#181 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/ABES3hNu63SCd5gSe99gKvEX9FT7d_cUks5qJv2ugaJpZM4IwTiO
.

@casperdcl
Copy link
Member

casperdcl commented Jun 9, 2016

I think it might make sense for a call to update() to return a dict to simplify the end interface... wasn't finding fault; thought it was a good idea.

from tqdm import tqdm

def callback_gen(t, ...):
  def inner(...):
    params = t.update(dict=true)
    if params:
      # use params
  return inner

callback = callback_gen(tqdm(total=len(iter)))
for x in iter:
  callback()

I'd estimate this would add a 50% overhead on average

@lrq3000
Copy link
Member Author

lrq3000 commented Aug 27, 2016

This should be reworked on to also provide the separate values when total=None. Also, merging this will not only help third-party devs but also our own modularization of the code, for example #223 (because then we can call parent and avoid copy/pasting the calculation code). We should then also add N_BARS as a returing argument.

Summary todo:

  • also return arguments if total=None
  • return N_BARS

Signed-off-by: Stephen L. <lrq3000@gmail.com>
… for total=None

Signed-off-by: Stephen L. <lrq3000@gmail.com>
@lrq3000 lrq3000 force-pushed the bar_format_callback branch from cdf0e45 to 5f40415 Compare September 9, 2016 03:17
@lrq3000
Copy link
Member Author

lrq3000 commented Sep 9, 2016

Closing this, this should be merged with #223 as it uses bar_format_callback to reduce code duplication (not really the callback but the dict return, but if dict return works then callback will also work because this is the same code but one if branching).

@lrq3000 lrq3000 closed this Sep 9, 2016
@lrq3000
Copy link
Member Author

lrq3000 commented Sep 9, 2016

Note that #223 contains bugfixes compared to the version in here, this is the reason I close this PR.

@casperdcl casperdcl deleted the bar_format_callback branch May 3, 2021 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p4-enhancement-future 🧨 On the back burner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants