Fix load_from_disk progress bar with redirected stdout by omarfarhoud · Pull Request #7919 · huggingface/datasets

Fixes #7918

Problem

When using load_from_disk() with contextlib.redirect_stdout(), the progress bar was not showing even for datasets with >16 files.

Root Cause

The disable parameter was set to None which triggers TTY auto-detection. This fails when stdout is redirected, causing the progress bar to be hidden.

Solution

Changed disable=len(state["_data_files"]) <= 16 or None to disable=len(state["_data_files"]) <= 16 to force the progress bar to show for datasets with >16 files, regardless of stdout redirection.

Testing

Verified that progress bars now appear correctly both with and without stdout redirection for datasets with >16 shards.