Repository navigation
Fix bare 'uv run' py_executable causing unloadable logs - #66191
lorenzozanee wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds documentation for local:// URIs and introduces validation for the py_executable option, specifically deprecating the bare uv run command. However, several issues were identified in the review: a critical ImportError is raised because get_local_dir_uri_path is imported but not defined, suggesting the local:// implementation is missing; the is_uv detection is fragile on Windows and should be made more robust; and a redundant warning log is printed right before raising a ValueError.
| from ray._private.runtime_env.packaging import get_local_dir_uri_path | ||
|
|
||
| if get_local_dir_uri_path(uri) is not None: | ||
| return |
There was a problem hiding this comment.
The function get_local_dir_uri_path is imported from ray._private.runtime_env.packaging, but it is not defined there (or anywhere else in the codebase). This will raise an ImportError on startup for any job that validates URIs, completely breaking runtime environment validation.\n\nIt appears that the implementation of local:// URIs is missing from this pull request, even though the documentation and validation changes for it were included (likely due to a rebasing or rebuilding error from a superceded PR). Please either include the missing implementation of local:// URIs or remove the local:// documentation and validation changes if they are not intended for this PR.
| is_uv = ( | ||
| first == "uv" | ||
| or first.endswith("/uv") | ||
| or first.endswith("\\uv") | ||
| or first == "uv.exe" | ||
| ) |
There was a problem hiding this comment.
The current check for is_uv using endswith is fragile and will fail to detect a bare uv run on Windows if a path prefix is used with uv.exe (e.g., C:\\bin\\uv.exe run). This is because first.endswith("\\\\uv") will not match uv.exe.\n\nWe can make this check much more robust and cleaner by using os.path.basename after normalizing the path separators.
import os\n is_uv = os.path.basename(first.replace("\\\\", "/")) in ("uv", "uv.exe")| logger.warning( | ||
| "runtime_env['py_executable']='uv run' is deprecated and no " | ||
| "longer required since Ray 2.47. The uv integration is now " | ||
| "automatic when you run your driver with 'uv run'; please " | ||
| "remove 'py_executable' from your runtime_env. Jobs with uv " | ||
| "succeed without it. If you need a custom executable, use a " | ||
| "full command (the hook sets 'uv run --python X.Y.Z python' " | ||
| "automatically)." | ||
| ) | ||
| raise ValueError( | ||
| "runtime_env['py_executable']='uv run' is deprecated and no " | ||
| "longer required since Ray 2.47. Ray's uv integration is now " | ||
| "automatic when the driver is launched with 'uv run'; please " | ||
| "remove 'py_executable' from your runtime_env. Jobs with uv " | ||
| "succeed without py_executable (see " | ||
| "https://docs.ray.io/en/latest/ray-core/handling-dependencies.html" | ||
| "#using-uv-for-package-management). Got: " | ||
| f"{py_executable!r}. If you need a custom worker command, " | ||
| "provide the full executable (e.g., the hook uses " | ||
| "'uv run --python X.Y.Z python')." | ||
| ) |
There was a problem hiding this comment.
The logger.warning call is redundant because a ValueError with almost the exact same message is raised immediately afterwards. Since the exception will propagate and halt execution, the warning will never be useful on its own and only clutters the logs/output. We should remove the redundant warning.
raise ValueError(\n "runtime_env['py_executable']='uv run' is deprecated and no "\n "longer required since Ray 2.47. Ray's uv integration is now "\n "automatic when the driver is launched with 'uv run'; please "\n "remove 'py_executable' from your runtime_env. Jobs with uv "\n "succeed without py_executable (see "\n "https://docs.ray.io/en/latest/ray-core/handling-dependencies.html"\n "#using-uv-for-package-management). Got: "\n f"{py_executable!r}. If you need a custom worker command, "\n "provide the full executable (e.g., the hook uses "\n "'uv run --python X.Y.Z python')."\n )| - ``working_dir`` (str): Specifies the working directory for the Ray workers. This must either be (1) a local existing directory with total size at most 500 MiB, (2) a local existing archive file (``.zip``, ``.tar.gz``, ``.tgz``, or ``.tar.xz``) with total uncompressed size at most 500 MiB (Note: ``excludes`` has no effect), (3) a URI to a remotely-stored archive (``.zip``, ``.tar.gz``, ``.tgz``, or ``.tar.xz``) containing the working directory for your job (no file size limit is enforced by Ray), or (4) a ``local://`` URI naming a directory that already exists on every node, such as one baked into your container image. See :ref:`remote-uris` for details. | ||
| In cases (1) through (3), the specified directory is downloaded to each node on the cluster, and Ray workers start in their node's copy of this directory. In case (4), Ray uploads and downloads nothing, and the workers start directly in that directory. See :ref:`in-image-working-dir`. |
There was a problem hiding this comment.
This PR includes extensive documentation updates for local:// URIs (e.g., here and in the new Local URIs section), but the actual implementation of local:// URIs is missing from the codebase (which also causes a critical ImportError in validation.py).\n\nIf local:// URIs are out of scope for this PR, please revert all documentation changes related to local:// URIs and move them to the appropriate PR where the feature is implemented.
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 a2f0149. Configure here.
| from ray._private.runtime_env.packaging import get_local_dir_uri_path | ||
|
|
||
| if get_local_dir_uri_path(uri) is not None: | ||
| return |
There was a problem hiding this comment.
URI validation imports missing helper
High Severity
validate_uri now imports and calls get_local_dir_uri_path, which is not defined in this tree. Every working_dir or py_modules URI therefore fails validation with an ImportError, including previously valid remote archives.
Reviewed by Cursor Bugbot for commit a2f0149. Configure here.
…ervability pages to MyST (#66461) ## Why are these changes needed? Converts the last non-API-reference RST pages under `ray-core/`, `data/`, and `rllib/` to MyST Markdown, plus the `train/` and `ray-observability/` pages that `doc/BUILD.bazel` names by path. The API reference trees (`*/api/`, `rllib/package_ref/`, and `ray-core/compiled-graph/compiled-graph-api`) stay RST for now. Each page gets its own commit, so you can review one file at a time. Every commit renames the page's literal `.rst` paths in `doc/BUILD.bazel` to `.md`. These paths are in `exclude` lists and in the explicit `files` lists of `doctest[data-gpu]` and `doctest[train-gpu]`, and they don't glob. Without the edit, an excluded page would silently join its target once it's `.md`, and an included page would silently drop out of it. Conversions are format-only: labels, headings, and prose are unchanged. A final whitespace-only commit soft-wraps the prose. `ray-soft-wrap`'s `verify.py` confirms non-whitespace bytes, rendered HTML, and idempotence for all 11 files. ### `rllib/getting-started`: doctest target removed The first commit deletes `doctest[rllib2]`, the only target over `rllib/getting-started.rst`, before the page converts. The target is tagged `manual` with a hang TODO, so no premerge or postmerge step has run it, and nothing else references it (`git grep rllib2` is empty). Its 15 `testcode` blocks had no `testoutput`, so they asserted nothing. The 12 visible blocks become display-only `python` code blocks. The three `:hide:` blocks held `.stop()` cleanups that never rendered, so they're deleted. `doctest[rllib]` still excludes the page. If these examples should be validated later, a `doc_code/` script is the better route than reviving the hanging target. cc @elliot-barn, who owns the TODO. This commit isn't buildable on its own. It turns a `.. testcode::` that had no blank line before its body into a `.. code-block:: python`, still with no blank line, and docutils reads the body as extra arguments to the directive. The later conversion commit fixes it in the `.md`, and a squash merge never puts the intermediate commit on master. ### Doctest coverage Docs-only PRs don't run doctests premerge. This PR edits `doc/BUILD.bazel`, so every library's docs example step runs, but premerge can't show the conversion kept the same blocks. For that, I parsed each `.md` and the `.rst` it replaced with Ray's `pytest-sphinx` fork, the same parser the doctest macro runs, and asserted identical sections (directive, body, `:options:`, `:skipif:`) and examples. | Page | BUILD role | Examples before → after | | --- | --- | --- | | `ray-core/handling-dependencies` | `doctest[core]` exclude | 17 → 17 | | `ray-core/tasks/nested-tasks` | `doctest[core]` exclude | 0 → 0 (`literalinclude` of a tested `doc_code/` file) | | `data/batch-inference` | `doctest_each` exclude, `doctest[data-gpu]` files | 7 → 7 | | `data/transforming-data` | `doctest_each` exclude, `doctest[data-gpu]` files | 24 → 24 | | `data/contributing/contributing` | `doctest_each` glob | 0 → 0 (toctree only) | | `rllib/getting-started` | `doctest[rllib]` exclude, `doctest[rllib2]` removed | 15 → 0, by the removal commit | | `ray-observability/user-guides/cli-sdk` | top-level exclude | 16 → 16 | | `ray-observability/user-guides/ray-tracing` | top-level exclude | 3 → 3 | | `train/horovod` | `doctest[train]` exclude | 2 → 2 | | `train/user-guides/data-loading-preprocessing` | `doctest[train]` exclude, `doctest[train-gpu]` files | 6 → 6 | | `train/user-guides/using-accelerators` | `doctest[train]` exclude, `doctest[train-gpu]` files | 10 → 10 | To show the check would catch a broken conversion, I mutated each page with examples three ways: dropping a `testcode` block, altering a line in one, and turning one into a four-backtick fence. The last renders fine but is never collected. The check failed on all 24 mutations. ### Rendering changes I ran `render_diff.py` on all 11 pages against `/en/master`. Six render identically: `nested-tasks`, `data/contributing/contributing`, `cli-sdk`, `ray-tracing`, `horovod`, and `using-accelerators`. Every difference on the other five is listed here. - `rllib/getting-started`: on master, one `.. testcode::` line had no blank line after it. docutils read the block's first six lines, the `best_result = results.get_best_result(...)` call, as the directive's argument and dropped them. So master shows code that uses `best_result` without showing where it comes from. The converted page renders all six lines. This is the one place the conversion deliberately doesn't reproduce master. - `rllib/getting-started`: the "Farama gymnasium" link now has `https://`. On master it's a relative link to `gymnasium.farama.org` that 404s. - `ray-core/handling-dependencies`: MyST drops the apostrophe when it slugifies the "can't import the packages" heading, so the section id changes. That heading had no label, so the page adds a target carrying the old docutils slug, and existing `#...-can-t-import-...` links still resolve. An auto-numbered span id, which nothing links to, also changes from `id4` to `id2`. - `data/batch-inference` and `train/user-guides/data-loading-preprocessing`: each renders an RST comment as an HTML comment, which readers never see. - `data/transforming-data`: the "When using" definition list's `<dl>` gains the unstyled `myst` class. The first preview diff also caught three regressions that the green build didn't. MyST's `replacements` extension turned two `(c)` list markers into `©` and an `etc..` into `etc…`. The anchor above had changed too. A follow-up commit fixes all three. A sweep of the 11 pages found no other text that extension rewrites. ### Dead `doc/BUILD.bazel` excludes A final commit drops four `exclude` entries that name files that have moved: two in `doctest[serve]` and two in the serve `doc_code` test. A glob exclude naming a missing file excludes nothing, so these had silently stopped applying. This doesn't change what any target runs. #66462 carries the same commit, along with a lint check that fails on this class of stale path, so the two PRs merge cleanly in either order. ### Open PRs that edit these files Each of these open PRs edits one of the converted `.rst` files, so each will need to move its change to the `.md`: #66279, #66191, #65956, #65933, and #65830 (`handling-dependencies`), #65693 (`cli-sdk`), and #66419, #66420, #66422, and #66423 (`data/batch-inference`, `train/user-guides/data-loading-preprocessing`). #66096, #64053, and #63881 also edit `doc/BUILD.bazel`, and only #66096 edits nearby lines. ## Related issue number None. No open PR converts these pages. I checked `gh pr list` for open PRs touching each file. ## Checks - [x] I've signed off every commit (`git commit -s`). - [x] Pre-commit hooks passed on every commit. - Doctest parity: `python3 doctest_parity.py <the 11 .md files>` with `pytest==7.4.4` and `pytest-sphinx @ git+https://github.com/ray-project/pytest-sphinx`. All OK, run again after the soft-wrap commit. - Static checks on every `.md`: fences balance, no leftover RST roles or directives, every label from the `.rst` is present, and directive counts match. - Read the Docs preview builds green under `fail_on_warning`, and the render diff against `/en/master` is in Rendering changes. The first build hit the known autosummary-import segfault and passed on rebuild. - Local doctest run: not done. The GPU targets need hardware, and the CPU targets run in this PR's premerge because of the `BUILD.bazel` change. AI assistance (Claude Code) was used for the conversion and the verification scripts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
…ervability pages to MyST (ray-project#66461) ## Why are these changes needed? Converts the last non-API-reference RST pages under `ray-core/`, `data/`, and `rllib/` to MyST Markdown, plus the `train/` and `ray-observability/` pages that `doc/BUILD.bazel` names by path. The API reference trees (`*/api/`, `rllib/package_ref/`, and `ray-core/compiled-graph/compiled-graph-api`) stay RST for now. Each page gets its own commit, so you can review one file at a time. Every commit renames the page's literal `.rst` paths in `doc/BUILD.bazel` to `.md`. These paths are in `exclude` lists and in the explicit `files` lists of `doctest[data-gpu]` and `doctest[train-gpu]`, and they don't glob. Without the edit, an excluded page would silently join its target once it's `.md`, and an included page would silently drop out of it. Conversions are format-only: labels, headings, and prose are unchanged. A final whitespace-only commit soft-wraps the prose. `ray-soft-wrap`'s `verify.py` confirms non-whitespace bytes, rendered HTML, and idempotence for all 11 files. ### `rllib/getting-started`: doctest target removed The first commit deletes `doctest[rllib2]`, the only target over `rllib/getting-started.rst`, before the page converts. The target is tagged `manual` with a hang TODO, so no premerge or postmerge step has run it, and nothing else references it (`git grep rllib2` is empty). Its 15 `testcode` blocks had no `testoutput`, so they asserted nothing. The 12 visible blocks become display-only `python` code blocks. The three `:hide:` blocks held `.stop()` cleanups that never rendered, so they're deleted. `doctest[rllib]` still excludes the page. If these examples should be validated later, a `doc_code/` script is the better route than reviving the hanging target. cc @elliot-barn, who owns the TODO. This commit isn't buildable on its own. It turns a `.. testcode::` that had no blank line before its body into a `.. code-block:: python`, still with no blank line, and docutils reads the body as extra arguments to the directive. The later conversion commit fixes it in the `.md`, and a squash merge never puts the intermediate commit on master. ### Doctest coverage Docs-only PRs don't run doctests premerge. This PR edits `doc/BUILD.bazel`, so every library's docs example step runs, but premerge can't show the conversion kept the same blocks. For that, I parsed each `.md` and the `.rst` it replaced with Ray's `pytest-sphinx` fork, the same parser the doctest macro runs, and asserted identical sections (directive, body, `:options:`, `:skipif:`) and examples. | Page | BUILD role | Examples before → after | | --- | --- | --- | | `ray-core/handling-dependencies` | `doctest[core]` exclude | 17 → 17 | | `ray-core/tasks/nested-tasks` | `doctest[core]` exclude | 0 → 0 (`literalinclude` of a tested `doc_code/` file) | | `data/batch-inference` | `doctest_each` exclude, `doctest[data-gpu]` files | 7 → 7 | | `data/transforming-data` | `doctest_each` exclude, `doctest[data-gpu]` files | 24 → 24 | | `data/contributing/contributing` | `doctest_each` glob | 0 → 0 (toctree only) | | `rllib/getting-started` | `doctest[rllib]` exclude, `doctest[rllib2]` removed | 15 → 0, by the removal commit | | `ray-observability/user-guides/cli-sdk` | top-level exclude | 16 → 16 | | `ray-observability/user-guides/ray-tracing` | top-level exclude | 3 → 3 | | `train/horovod` | `doctest[train]` exclude | 2 → 2 | | `train/user-guides/data-loading-preprocessing` | `doctest[train]` exclude, `doctest[train-gpu]` files | 6 → 6 | | `train/user-guides/using-accelerators` | `doctest[train]` exclude, `doctest[train-gpu]` files | 10 → 10 | To show the check would catch a broken conversion, I mutated each page with examples three ways: dropping a `testcode` block, altering a line in one, and turning one into a four-backtick fence. The last renders fine but is never collected. The check failed on all 24 mutations. ### Rendering changes I ran `render_diff.py` on all 11 pages against `/en/master`. Six render identically: `nested-tasks`, `data/contributing/contributing`, `cli-sdk`, `ray-tracing`, `horovod`, and `using-accelerators`. Every difference on the other five is listed here. - `rllib/getting-started`: on master, one `.. testcode::` line had no blank line after it. docutils read the block's first six lines, the `best_result = results.get_best_result(...)` call, as the directive's argument and dropped them. So master shows code that uses `best_result` without showing where it comes from. The converted page renders all six lines. This is the one place the conversion deliberately doesn't reproduce master. - `rllib/getting-started`: the "Farama gymnasium" link now has `https://`. On master it's a relative link to `gymnasium.farama.org` that 404s. - `ray-core/handling-dependencies`: MyST drops the apostrophe when it slugifies the "can't import the packages" heading, so the section id changes. That heading had no label, so the page adds a target carrying the old docutils slug, and existing `#...-can-t-import-...` links still resolve. An auto-numbered span id, which nothing links to, also changes from `id4` to `id2`. - `data/batch-inference` and `train/user-guides/data-loading-preprocessing`: each renders an RST comment as an HTML comment, which readers never see. - `data/transforming-data`: the "When using" definition list's `<dl>` gains the unstyled `myst` class. The first preview diff also caught three regressions that the green build didn't. MyST's `replacements` extension turned two `(c)` list markers into `©` and an `etc..` into `etc…`. The anchor above had changed too. A follow-up commit fixes all three. A sweep of the 11 pages found no other text that extension rewrites. ### Dead `doc/BUILD.bazel` excludes A final commit drops four `exclude` entries that name files that have moved: two in `doctest[serve]` and two in the serve `doc_code` test. A glob exclude naming a missing file excludes nothing, so these had silently stopped applying. This doesn't change what any target runs. ray-project#66462 carries the same commit, along with a lint check that fails on this class of stale path, so the two PRs merge cleanly in either order. ### Open PRs that edit these files Each of these open PRs edits one of the converted `.rst` files, so each will need to move its change to the `.md`: ray-project#66279, ray-project#66191, ray-project#65956, ray-project#65933, and ray-project#65830 (`handling-dependencies`), ray-project#65693 (`cli-sdk`), and ray-project#66419, ray-project#66420, ray-project#66422, and ray-project#66423 (`data/batch-inference`, `train/user-guides/data-loading-preprocessing`). ray-project#66096, ray-project#64053, and ray-project#63881 also edit `doc/BUILD.bazel`, and only ray-project#66096 edits nearby lines. ## Related issue number None. No open PR converts these pages. I checked `gh pr list` for open PRs touching each file. ## Checks - [x] I've signed off every commit (`git commit -s`). - [x] Pre-commit hooks passed on every commit. - Doctest parity: `python3 doctest_parity.py <the 11 .md files>` with `pytest==7.4.4` and `pytest-sphinx @ git+https://github.com/ray-project/pytest-sphinx`. All OK, run again after the soft-wrap commit. - Static checks on every `.md`: fences balance, no leftover RST roles or directives, every label from the `.rst` is present, and directive counts match. - Read the Docs preview builds green under `fail_on_warning`, and the render diff against `/en/master` is in Rendering changes. The first build hit the known autosummary-import segfault and passed on rebuild. - Local doctest run: not done. The GPU targets need hardware, and the CPU targets run in this PR's premerge because of the `BUILD.bazel` change. AI assistance (Claude Code) was used for the conversion and the verification scripts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
|
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. |
|
Thanks for picking this up! A few things:
|
|
Thanks for picking up #54275, @lorenzozanee. While looking into @martinlhw's question about whether a bare I opened #67281 as a docs-only fix that adds a caution against a bare |
) ## 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
Since Ray 2.47 the
uvintegration is automatic when the driver is launched withuv run; the hook now setspy_executabletouv run --python X.Y.Z pythonautomatically. The legacy valuepy_executable='uv run'lacks a Python interpreter and causes workers to fail to start with unloadable runtime_env/worker logs. This PR rejects the bare value at validation time with a clear error directing users to removepy_executable.Related issues
Fixes #54275
Additional information
Docs updated to state that
py_executableshould not be set manually foruv.Supercedes #65788(原PR分支已删,按原提交重建)