[datasets] Add an env var for progress bar behavior (#20586)

Adds a RAY_DATA_DISABLE_PROGRESS_BARS env var to control the default progress bar behavior. The default value is "0". Setting it to "1" disables progress bars, unless they are reenabled again by the set_progress_bars method.
This commit is contained in:
Antoni Baum 2021-11-20 00:09:58 +01:00 committed by GitHub
parent 1a00964902
commit c385756817
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,7 @@
from typing import List, Any
import ray
from ray.ray_constants import env_integer
from ray.types import ObjectRef
from ray.util.annotations import PublicAPI
@ -12,13 +13,18 @@ except ImportError:
needs_warning = True
# Whether progress bars are enabled in this process.
_enabled: bool = True
_enabled: bool = not bool(env_integer("RAY_DATA_DISABLE_PROGRESS_BARS", 0))
@PublicAPI
def set_progress_bars(enabled: bool) -> bool:
"""Set whether progress bars are enabled.
The default behavior is controlled by the
``RAY_DATA_DISABLE_PROGRESS_BARS`` environment variable. By default,
it is set to "0". Setting it to "1" will disable progress bars, unless
they are reenabled by this method.
Returns:
Whether progress bars were previously enabled.
"""