[Data] Move env_float, env_integer, and env_bool to ray._common#60642
[Data] Move env_float, env_integer, and env_bool to ray._common#60642bveeramani merged 3 commits intoray-project:masterfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the env_integer, env_float, and env_bool utility functions by moving them from ray._private.ray_constants to ray._common.utils. The changes across the codebase correctly update the import paths to reflect this move.
My review focuses on the implementation of the moved functions. I've identified a correctness issue in env_integer where it fails to handle negative integer values from environment variables. I've also suggested a minor improvement to env_bool for better readability and to avoid redundant lookups. The implementation of env_float looks good.
| def env_bool(key, default): | ||
| if key in os.environ: | ||
| return ( | ||
| True | ||
| if os.environ[key].lower() == "true" or os.environ[key] == "1" | ||
| else False | ||
| ) | ||
| return default |
There was a problem hiding this comment.
The current implementation accesses os.environ[key] multiple times within the conditional logic. This can be slightly improved for efficiency and readability by storing the value in a local variable before performing comparisons.
def env_bool(key, default):
if key in os.environ:
val = os.environ[key].lower()
return val == "true" or val == "1"
return default
python/ray/data/_internal/cluster_autoscaler/default_autoscaling_coordinator.py
Outdated
Show resolved
Hide resolved
|
Hi @DeborahOlaboye, can you rebase + fix the tests? |
9089e1c to
a121905
Compare
Thanks for the review. I've addressed the tests and also rebased the branch. |
a121905 to
700d1ff
Compare
Signed-off-by: DeborahOlaboye <deboraholaboye@gmail.com>
700d1ff to
ed1d2c9
Compare
|
pushed a commit to fix linter |
…project#60642) ## Description Move `env_integer`, `env_float`, and `env_bool` utility functions from `ray._private.ray_constants` to `ray._common.utils`. Update all Ray Data imports to use the new location. ## Related issues Fixes ray-project#60516 --------- Signed-off-by: DeborahOlaboye <deboraholaboye@gmail.com> Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: Balaji Veeramani <balaji@anyscale.com> Signed-off-by: Ondrej Prenek <ondra.prenek@gmail.com>
…project#60642) ## Description Move `env_integer`, `env_float`, and `env_bool` utility functions from `ray._private.ray_constants` to `ray._common.utils`. Update all Ray Data imports to use the new location. ## Related issues Fixes ray-project#60516 --------- Signed-off-by: DeborahOlaboye <deboraholaboye@gmail.com> Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: Balaji Veeramani <balaji@anyscale.com>
…project#60642) ## Description Move `env_integer`, `env_float`, and `env_bool` utility functions from `ray._private.ray_constants` to `ray._common.utils`. Update all Ray Data imports to use the new location. ## Related issues Fixes ray-project#60516 --------- Signed-off-by: DeborahOlaboye <deboraholaboye@gmail.com> Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: Balaji Veeramani <balaji@anyscale.com>
…project#60642) ## Description Move `env_integer`, `env_float`, and `env_bool` utility functions from `ray._private.ray_constants` to `ray._common.utils`. Update all Ray Data imports to use the new location. ## Related issues Fixes ray-project#60516 --------- Signed-off-by: DeborahOlaboye <deboraholaboye@gmail.com> Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: Balaji Veeramani <balaji@anyscale.com> Signed-off-by: Muhammad Saif <2024BBIT200@student.Uet.edu.pk>
…project#60642) Move `env_integer`, `env_float`, and `env_bool` utility functions from `ray._private.ray_constants` to `ray._common.utils`. Update all Ray Data imports to use the new location. Fixes ray-project#60516 --------- Signed-off-by: DeborahOlaboye <deboraholaboye@gmail.com> Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: Balaji Veeramani <balaji@anyscale.com>
…project#60642) ## Description Move `env_integer`, `env_float`, and `env_bool` utility functions from `ray._private.ray_constants` to `ray._common.utils`. Update all Ray Data imports to use the new location. ## Related issues Fixes ray-project#60516 --------- Signed-off-by: DeborahOlaboye <deboraholaboye@gmail.com> Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: Balaji Veeramani <balaji@anyscale.com> Signed-off-by: Adel Nour <ans9868@nyu.edu>
…project#60642) ## Description Move `env_integer`, `env_float`, and `env_bool` utility functions from `ray._private.ray_constants` to `ray._common.utils`. Update all Ray Data imports to use the new location. ## Related issues Fixes ray-project#60516 --------- Signed-off-by: DeborahOlaboye <deboraholaboye@gmail.com> Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: Balaji Veeramani <balaji@anyscale.com>
…project#60642) ## Description Move `env_integer`, `env_float`, and `env_bool` utility functions from `ray._private.ray_constants` to `ray._common.utils`. Update all Ray Data imports to use the new location. ## Related issues Fixes ray-project#60516 --------- Signed-off-by: DeborahOlaboye <deboraholaboye@gmail.com> Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: Balaji Veeramani <balaji@anyscale.com> Signed-off-by: peterxcli <peterxcli@gmail.com>
…project#60642) ## Description Move `env_integer`, `env_float`, and `env_bool` utility functions from `ray._private.ray_constants` to `ray._common.utils`. Update all Ray Data imports to use the new location. ## Related issues Fixes ray-project#60516 --------- Signed-off-by: DeborahOlaboye <deboraholaboye@gmail.com> Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: Balaji Veeramani <balaji@anyscale.com> Signed-off-by: peterxcli <peterxcli@gmail.com>
…project#60642) ## Description Move `env_integer`, `env_float`, and `env_bool` utility functions from `ray._private.ray_constants` to `ray._common.utils`. Update all Ray Data imports to use the new location. ## Related issues Fixes ray-project#60516 --------- Signed-off-by: DeborahOlaboye <deboraholaboye@gmail.com> Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: Balaji Veeramani <balaji@anyscale.com>
Description
Move
env_integer,env_float, andenv_boolutility functions fromray._private.ray_constantstoray._common.utils. Update all Ray Data imports to use the new location.Related issues
Fixes #60516