-
Notifications
You must be signed in to change notification settings - Fork 7k
[ci][deps] raydepsts: Improved error messages #58058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ci][deps] raydepsts: Improved error messages #58058
Conversation
Signed-off-by: elliot-barn <[email protected]>
There was a problem hiding this 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)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| click.echo(f"Executing command: {' '.join(cmd)}") | |
| click.echo(f"Executing command: {shlex.join(cmd)}") |
| raise RuntimeError( | ||
| f"Failed to execute command: {' '.join(cmd)} with error: {status.stderr.decode('utf-8')}" | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| {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 ""} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| {f"config_name: {depset.config_name}" if depset.config_name else ""} | |
| config_name: {depset.config_name} |
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]>
improving error messages for raydepsets Updated unit tests to verify error messages Signed-off-by: elliot-barn <[email protected]>
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]>
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]>
improving error messages for raydepsets
Updated unit tests to verify error messages