Skip to content

Commit

Permalink
[core] Fix flickering progress bar due to overriden prints to StringIO (
Browse files Browse the repository at this point in the history
ray-project#34735)

Some modules are using print() to string buffers, which we unnecessarily intercept and hide/unhide our tqdm bars for. This causes flickering in the progress bar.
  • Loading branch information
ericl committed Apr 25, 2023
1 parent 38f4e44 commit 9a5c547
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/ray/experimental/tqdm_ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import logging
import os
import sys
import threading
import uuid
from typing import Any, Dict, Iterable, Optional
Expand Down Expand Up @@ -37,6 +38,11 @@ def safe_print(*args, **kwargs):
By default, the builtin print will be patched to this function when tqdm_ray is
used. To disable this, set RAY_TQDM_PATCH_PRINT=0.
"""

# Ignore prints to StringIO objects, etc.
if kwargs.get("file") not in [sys.stdout, sys.stderr, None]:
return _print(*args, **kwargs)

try:
instance().hide_bars()
_print(*args, **kwargs)
Expand Down

0 comments on commit 9a5c547

Please sign in to comment.