diff --git a/python/ray/_private/ray_constants.py b/python/ray/_private/ray_constants.py index 9e76e57e3088..b8b6f7b443a5 100644 --- a/python/ray/_private/ray_constants.py +++ b/python/ray/_private/ray_constants.py @@ -23,6 +23,21 @@ def env_integer(key, default): return default +def env_float(key, default): + if key in os.environ: + value = os.environ[key] + try: + return float(value) + except ValueError: + logger.debug( + f"Found {key} in environment, but value must " + f"be a float. Got: {value}. Returning " + f"provided default {default}." + ) + return default + return default + + def env_bool(key, default): if key in os.environ: return (