Skip to content

Conversation

@aslonnie
Copy link
Collaborator

into anyscale_job_runner. it is only used in anyscale_job_runner now

into `anyscale_job_runner`. it is only used in `anyscale_job_runner` now

Signed-off-by: Lonnie Liu <lonnie@anyscale.com>
@aslonnie aslonnie requested a review from a team as a code owner October 13, 2025 19:59
@aslonnie aslonnie added the go add ONLY when ready to merge, run all tests label Oct 13, 2025
Copy link
Contributor

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

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 refactors the codebase by moving the join_cloud_storage_paths function from the general util module to the anyscale_job_runner module, where it is exclusively used. This is a good change that improves modularity. I've added a review comment to improve the implementation of the moved function, making it more robust against edge cases and more Pythonic.

Comment on lines +43 to +52
def _join_cloud_storage_paths(*paths: str):
paths = list(paths)
if len(paths) > 1:
for i in range(1, len(paths)):
while paths[i][0] == "/":
paths[i] = paths[i][1:]
joined_path = os.path.join(*paths)
while joined_path[-1] == "/":
joined_path = joined_path[:-1]
return joined_path
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The current implementation of _join_cloud_storage_paths has a couple of potential issues and can be simplified.

  1. Potential IndexError: The expression paths[i][0] will raise an IndexError if paths[i] is an empty string. Similarly, joined_path[-1] will raise an IndexError if os.path.join returns an empty string (e.g., if no paths are provided).
  2. Inefficient string manipulation: The while loops for stripping leading and trailing slashes can be replaced with the more idiomatic and efficient lstrip('/') and rstrip('/') string methods.

Here is a suggested improvement that addresses these points, making the function more robust and Pythonic.

Suggested change
def _join_cloud_storage_paths(*paths: str):
paths = list(paths)
if len(paths) > 1:
for i in range(1, len(paths)):
while paths[i][0] == "/":
paths[i] = paths[i][1:]
joined_path = os.path.join(*paths)
while joined_path[-1] == "/":
joined_path = joined_path[:-1]
return joined_path
def _join_cloud_storage_paths(*paths: str):
path_list = list(paths)
if len(path_list) > 1:
for i in range(1, len(path_list)):
path_list[i] = path_list[i].lstrip("/")
joined_path = os.path.join(*path_list)
return joined_path.rstrip("/")

@aslonnie aslonnie merged commit 6b3ebc1 into master Oct 13, 2025
5 of 6 checks passed
@aslonnie aslonnie deleted the lonnie-251013-winfix10 branch October 13, 2025 20:19
harshit-anyscale pushed a commit that referenced this pull request Oct 15, 2025
into `anyscale_job_runner`. it is only used in `anyscale_job_runner` now

Signed-off-by: Lonnie Liu <lonnie@anyscale.com>
justinyeh1995 pushed a commit to justinyeh1995/ray that referenced this pull request Oct 20, 2025
into `anyscale_job_runner`. it is only used in `anyscale_job_runner` now

Signed-off-by: Lonnie Liu <lonnie@anyscale.com>
xinyuangui2 pushed a commit to xinyuangui2/ray that referenced this pull request Oct 22, 2025
into `anyscale_job_runner`. it is only used in `anyscale_job_runner` now

Signed-off-by: Lonnie Liu <lonnie@anyscale.com>
Signed-off-by: xgui <xgui@anyscale.com>
elliot-barn pushed a commit that referenced this pull request Oct 23, 2025
into `anyscale_job_runner`. it is only used in `anyscale_job_runner` now

Signed-off-by: Lonnie Liu <lonnie@anyscale.com>
Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
landscapepainter pushed a commit to landscapepainter/ray that referenced this pull request Nov 17, 2025
into `anyscale_job_runner`. it is only used in `anyscale_job_runner` now

Signed-off-by: Lonnie Liu <lonnie@anyscale.com>
Aydin-ab pushed a commit to Aydin-ab/ray-aydin that referenced this pull request Nov 19, 2025
into `anyscale_job_runner`. it is only used in `anyscale_job_runner` now

Signed-off-by: Lonnie Liu <lonnie@anyscale.com>
Signed-off-by: Aydin Abiar <aydin@anyscale.com>
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.

2 participants