Feature annotation#52
Open
harsh-sikhwal wants to merge 31 commits into
Open
Conversation
harsh-sikhwal
commented
May 12, 2026
harsh-sikhwal
commented
May 12, 2026
harsh-sikhwal
commented
May 12, 2026
harsh-sikhwal
commented
May 12, 2026
harsh-sikhwal
commented
May 12, 2026
harsh-sikhwal
commented
May 12, 2026
harsh-sikhwal
commented
May 21, 2026
harsh-sikhwal
commented
May 21, 2026
harsh-sikhwal
commented
May 21, 2026
…agraph into feature-annotation
harsh-sikhwal
commented
May 21, 2026
harsh-sikhwal
commented
May 21, 2026
harsh-sikhwal
commented
May 21, 2026
pradoshkeys
approved these changes
May 22, 2026
ajbalogh
approved these changes
May 22, 2026
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
Reworks the annotation and
get_graphAPIs to support richer, batched annotations and a structured graph response format.Annotation API
AnnotateRequestwith a newAnnotationschema. The old flat(name, attribute, value)triples are replaced withAnnotation.Node,Annotation.Edge, andAnnotation.Linkobjects, each carrying a list ofAnnotation.Attribute(attribute/value) pairs._expand_node_stringhelper, so a single annotation can target many graph elements:dgx[0:3]→dgx.0,dgx.1,dgx.2dgx[0:2]cpu[0:2]→ cartesian product over both slicesdgx.0→ all nodes under thedgx.0prefix_IMMUTABLE_ATTRIBUTESset (type,instance,instance_idx,device,composed_device,link) — annotating these now raisesValueError._build_prefix_mapand_build_link_mapto make node-prefix and link-name lookups O(1) per annotation.get_graphAPIGraphRequestnow selects between two return formats:infragraph— structured response containing the originalInfrastructureplus theAnnotationobject.networkx— the existing networkx node-link YAML string.Annotation.Configwithchoiceoffull(every attribute) orpartial(annotations only, excluding immutable infrastructure-derived attributes).set_graphnow resets annotations as part of building the graph.Tests
test_ipaddress_annotations,test_rank_annotations, andtest_shortest_pathto the newAnnotationschema.test_expand_node_string.pycovering the slice-expansion grammar (single name, single slice, multi-segment, mixed slice/no-slice, empty input).Test plan
pytest src/tests/test_expand_node_string.pypytest src/tests/test_ipaddress_annotations.py src/tests/test_rank_annotations.py src/tests/test_shortest_path.pyget_graphin bothinfragraphandnetworkxformats withfullandpartialannotation modestype) raisesValueError