Fix Progress Bar in Notebook - #932
Conversation
Codecov Report
@@ Coverage Diff @@
## master #932 +/- ##
==========================================
+ Coverage 98.17% 98.22% +0.04%
==========================================
Files 119 119
Lines 10867 10859 -8
==========================================
- Hits 10669 10666 -3
+ Misses 198 193 -5
Continue to review full report at Codecov.
|
| tqdm_options.update({'file': open(os.devnull, 'w'), 'disable': False}) | ||
|
|
||
| progress_bar = make_tqdm_iterator(**tqdm_options) | ||
| progress_bar._instances.clear() |
| @@ -299,7 +300,6 @@ def calculate_feature_matrix(features, entityset=None, cutoff_time=None, instanc | |||
|
|
|||
| progress_bar.refresh() | |||
|
@casperdcl, I implemented those changes on a different branch, tqdm-suggestions, but it did not resolve the issue Running this code in a notebook: import featuretools as ft
import tqdm
print(tqdm.__version__)
es = ft.demo.load_mock_customer(return_entityset=True)
cutoff_time = es['transactions'].df[["transaction_id", "transaction_time"]]
ft.dfs(entityset=es, target_entity='transactions', cutoff_time=cutoff_time, verbose=True)Interrupting the kernel during the |
|
Thanks @rwedge - I suspect this may be a |
|
@casperdcl - running the code you provided, interrupting the loop, then re-running the loop does not result in unexpected progress bar behavior. It looks normal. |
|
Great so this is a wrapper issue; will open a new issue upstream |
|
Thanks for helping look into this! |
|
@kmax12 I assume the reason you became my first ever sponsor? ❤️ 🎊 |
|
@casperdcl the reason is that I've been a longtime user of tqdm and wanted to support you. the help here is above and beyond. we really appreciate it. thanks! |
|
With #from tqdm.auto import tqdm
from tqdm import tqdm
import pandas as pd
from random import random
import warnings
with warnings.catch_warnings():
warnings.filterwarnings('ignore', category=FutureWarning)
tqdm.pandas()
df = pd.DataFrame((random() for _ in range(10)) for _ in range(int(1e6)))
try:
df.progress_apply(lambda x: x**x ** (1/x) ** x ** (1/x) ** x ** (1/x))
except KeyboardInterrupt:
print("finished with %d instances left" % len(tqdm._instances))#from tqdm.auto import tqdm
from tqdm import tqdm
import featuretools as ft
es = ft.demo.load_mock_customer(return_entityset=True)
cutoff_time = es['transactions'].df[["transaction_id", "transaction_time"]]
try:
ft.dfs(entityset=es, target_entity='transactions', cutoff_time=cutoff_time, verbose=True)
except KeyboardInterrupt:
print("finished with %d instances left" % len(tqdm._instances))So Looks like https://github.com/tqdm/tqdm/blob/5e8978909c639bc20f58bf877e66cc6a0b9fb5bf/tqdm/std.py#L766-L767 |
|
@casperdcl thanks for looking into this, I've opened a new issue |


This closes #791 by preventing an interrupted progress bar from double printing when running in a jupyter notebook.