Skip to content

[Runtime Env] Fix ray job submit --working-dir for local zip files and http:// URLs#62843

Merged
edoakes merged 3 commits into
ray-project:masterfrom
wenhaozhao011-cmd:fix-job-submit-working-dir
May 8, 2026
Merged

[Runtime Env] Fix ray job submit --working-dir for local zip files and http:// URLs#62843
edoakes merged 3 commits into
ray-project:masterfrom
wenhaozhao011-cmd:fix-job-submit-working-dir

Conversation

@wenhaozhao011-cmd

Copy link
Copy Markdown
Contributor

Why are these changes needed?

When using the ray job submit command with --working-dir pointing to a local zip file or an HTTP URL of a zip file, we encountered some bugs. For details, please refer to the two issues below:

1. Local zip files fail to upload (#34605)

When a local .zip file is specified as working_dir, the code in
upload_working_dir_if_needed() bypassed the HTTP-based upload_fn
callback and called upload_package_to_gcs() directly. This requires
an active GCS connection via ray.init(), which is never called by
the CLI client, causing a RuntimeError.

Fix: Check upload_fn before choosing the upload mechanism, following
the same pattern used in py_modules.py for .whl files (lines 140-154).

2. HTTP URLs not recognized as remote URIs (#45954)

http:// URLs were not recognized as valid remote URIs because the http
protocol was missing from the Protocol enum and get_remote_protocols().
The URL was incorrectly treated as a local path.

Fix: Add http to get_protocols(), get_remote_protocols(), and
download_remote_uri(), reusing the existing HTTPS handler since
smart_open already supports both HTTP and HTTPS.

Related issue number

Closes #34605
Closes #45954

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 tests if needed.
@wenhaozhao011-cmd wenhaozhao011-cmd requested a review from a team as a code owner April 22, 2026 02:49

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for the http protocol in Ray's runtime environment, allowing remote HTTP paths for zip files, and updates upload_working_dir_if_needed to utilize an optional upload_fn for local zip files. The review feedback suggests consolidating the http and https protocol handling blocks to reduce duplication, updating the type hint for upload_fn to include the new is_file parameter, and removing a redundant test case.

Comment thread python/ray/_private/runtime_env/protocol.py Outdated
Comment thread python/ray/_private/runtime_env/working_dir.py
Comment thread python/ray/tests/test_runtime_env_packaging.py Outdated
@wenhaozhao011-cmd wenhaozhao011-cmd force-pushed the fix-job-submit-working-dir branch from aea1a79 to 4e96f0b Compare April 22, 2026 02:59
@ray-gardener ray-gardener Bot added core Issues that should be addressed in Ray Core community-contribution Contributed by the community labels Apr 22, 2026
@edoakes edoakes added the go add ONLY when ready to merge, run all tests label Apr 22, 2026
@edoakes edoakes enabled auto-merge (squash) April 22, 2026 21:36
@github-actions github-actions Bot disabled auto-merge April 23, 2026 03:53

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit b14f5778843d08749cb4baa3ec8a8fbb113d9f96. Configure here.

Comment thread python/ray/_private/runtime_env/protocol.py
…and http:// URLs

Fix two bugs in `ray job submit --working-dir`:

1. **Local zip files (ray-project#34605)**: When a local `.zip` file is specified as
   `working_dir`, the upload path bypassed the HTTP-based `upload_fn` and
   called `upload_package_to_gcs()` directly, which requires `ray.init()`
   (never called by the CLI client). Now respects `upload_fn` when provided,
   following the same pattern used in `py_modules.py` for `.whl` files.

2. **HTTP URLs (ray-project#45954)**: `http://` URLs were not recognized as remote URIs
   because `http` was missing from the Protocol enum and remote protocols set.
   Added `http` protocol support, reusing the existing HTTPS handler since
   `smart_open` supports both.

🤖 Generated with [Qoder][https://qoder.com]

Signed-off-by: leqiong <leqiong.zwh@alibaba-inc.com>
@wenhaozhao011-cmd wenhaozhao011-cmd force-pushed the fix-job-submit-working-dir branch from b14f577 to 52de6bb Compare April 24, 2026 02:42
@wenhaozhao011-cmd

Copy link
Copy Markdown
Contributor Author

This CI failure appears to be unrelated to this PR.

@wenhaozhao011-cmd

Copy link
Copy Markdown
Contributor Author

Hi @edoakes , I've updated the branch and all checks are passing.
Could you please help merge this PR?

@edoakes edoakes merged commit 80ec850 into ray-project:master May 8, 2026
6 checks passed
@edoakes

edoakes commented May 8, 2026

Copy link
Copy Markdown
Collaborator

@wenhaozhao011-cmd merged -- thanks for the contribution!

Lucas61000 pushed a commit to Lucas61000/ray that referenced this pull request May 15, 2026
…and http:// URLs (ray-project#62843)

## Why are these changes needed?

When using the `ray job submit` command with `--working-dir` pointing to
a local zip file or an HTTP URL of a zip file, we encountered some bugs.
For details, please refer to the two issues below:

### 1. Local zip files fail to upload (ray-project#34605)

When a local `.zip` file is specified as `working_dir`, the code in
`upload_working_dir_if_needed()` bypassed the HTTP-based `upload_fn`
callback and called `upload_package_to_gcs()` directly. This requires
an active GCS connection via `ray.init()`, which is never called by
the CLI client, causing a `RuntimeError`.

**Fix:** Check `upload_fn` before choosing the upload mechanism,
following
the same pattern used in `py_modules.py` for `.whl` files (lines
140-154).

### 2. HTTP URLs not recognized as remote URIs (ray-project#45954)

`http://` URLs were not recognized as valid remote URIs because the
`http`
protocol was missing from the `Protocol` enum and
`get_remote_protocols()`.
The URL was incorrectly treated as a local path.

**Fix:** Add `http` to `get_protocols()`, `get_remote_protocols()`, and
`download_remote_uri()`, reusing the existing HTTPS handler since
`smart_open` already supports both HTTP and HTTPS.

## Related issue number

Closes ray-project#34605
Closes ray-project#45954

## Checks

- [x] I've signed off every commit(by using the -s flag, i.e.,
  `git commit -s`) in this PR.
- [x] 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/.
- [x] I've added any new tests if needed.

Signed-off-by: leqiong <leqiong.zwh@alibaba-inc.com>
Co-authored-by: leqiong <leqiong.zwh@alibaba-inc.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests

2 participants