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

bar.current() fails with TypeError: 'int' object is not callable #253

Closed
jspilinek opened this issue Oct 4, 2023 · 3 comments
Closed

bar.current() fails with TypeError: 'int' object is not callable #253

jspilinek opened this issue Oct 4, 2023 · 3 comments

Comments

@jspilinek
Copy link

My script is parsing through log files. Script worked fine on my old machine with alive-progress 2.4.1. My new machine is using alive-progress 3.1.4

TotalFileSize is the total bytes of all files to be parsed.

My 2.4.1 alive_bar:
with alive_bar(TotalFileSize, title=f'Processing {TotalMB} MB',monitor='[{percent:.0%}] {count}/{total} Bytes') as bar:

I see in 3.0 there was support added for units. My new alive_bar:

with alive_bar(TotalFileSize, title=f'Processing Files', unit='B', scale='SI', precision=1) as bar:

My code loops throught the files, reading one line at a time. For each line processed I calculate the line size and update the bar:

bar(sys.getsizeof(line)-sys.getsizeof('\n'))

I never quite reach 100%. Must be math is slightly off. After processing all files I bump the bar to 100% with:
bar(TotalFileSize-bar.current())

This worked in alive-progress 2.4.1, but no longer works in 3.1.4.

bar.current() fails with error:
TypeError: 'int' object is not callable

@TheTechRobo
Copy link
Contributor

Have you tried just bar.current (without the brackets)?

@jspilinek
Copy link
Author

bar.current works. Thanks!

README.md should be updated as it references bar.current() twice

@rsalmei
Copy link
Owner

rsalmei commented Oct 5, 2023

Thanks @TheTechRobo.

Yep, the readme is not up-to-date. I'm going to fix it, thanks @jspilinek.

I just wanted to let you know that the auto-suggestions of ipython do show current is not a method:
image

rsalmei added a commit that referenced this issue Oct 5, 2023
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

3 participants