Repository navigation
[core] Add local:// runtime_env URIs for code already in node - #65245
abrarsheikh merged 18 commits into
Conversation
Signed-off-by: YashwanthRanjanSingaravel <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces support for "local://" URIs in "working_dir" and "py_modules" within Ray's runtime environments, allowing the use of directories already present on all cluster nodes without packaging or uploading them. The review feedback highlights several Windows-specific issues, including a command execution failure when paths contain spaces, and multiple test failures due to Unix-style absolute paths not being recognized as absolute on Windows. Suggestions are provided to make both the runtime execution and the test suite fully cross-platform.
Signed-off-by: YashwanthRanjanSingaravel <[email protected]>
…anSingaravel/ray into feat/image-workdir-support
There was a problem hiding this comment.
Code Review
This pull request introduces support for local:// URIs in runtime_env (working_dir and py_modules), allowing users to reference directories already present on all cluster nodes (such as those baked into container images) without uploading or downloading them. Feedback highlights a potential issue on Windows where using subprocess.list2cmdline to quote paths for cmd.exe shell execution (such as cd) can fail if the path contains shell metacharacters like & but no spaces, suggesting wrapping the path in double quotes directly instead.
|
bugbot run |
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
Signed-off-by: YashwanthRanjanSingaravel <[email protected]>
9f768ca to
296937f
Compare
Signed-off-by: YashwanthRanjanSingaravel <[email protected]>
|
Please fix premerge errors. We also need to trigger Windows CI runs before merging this PR. |
ronny-anyscale
left a comment
There was a problem hiding this comment.
Docs style review from the Anyscale docs team, scoped to prose style, grammar, and Ray's documentation conventions. I don't own this code, so anything technical below is a question for the maintainers rather than a request.
Ronny Roland (Anyscale docs team) ran this review with Claude Code assisting. I read every comment and stand behind each one.
This is non-blocking. @abrarsheikh and @MortalHappiness have both approved, and the approval is on the head I reviewed (73fd81b). Nothing here should hold the merge. If it lands first, I'll open a follow-up PR with these instead.
The standard is Ray's own style guide, doc/source/ray-contribute/writing-style.md. Worth noting that Vale doesn't gate this page at all (.vale.ini scopes it to Ray Data and the example gallery), so none of this would have been caught automatically.
The new local:// section is genuinely good. The warning about content drift across nodes is the right call and states the failure mode precisely, and the py_modules versus local-path contrast is the clearest part of the page. The comments are small: semicolons and parentheticals (§Sentence structure), "note that" (§Cut qualifiers and filler), a few passive constructions with Ray as the actor, one parallel-structure slip, and a list lead-in.
A note on two things I checked and deliberately left alone:
local://C:/appon L829 is correct with two slashes.parse_uriaccepts it alongsidelocal:///C:/app, and the error message recommends that exact spelling. My comment there is wording only.- The archive list on L863 matches
PACKAGE_UPLOAD_EXTENSIONSexactly.
I also read this thread before writing anything. The py_modules PYTHONPATH difference was settled there as "keep the behavior, document it carefully," and this section is that documentation, so my L845 comment styles your applied fix rather than reopening the discussion.
One question, no suggestion attached: the heading "Directories already present on every node" doesn't contain local://, which is the string a reader scanning this page for the feature will look for. Something in the shape of "Local URIs" would also sit parallel to the "Remote URIs" section immediately below it. Entirely your call, and safe either way since the :ref: label is explicit.
On wrapping: the new section hard-wraps mid-sentence at roughly 88 columns. The rest of this file and the guide's §Soft-wrap prose both want one source line per paragraph, so my suggestions soft-wrap as they go.
Signed-off-by: YashwanthRanjanSingaravel <[email protected]>
Signed-off-by: YashwanthRanjanSingaravel <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 48097bd. Configure here.
Signed-off-by: YashwanthRanjanSingaravel <[email protected]>
#66292) ## Description - `TestLocalWorkingDir::test_used_in_place_without_upload[working_dir]` passes, then errors at teardown. - On Windows the error is `RecursionError: maximum recursion depth exceeded`. - A `local://` working_dir is used in place, so `modify_context` makes it the worker's cwd. - Windows refuses to remove a directory a live process sits in, giving `WinError 32`. - `TemporaryDirectory`'s `onerror` handler then recurses until the stack runs out. - The test requested `start_cluster` before `tmp_working_dir`. - pytest tears fixtures down in reverse, so the directory went away while workers were alive. - Introduced by #65245. It only shows in the soft failing flaky Windows postmerge job. ## Changes - `test_runtime_env_working_dir.py`: request `tmp_working_dir` before `start_cluster`. - The cluster now tears down first. - `Cluster.shutdown` kills worker processes with `wait=True`, so the directory is free. - The docstring records why the fixture order matters. ## Tests - No new test. The existing `[working_dir]` parameter is the regression test, and it is the failing one. - `[py_modules]` already passed, because that path only extends `PYTHONPATH` and never sets cwd. - The production behaviour is unchanged; `test_directory_is_never_deleted` still covers it. --------- Signed-off-by: YashwanthRanjanSingaravel <[email protected]>
ray-project#66292) ## Description - `TestLocalWorkingDir::test_used_in_place_without_upload[working_dir]` passes, then errors at teardown. - On Windows the error is `RecursionError: maximum recursion depth exceeded`. - A `local://` working_dir is used in place, so `modify_context` makes it the worker's cwd. - Windows refuses to remove a directory a live process sits in, giving `WinError 32`. - `TemporaryDirectory`'s `onerror` handler then recurses until the stack runs out. - The test requested `start_cluster` before `tmp_working_dir`. - pytest tears fixtures down in reverse, so the directory went away while workers were alive. - Introduced by ray-project#65245. It only shows in the soft failing flaky Windows postmerge job. ## Changes - `test_runtime_env_working_dir.py`: request `tmp_working_dir` before `start_cluster`. - The cluster now tears down first. - `Cluster.shutdown` kills worker processes with `wait=True`, so the directory is free. - The docstring records why the fixture order matters. ## Tests - No new test. The existing `[working_dir]` parameter is the regression test, and it is the failing one. - `[py_modules]` already passed, because that path only extends `PYTHONPATH` and never sets cwd. - The production behaviour is unchanged; `test_directory_is_never_deleted` still covers it. --------- Signed-off-by: YashwanthRanjanSingaravel <[email protected]>
…cted (#66302) ## Description - `TestLocalWorkingDir::test_relative_path_rejected_on_the_client` passes, then errors at teardown. - Only in `//python/ray/tests:test_runtime_env_working_dir_client_mode`, on every Windows postmerge run. - The teardown error is: - `ValueError: Removing a node that is connected to this Ray client is not allowed` - raised by `Cluster.remove_node` at `cluster_utils.py:305`. - `connect` sets `worker.node` before it validates the runtime_env. - `worker.py:2649` reads `worker.node.get_runtime_env_dir_path()`, then calls `upload_working_dir_if_needed`. - `parse_uri` rejects the relative `local://` path there, so `ray.init` raises after connecting. - The driver is left attached to the head node. - Under `RAY_CLIENT_MODE=1` the fixture's own `ray.shutdown` is redirected to the Ray Client. - It never reaches `disconnect`, which is what clears `worker.node` at `worker.py:2827`. - That is why the plain target passes and only the client mode target fails. - Introduced by #65245. ## Changes - `test_runtime_env_working_dir.py`: detach the driver after the expected `ValueError`. - The `ray.shutdown` runs inside `disable_client_hook` so it reaches the real one in both modes. - `disable_client_hook` restores the previous hook state on exit; `test_client.py` already uses it. ## Tests - No new test. The existing test is the regression test, and it is the one erroring today. - Verified the bypass with `RAY_CLIENT_MODE=1`: `client_mode_should_convert()` is `True` normally, `False` inside `disable_client_hook()`, and `True` again afterwards. - The client side rejection itself stays covered by `unit/test_runtime_env_working_dir.py`. --------- Signed-off-by: YashwanthRanjanSingaravel <[email protected]>
…oject#65245) ## Description - Adds a `local://` runtime_env URI: `working_dir: local:///app` - Used in place with no uploading or unpacking ## Changes - `Protocol.LOCAL`: `parse_uri` returns the path itself, rejects non absolute paths. - `working_dir`/`py_modules`: no upload or download, 0 bytes cached, never deleted. - new section in the docs. --------- Signed-off-by: YashwanthRanjanSingaravel <[email protected]>
ray-project#66292) ## Description - `TestLocalWorkingDir::test_used_in_place_without_upload[working_dir]` passes, then errors at teardown. - On Windows the error is `RecursionError: maximum recursion depth exceeded`. - A `local://` working_dir is used in place, so `modify_context` makes it the worker's cwd. - Windows refuses to remove a directory a live process sits in, giving `WinError 32`. - `TemporaryDirectory`'s `onerror` handler then recurses until the stack runs out. - The test requested `start_cluster` before `tmp_working_dir`. - pytest tears fixtures down in reverse, so the directory went away while workers were alive. - Introduced by ray-project#65245. It only shows in the soft failing flaky Windows postmerge job. ## Changes - `test_runtime_env_working_dir.py`: request `tmp_working_dir` before `start_cluster`. - The cluster now tears down first. - `Cluster.shutdown` kills worker processes with `wait=True`, so the directory is free. - The docstring records why the fixture order matters. ## Tests - No new test. The existing `[working_dir]` parameter is the regression test, and it is the failing one. - `[py_modules]` already passed, because that path only extends `PYTHONPATH` and never sets cwd. - The production behaviour is unchanged; `test_directory_is_never_deleted` still covers it. --------- Signed-off-by: YashwanthRanjanSingaravel <[email protected]>
…cted (ray-project#66302) ## Description - `TestLocalWorkingDir::test_relative_path_rejected_on_the_client` passes, then errors at teardown. - Only in `//python/ray/tests:test_runtime_env_working_dir_client_mode`, on every Windows postmerge run. - The teardown error is: - `ValueError: Removing a node that is connected to this Ray client is not allowed` - raised by `Cluster.remove_node` at `cluster_utils.py:305`. - `connect` sets `worker.node` before it validates the runtime_env. - `worker.py:2649` reads `worker.node.get_runtime_env_dir_path()`, then calls `upload_working_dir_if_needed`. - `parse_uri` rejects the relative `local://` path there, so `ray.init` raises after connecting. - The driver is left attached to the head node. - Under `RAY_CLIENT_MODE=1` the fixture's own `ray.shutdown` is redirected to the Ray Client. - It never reaches `disconnect`, which is what clears `worker.node` at `worker.py:2827`. - That is why the plain target passes and only the client mode target fails. - Introduced by ray-project#65245. ## Changes - `test_runtime_env_working_dir.py`: detach the driver after the expected `ValueError`. - The `ray.shutdown` runs inside `disable_client_hook` so it reaches the real one in both modes. - `disable_client_hook` restores the previous hook state on exit; `test_client.py` already uses it. ## Tests - No new test. The existing test is the regression test, and it is the one erroring today. - Verified the bypass with `RAY_CLIENT_MODE=1`: `client_mode_should_convert()` is `True` normally, `False` inside `disable_client_hook()`, and `True` again afterwards. - The client side rejection itself stays covered by `unit/test_runtime_env_working_dir.py`. --------- Signed-off-by: YashwanthRanjanSingaravel <[email protected]>
) ## Description Adds a caution to the `uv run` section of the runtime environments page: don't set `py_executable` to a bare `uv run` to enable the uv integration. When the driver is launched with `uv run`, Ray sets `py_executable` itself. A bare `uv run` starts workers in whatever environment uv resolves from the worker's starting directory, and if that environment lacks Ray, workers crash on startup and jobs hang without a clear error. @martinlhw, this is a docs-only alternative to #66191, which you're assigned to. Your question on that PR, whether bare `uv run` always fails, turned out to be the deciding one: it doesn't. Results on Ray 2.59.0 with uv 0.11.14, macOS, local cluster: | Setup | Result | |---|---| | Plain `python` driver outside any uv project, `py_executable="uv run"` | Workers crash with `ModuleNotFoundError: No module named 'ray'`; `ray.get` times out | | Plain `python` driver inside a uv project that depends on Ray | Works | | Driver launched with `uv run` | Works, because the uv hook overwrites `py_executable` | | `JobSubmissionClient.submit_job` with `py_executable="uv run"`, cluster started inside a uv project | `SUCCEEDED`, with and without `working_dir` | | Same submission, cluster started outside a uv project | Stuck in `PENDING` (reproduces #54275) | Because the bare value works in some setups, rejecting it with a `ValueError` as #66191 does would break working configurations, including per-task `runtime_env` usage that the uv hook never rewrites. The failure is also the same one any `py_executable` pointing at a Python without Ray produces, so a string match on `uv run` covers only one case of it. A docs caution addresses what the issue reporter asked for at minimum, "noting in the docs specifically that `py_executable` shouldn't be provided." If Core wants a runtime guard too, a warning rather than an error seems like the safer shape, and it can land separately. ## Related issues Addresses #54275. Supersedes #66191, which conflicts with master: its `local://` changes landed separately in #65245, and the page it edits moved to MyST in #66461. ## Additional information - Duplicate check: #66191 is the only open PR referencing #54275, and none of the open `py_executable` or uv PRs touch this guidance. - Tests: prose-only change. Vale reports no findings on the added lines, and pre-commit passes. The behavior described is from the local runs in the table above. - AI assistance: Claude Code drafted this change and ran the tests above. I reviewed every line. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>

Description
local://runtime_env URI:working_dir: local:///appChanges
Protocol.LOCAL:parse_urireturns the path itself, rejects non absolute paths.working_dir/py_modules: no upload or download, 0 bytes cached, never deleted.