Skip to content

Conversation

@elliot-barn
Copy link
Contributor

improving error messages for raydepsets

Updated unit tests to verify error messages

Signed-off-by: elliot-barn <[email protected]>
@elliot-barn elliot-barn requested a review from aslonnie October 23, 2025 19:46
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 significantly improves the error messages in raydepsets, making them more informative and context-rich. The changes to include depset names, config file names, and underlying error details from subprocesses will greatly aid in debugging. The accompanying updates to the unit tests to verify these new error messages are also a great addition.

I've added a few minor suggestions to further improve code clarity, consistency, and remove some leftover debugging code. Overall, this is a solid improvement to the tool's usability.

cmd = [self._uv_binary, "pip", cmd, *args]
click.echo(f"Executing command: {cmd}")
status = subprocess.run(cmd, cwd=self.workspace.dir, input=stdin)
click.echo(f"Executing command: {' '.join(cmd)}")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For logging the command, using shlex.join(cmd) is generally safer than ' '.join(cmd) as it correctly handles arguments that contain spaces or other special characters. This makes the logged command string easier to copy and paste into a shell for debugging.

Suggested change
click.echo(f"Executing command: {' '.join(cmd)}")
click.echo(f"Executing command: {shlex.join(cmd)}")

Comment on lines +242 to +244
raise RuntimeError(
f"Failed to execute command: {' '.join(cmd)} with error: {status.stderr.decode('utf-8')}"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Similarly here, using shlex.join(cmd) would be better for creating a reproducible command string in the error message. To avoid calling shlex.join twice, you could consider storing the result in a variable before the click.echo call on line 237.

Suggested change
raise RuntimeError(
f"Failed to execute command: {' '.join(cmd)} with error: {status.stderr.decode('utf-8')}"
)
raise RuntimeError(
f"Failed to execute command: {shlex.join(cmd)} with error: {status.stderr.decode('utf-8')}"
)

build_arg_sets=["invalid_build_arg_set"],
)
workspace = Workspace(dir=tmpdir)
with unittest.TestCase().assertRaises(KeyError) as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Since this is a pytest test file, it would be more idiomatic to use pytest.raises instead of unittest.TestCase().assertRaises.

Suggested change
with unittest.TestCase().assertRaises(KeyError) as e:
with pytest.raises(KeyError) as e:

workspace = Workspace(dir=tmpdir)
with unittest.TestCase().assertRaises(KeyError) as e:
workspace.load_config(config_path=Path(tmpdir) / "test.depsets.yaml")
print(str(e.exception))
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This print statement appears to be for debugging and should be removed before merging.

{f"pre_hooks: {depset.pre_hooks}" if depset.pre_hooks else ""}
{f"depsets: {depset.depsets}" if depset.depsets else ""}
{f"source_depset: {depset.source_depset}" if depset.source_depset else ""}
{f"config_name: {depset.config_name}" if depset.config_name else ""}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The config_name field is a required string argument in the Depset dataclass, so it should never be None or an empty string. This conditional check is redundant and can be removed for clarity.

Suggested change
{f"config_name: {depset.config_name}" if depset.config_name else ""}
config_name: {depset.config_name}

@aslonnie aslonnie added the go add ONLY when ready to merge, run all tests label Oct 23, 2025
@aslonnie aslonnie self-requested a review October 23, 2025 19:54
@ray-gardener ray-gardener bot added the devprod label Oct 24, 2025
@aslonnie aslonnie merged commit 6da558b into master Oct 24, 2025
6 checks passed
@aslonnie aslonnie deleted the elliot-barn/raydepsets-improve-error-handling branch October 24, 2025 16:51
xinyuangui2 pushed a commit to xinyuangui2/ray that referenced this pull request Oct 27, 2025
improving error messages for raydepsets

Updated unit tests to verify error messages

Signed-off-by: elliot-barn <[email protected]>
Signed-off-by: xgui <[email protected]>
landscapepainter pushed a commit to landscapepainter/ray that referenced this pull request Nov 17, 2025
improving error messages for raydepsets 

Updated unit tests to verify error messages

Signed-off-by: elliot-barn <[email protected]>
Aydin-ab pushed a commit to Aydin-ab/ray-aydin that referenced this pull request Nov 19, 2025
improving error messages for raydepsets

Updated unit tests to verify error messages

Signed-off-by: elliot-barn <[email protected]>
Signed-off-by: Aydin Abiar <[email protected]>
Future-Outlier pushed a commit to Future-Outlier/ray that referenced this pull request Dec 7, 2025
improving error messages for raydepsets

Updated unit tests to verify error messages

Signed-off-by: elliot-barn <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devprod go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants