-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
[Core] Implement py_executable support for runtime environments to enable better UV support #50160
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
edoakes
reviewed
Feb 3, 2025
edoakes
reviewed
Feb 3, 2025
edoakes
reviewed
Feb 3, 2025
edoakes
reviewed
Feb 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good pending uv
e2e test
edoakes
approved these changes
Feb 3, 2025
import emoji | ||
return emoji.emojize("Ray rocks :thumbs_up:") | ||
|
||
assert ray.get(emojize.remote()) == "Ray rocks 👍" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Co-authored-by: angelinalg <122562471+angelinalg@users.noreply.github.com> Signed-off-by: Philipp Moritz <pcmoritz@gmail.com>
Co-authored-by: angelinalg <122562471+angelinalg@users.noreply.github.com> Signed-off-by: Philipp Moritz <pcmoritz@gmail.com>
Co-authored-by: angelinalg <122562471+angelinalg@users.noreply.github.com> Signed-off-by: Philipp Moritz <pcmoritz@gmail.com>
Co-authored-by: angelinalg <122562471+angelinalg@users.noreply.github.com> Signed-off-by: Philipp Moritz <pcmoritz@gmail.com>
Co-authored-by: angelinalg <122562471+angelinalg@users.noreply.github.com> Signed-off-by: Philipp Moritz <pcmoritz@gmail.com>
2 tasks
8 tasks
pcmoritz
added a commit
that referenced
this pull request
Feb 13, 2025
…#50462) <!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? Next step after #50160 to make it more convenient to use UV with Ray. This is a useful runtime environment hook for mirroring the environment of `uv run` to the workers (currently the args to uv run and the working_dir). This is useful because it will allow people to intuitively use `uv run` in a distributed application with the same behavior as for a single python process. This only modifies the environment if the driver was run with `uv run` and could conceivably become the default for drivers run with uv run. This is currently a developer API as implied by the fact that it is in the `_private` namespace. It is currently for experimentation and can needs to be opted in via ```shell export RAY_RUNTIME_ENV_HOOK=ray._private.runtime_env.uv_runtime_env_hook.hook ``` If it works well, we might make it the default in the `uv run` case. ## Related issue number <!-- For example: "Closes #1234" --> ## 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: Philipp Moritz <pcmoritz@gmail.com> Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: angelinalg <122562471+angelinalg@users.noreply.github.com>
israbbani
pushed a commit
that referenced
this pull request
Feb 25, 2025
…#50462) <!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? Next step after #50160 to make it more convenient to use UV with Ray. This is a useful runtime environment hook for mirroring the environment of `uv run` to the workers (currently the args to uv run and the working_dir). This is useful because it will allow people to intuitively use `uv run` in a distributed application with the same behavior as for a single python process. This only modifies the environment if the driver was run with `uv run` and could conceivably become the default for drivers run with uv run. This is currently a developer API as implied by the fact that it is in the `_private` namespace. It is currently for experimentation and can needs to be opted in via ```shell export RAY_RUNTIME_ENV_HOOK=ray._private.runtime_env.uv_runtime_env_hook.hook ``` If it works well, we might make it the default in the `uv run` case. ## Related issue number <!-- For example: "Closes #1234" --> ## 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: Philipp Moritz <pcmoritz@gmail.com> Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: angelinalg <122562471+angelinalg@users.noreply.github.com>
xsuler
pushed a commit
to antgroup/ant-ray
that referenced
this pull request
Mar 4, 2025
…able better UV support (ray-project#50160) <!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? This implements a very simple runtime environment plugin that allows e.g. using the `uv run` command for dependency handling (but could also be useful for wrapping the worker command e.g. with a profiler or debugger). **Very simple example:** ``` uv run --with emoji test.py ``` with ```Python import ray ray.init(runtime_env={"py_executable": "uv run --with emoji"}) @ray.remote def f(): import emoji return emoji.emojize("Ray rocks :thumbs_up:") print(ray.get(f.remote())) ``` **Slightly more complex example** with `pyproject.toml` in the working_dir (see https://docs.astral.sh/uv/guides/scripts): ``` uv run test.py ``` with pyproject.toml: ```toml [project] name = "test" version = "0.1" dependencies = [ "rich", "emoji", "ray", # had to do "ray @ file:///tmp/ray-2.41.0-cp312-cp312-macosx_11_0_arm64.whl" here since this is not released yet ] ``` text.py ```Python import ray import time from rich.progress import track ray.init(runtime_env={"working_dir": ".", "py_executable": "uv run --isolated"}) @ray.remote def f(): import emoji return emoji.emojize("Ray rocks :thumbs_up:") for i in track(range(20), description="For example:"): print(ray.get(f.remote())) time.sleep(0.05) ``` And the dependencies can also be locked with `uv lock`. ## Related issue number <!-- For example: "Closes ray-project#1234" --> ## 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: Philipp Moritz <pcmoritz@gmail.com> Co-authored-by: pcmoritz <pcmoritz@anyscale.com> Co-authored-by: angelinalg <122562471+angelinalg@users.noreply.github.com>
xsuler
pushed a commit
to antgroup/ant-ray
that referenced
this pull request
Mar 4, 2025
…ray-project#50462) <!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? Next step after ray-project#50160 to make it more convenient to use UV with Ray. This is a useful runtime environment hook for mirroring the environment of `uv run` to the workers (currently the args to uv run and the working_dir). This is useful because it will allow people to intuitively use `uv run` in a distributed application with the same behavior as for a single python process. This only modifies the environment if the driver was run with `uv run` and could conceivably become the default for drivers run with uv run. This is currently a developer API as implied by the fact that it is in the `_private` namespace. It is currently for experimentation and can needs to be opted in via ```shell export RAY_RUNTIME_ENV_HOOK=ray._private.runtime_env.uv_runtime_env_hook.hook ``` If it works well, we might make it the default in the `uv run` case. ## Related issue number <!-- For example: "Closes ray-project#1234" --> ## 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: Philipp Moritz <pcmoritz@gmail.com> Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: angelinalg <122562471+angelinalg@users.noreply.github.com>
xsuler
pushed a commit
to antgroup/ant-ray
that referenced
this pull request
Mar 4, 2025
…able better UV support (ray-project#50160) <!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? This implements a very simple runtime environment plugin that allows e.g. using the `uv run` command for dependency handling (but could also be useful for wrapping the worker command e.g. with a profiler or debugger). **Very simple example:** ``` uv run --with emoji test.py ``` with ```Python import ray ray.init(runtime_env={"py_executable": "uv run --with emoji"}) @ray.remote def f(): import emoji return emoji.emojize("Ray rocks :thumbs_up:") print(ray.get(f.remote())) ``` **Slightly more complex example** with `pyproject.toml` in the working_dir (see https://docs.astral.sh/uv/guides/scripts): ``` uv run test.py ``` with pyproject.toml: ```toml [project] name = "test" version = "0.1" dependencies = [ "rich", "emoji", "ray", # had to do "ray @ file:///tmp/ray-2.41.0-cp312-cp312-macosx_11_0_arm64.whl" here since this is not released yet ] ``` text.py ```Python import ray import time from rich.progress import track ray.init(runtime_env={"working_dir": ".", "py_executable": "uv run --isolated"}) @ray.remote def f(): import emoji return emoji.emojize("Ray rocks :thumbs_up:") for i in track(range(20), description="For example:"): print(ray.get(f.remote())) time.sleep(0.05) ``` And the dependencies can also be locked with `uv lock`. ## Related issue number <!-- For example: "Closes ray-project#1234" --> ## 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: Philipp Moritz <pcmoritz@gmail.com> Co-authored-by: pcmoritz <pcmoritz@anyscale.com> Co-authored-by: angelinalg <122562471+angelinalg@users.noreply.github.com>
xsuler
pushed a commit
to antgroup/ant-ray
that referenced
this pull request
Mar 4, 2025
…ray-project#50462) <!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? Next step after ray-project#50160 to make it more convenient to use UV with Ray. This is a useful runtime environment hook for mirroring the environment of `uv run` to the workers (currently the args to uv run and the working_dir). This is useful because it will allow people to intuitively use `uv run` in a distributed application with the same behavior as for a single python process. This only modifies the environment if the driver was run with `uv run` and could conceivably become the default for drivers run with uv run. This is currently a developer API as implied by the fact that it is in the `_private` namespace. It is currently for experimentation and can needs to be opted in via ```shell export RAY_RUNTIME_ENV_HOOK=ray._private.runtime_env.uv_runtime_env_hook.hook ``` If it works well, we might make it the default in the `uv run` case. ## Related issue number <!-- For example: "Closes ray-project#1234" --> ## 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: Philipp Moritz <pcmoritz@gmail.com> Co-authored-by: Edward Oakes <ed.nmi.oakes@gmail.com> Co-authored-by: angelinalg <122562471+angelinalg@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why are these changes needed?
This implements a very simple runtime environment plugin that allows e.g. using the
uv run
command for dependency handling (but could also be useful for wrapping the worker command e.g. with a profiler or debugger).Very simple example:
with
Slightly more complex example with
pyproject.toml
in the working_dir (see https://docs.astral.sh/uv/guides/scripts):with
pyproject.toml:
text.py
And the dependencies can also be locked with
uv lock
.Related issue number
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.