Repository navigation
Conversation
Jegp
reviewed
Nov 30, 2026
Jegp
left a comment
Collaborator
There was a problem hiding this comment.
Great find! One comment, otherwise I think we're good to go.
| @pytest.mark.parametrize("type_check", [True, False]) | ||
| @pytest.mark.parametrize( | ||
| "node", | ||
| [ |
Collaborator
There was a problem hiding this comment.
Is there a way to simply find all the possible NIR nodes programmatically, rather than hard code them?
Contributor
Author
There was a problem hiding this comment.
Thanks! Good point. The node types now come from the registry that nir.read uses (nir.ir.__all_ir, without NIRGraph), so the test covers every type dict2NIRNode can rebuild. The constructor arguments cannot be derived from the class alone (shapes have to be consistent), so there is still one example per type, but a new test fails as soon as a type in the registry has no example. Done in 0738d97.
List the node types of test_read_single_node from the registry used by dict2NIRNode instead of hard coding them, and fail when a registered type has no example instance.
This branch has not been deployed
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.
nir.writeaccepts anyNIRNode, but a file whose root is a single node cannot be read back:readpassestype_checkto whatever node it finds, and onlyNIRGraphtakes that argument. Onmain(3f4b259), withtype_check=TrueorFalse:This worked in v1.0.6 and fails since v1.0.7 (#167).
Fix: only add
type_checkwhen the root node is aNIRGraph. Reading graphs is unchanged.Tests:
test_read_single_nodewrites and reads each of the 18 non-graph node types, with both values oftype_check, and compares their fields. All 36 cases fail onmainwith the error above and pass with this change. Full suite: 115 passed, 5 skipped, plustest_serialize_deserialize_data, which also fails onmainon my Windows machine (PermissionErrorwhen h5py reopens aNamedTemporaryFile).I left the return annotation of
read(NIRGraph) and its docstring as they are. If files with a single node are not meant to be supported, I can change this to an explicit error inwriteinstead.