-
Notifications
You must be signed in to change notification settings - Fork 7.1k
[ci] Add docstrings to raydepsets CLI functions #59909
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
Conversation
Add documentation to 20 functions in ci/raydepsets/cli.py that were missing docstrings, improving code readability and maintainability. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com>
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 adds docstrings to many functions in ci/raydepsets/cli.py, which is a great step towards improving code readability and maintainability. I've reviewed the new docstrings and they are generally well-written and accurate.
My feedback focuses on making the docstrings more complete by documenting the exceptions that can be raised by the functions. This is important for developers using these functions to handle potential errors correctly. I've provided suggestions to add Raises sections to several docstrings, following the Google Python Style Guide.
| return (self.get_path(output_path), (Path(self.temp_dir) / output_path)) | ||
|
|
||
| def _build(self, build_all_configs: Optional[bool] = False): | ||
| """Build the dependency graph from config depsets.""" |
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 docstring is a good start, but it's incomplete. This function can raise a ValueError if an invalid operation is found in a depset. It's important to document this behavior in the docstring for better maintainability and to help other developers understand the function's contract.
"""Build the dependency graph from config depsets.
Raises:
ValueError: If a depset has an invalid operation.
"""| self.build_graph = self.build_graph.subgraph(nodes).copy() | ||
|
|
||
| def execute(self, single_depset_name: Optional[str] = None): | ||
| """Execute all depsets in topological order, optionally limited to a single depset.""" |
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 docstring is helpful, but it's missing information about potential exceptions. This function calls _get_depset, which can raise a KeyError if single_depset_name is provided but not found. This should be documented.
"""Execute all depsets in topological order, optionally limited to a single depset.
Raises:
KeyError: If `single_depset_name` is provided but not found.
"""| def exec_uv_cmd( | ||
| self, cmd: str, args: List[str], stdin: Optional[bytes] = None | ||
| ) -> str: | ||
| """Execute a uv pip command with the given arguments.""" |
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.
| return status.stdout.decode("utf-8") | ||
|
|
||
| def execute_pre_hook(self, pre_hook: str): | ||
| """Execute a pre-hook shell command.""" |
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.
| ) | ||
|
|
||
| def read_lock_file(self, file_path: Path) -> List[str]: | ||
| """Read and return the contents of a lock file as a list of lines.""" |
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.
| return Path(self.workspace.dir) / path | ||
|
|
||
| def check_subset_exists(self, source_depset: Depset, requirements: List[str]): | ||
| """Verify that all requirements exist in the source depset.""" |
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.
|
|
||
|
|
||
| def _get_depset(depsets: List[Depset], name: str) -> Depset: | ||
| """Find and return a depset by name from a list of depsets.""" |
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.
This docstring is a good summary, but it would be more helpful if it followed the Google Python Style Guide format, including Args, Returns, and Raises sections. This function raises a KeyError if the depset is not found, which is important to document.
"""Find and return a depset by name from a list of depsets.
Args:
depsets: A list of depset objects to search through.
name: The name of the depset to find.
Returns:
The depset object with the matching name.
Raises:
KeyError: If no depset with the given name is found.
"""|
|
||
|
|
||
| def _uv_binary(): | ||
| """Get the path to the uv binary for the current platform.""" |
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 docstring is good, but it's incomplete. This function can raise a RuntimeError for unsupported platforms. It's important to document this behavior.
"""Get the path to the uv binary for the current platform.
Returns:
The path to the uv binary.
Raises:
RuntimeError: If the current platform/processor is not supported.
"""Add documentation to 20 functions in ci/raydepsets/cli.py that were missing docstrings, improving code readability and maintainability. 🤖 Generated with [Claude Code] Signed-off-by: elliot-barn <elliot.barnwell@anyscale.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: jasonwrwang <jasonwrwang@tencent.com>
Add documentation to 20 functions in ci/raydepsets/cli.py that were missing docstrings, improving code readability and maintainability.
🤖 Generated with [Claude Code]