Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Utility] add env_float utility into ray._private.ray_constants #47117

Merged
merged 1 commit into from
Aug 13, 2024

Conversation

hongpeng-guo
Copy link
Contributor

@hongpeng-guo hongpeng-guo commented Aug 13, 2024

Why are these changes needed?

The current codebase includes env_bool and env_integer functions that directly convert environment variable strings into their respective types. To extend this functionality, we also need an env_float function to safely convert strings representing floating-point numbers into the float type."

Related issue number

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Signed-off-by: Hongpeng Guo <[email protected]>
@hongpeng-guo hongpeng-guo changed the title add env_float unility [Utility] add env_float utility into ray._private.ray_constant Aug 13, 2024
@hongpeng-guo hongpeng-guo self-assigned this Aug 13, 2024
@hongpeng-guo hongpeng-guo changed the title [Utility] add env_float utility into ray._private.ray_constant [Utility] add env_float utility into ray._private.ray_constants Aug 13, 2024
@jjyao jjyao added the go add ONLY when ready to merge, run all tests label Aug 13, 2024
@@ -23,6 +23,21 @@ def env_integer(key, default):
return default


def env_float(key, default):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QQ: Any use cases where we set float in env_var?

Copy link
Contributor Author

@hongpeng-guo hongpeng-guo Aug 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! In some cases in runtime, it's better to use float numbers for timeout_values, especially when comparing them to real-time (float) values. Reading them as floats makes more sense in those scenarios.

@woshiyyya
Copy link
Member

Add a unit test for this function?

@hongpeng-guo
Copy link
Contributor Author

Add a unit test for this function?

Also thought about this. But it seems we don't have tests for env_bool and env_integer in the codebase, either. I guess it might be fine here.

@matthewdeng matthewdeng merged commit bb127a8 into ray-project:master Aug 13, 2024
5 checks passed
@hongpeng-guo hongpeng-guo deleted the hpguo/add_env_float branch August 13, 2024 21:55
simonsays1980 pushed a commit to simonsays1980/ray that referenced this pull request Aug 14, 2024
…ay-project#47117)

The current codebase includes `env_bool` and `env_integer` functions
that directly convert environment variable strings into their respective
types. To extend this functionality, we also need an `env_float`
function to safely convert strings representing floating-point numbers
into the `float` type."

Signed-off-by: Hongpeng Guo <[email protected]>
simonsays1980 pushed a commit to simonsays1980/ray that referenced this pull request Aug 15, 2024
…ay-project#47117)

The current codebase includes `env_bool` and `env_integer` functions
that directly convert environment variable strings into their respective
types. To extend this functionality, we also need an `env_float`
function to safely convert strings representing floating-point numbers
into the `float` type."

Signed-off-by: Hongpeng Guo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants