Skip to content

Commit 483ac2e

Browse files
authored
Fix load_from_disk progress bar with redirected stdout (#7919)
* Fix load_from_disk progress bar with redirected stdout Fixes #7918. Changed disable=None to disable=False to prevent TTY auto-detection from failing when stdout is redirected. * Run ruff format * Check TQDM_POSITION to force-enable progress in cloud environments * Move TQDM_POSITION check to tqdm class for all progress bars
1 parent f0a17a1 commit 483ac2e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/datasets/utils/tqdm.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
```
4141
"""
4242

43+
import os
4344
import warnings
4445

4546
from tqdm.auto import tqdm as old_tqdm
@@ -111,6 +112,9 @@ class tqdm(old_tqdm):
111112
def __init__(self, *args, **kwargs):
112113
if are_progress_bars_disabled():
113114
kwargs["disable"] = True
115+
elif kwargs.get("disable") is None and os.getenv("TQDM_POSITION") == "-1":
116+
# Force-enable progress bars in cloud environments when disable=None
117+
kwargs["disable"] = False
114118
super().__init__(*args, **kwargs)
115119

116120
def __delattr__(self, attr: str) -> None:

0 commit comments

Comments
 (0)