Closed
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for selecting and grouping nodes by attribute values using an attr: directive prefix in the select_node_groups_by_path method. This extends the existing regex-based node selection to allow grouping by arbitrary node attributes.
Key changes:
- Added attribute-based node grouping with
attr:<name>syntax - Updated docstrings to document the new directive
- Added comprehensive test coverage for both Network and NetworkView classes
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| ngraph/network.py | Added attribute-based grouping logic and updated docstring |
| ngraph/network_view.py | Updated docstring to document attribute directive |
| tests/test_network_selection.py | Added test for attribute-based grouping on Network |
| tests/test_network_view.py | Added test for attribute-based grouping on NetworkView |
Comment on lines
+246
to
+247
| value = node.attrs.get(attr_name) | ||
| if value is not None: |
There was a problem hiding this comment.
The condition value is not None excludes nodes with explicit None values, which may be valid attribute values. Consider using attr_name in node.attrs to check for attribute existence instead, or document this behavior clearly.
Suggested change
| value = node.attrs.get(attr_name) | |
| if value is not None: | |
| if attr_name in node.attrs: | |
| value = node.attrs[attr_name] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
attr:directiveTesting
make format(fails: pre-commit: No such file or directory)ruff format ngraph/network.py ngraph/network_view.py tests/test_network_selection.py tests/test_network_view.pyruff check ngraph/network.py ngraph/network_view.py tests/test_network_selection.py tests/test_network_view.py --fixmake docsmake check(fails: pre-commit is not installed)pytest(fails: No module named 'yaml')https://chatgpt.com/codex/tasks/task_e_6894b36acdf0832186d9aed47ad47219