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

Set scroll area when calling Counter() directly #52

Closed
ngriffiths13 opened this issue Nov 29, 2022 · 3 comments
Closed

Set scroll area when calling Counter() directly #52

ngriffiths13 opened this issue Nov 29, 2022 · 3 comments

Comments

@ngriffiths13
Copy link

Describe the bug
When using enlighten and logging, the progress bar is being interrupted everytime I log.

INFO:__main__:LOG
INFO:__main__:LOG
INFO:__main__:LOG
INFO:__main__:LOG
INFO:__main__:LOG
INFO:__main__:LOG
INFO:__main__:LOG
INFO:__main__:LOG
Backtesting  18%|█████████████████████▊                                                                                                   |  9/50 [00:00<00:01, 81.32 bars/s]INFO:__main__:LOG
INFO:__main__:LOG
INFO:__main__:LOG
INFO:__main__:LOG
INFO:__main__:LOG
INFO:__main__:LOG
INFO:__main__:LOG
INFO:__main__:LOG
INFO:__main__:LOG
Backtesting  36%|███████████████████████████████████████████▌                                                                             | 18/50 [00:00<00:00, 81.41 bars/s]INFO:__main__:LOG

To Reproduce

import logging
import time

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

my_list = list(range(50))
pbar = enlighten.Counter(total=len(my_list), desc="Backtesting",
                                      unit="bars", color="blue")

for l in my_list:
    time.sleep(.01)
    logger.info("LOG")
    pbar.update()

Environment (please complete the following information):

  • Enlighten Version: 1.11.1
  • OS and version: MacOS M1 Chip
  • Console application: iterm2
  • Special Conditions: Running with poetry in python 3.10.5
@avylove
Copy link
Contributor

avylove commented Nov 29, 2022

The scroll area isn't set when calling Counter() directly. Maybe it should be?

What you want to do is create a manager first.

manager = enlighten.get_manager()
pbar = manager.counter()

@ngriffiths13
Copy link
Author

Ah okay that did the trick. Setting it automatically might be nice. Or at least making it clear that it doesn't in the documentation. Thanks!

@avylove avylove changed the title Logging Interrupting Progress Bar Set scroll area when calling Counter() directly Jan 29, 2023
@avylove
Copy link
Contributor

avylove commented Sep 24, 2023

In 1.12.0 calling the Counter class directly will now behave the same as using a manager. References to calling directly have been removed from the documentation and it may be dropped in a future release.

@avylove avylove closed this as completed Sep 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants