Skip to content

Add graph query API (node/edge/attribute filters and shortest-path search)#75

Open
harsh-sikhwal wants to merge 11 commits into
mainfrom
feature-query-graph
Open

Add graph query API (node/edge/attribute filters and shortest-path search)#75
harsh-sikhwal wants to merge 11 commits into
mainfrom
feature-query-graph

Conversation

@harsh-sikhwal

@harsh-sikhwal harsh-sikhwal commented Jul 14, 2026

Copy link
Copy Markdown
Member
  • Adds a new query.yaml schema and QueryRequest/QueryResponse message types (node filter, edge filter, attribute filter, shortest-path) to infragraph.proto.
  • Implements InfraGraphService.query_graph() with node/edge attribute matching (_match_attrs, _process_node_filter, _process_edge_filter) and shortest-path lookup via networkx.
  • Regenerates artifacts/infragraph.proto, artifacts/openapi.yaml, and docs/src/openapi.html from the updated schema.
  • Fixes description typos and copy-paste errors in schema/query.yaml.
  • Adds test_graph_query.py covering node/edge/attribute/shortest-path queries; updates existing blueprint and translator tests, and strips debug prints from test suites.

Schema:

https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/Keysight/infragraph/feature-query-graph/artifacts/openapi.yaml&nocors

Example usage

Node attribute filter query

from infragraph import QueryRequest

query = QueryRequest()
query.filter.node_filter.node_identifier = ["dgx_h100"]
query.filter.node_filter.attribute_filter.attributes.add(attribute="cx7_type", value="smart")

query_response = service.query_graph(query)
for node in query_response.nodes:
    print(node.name, {a.attribute: a.value for a in node.attributes})

Graph attribute filter query

query = QueryRequest()
query.filter.graph_filter.attributes.add(attribute="region", value="us-east")

query_response = service.query_graph(query)

Shortest path query

query = QueryRequest()
query.shortest_path.name = "rank0-rank1"
query.shortest_path.source = service.get_endpoints("rank", "0")[0]
query.shortest_path.destination = service.get_endpoints("rank", "1")[0]

query_response = service.query_graph(query)
path = [node.name for node in query_response.nodes]

@harsh-sikhwal harsh-sikhwal changed the title Draft: Feature query graph Add graph query API (node/edge/attribute filters and shortest-path search) Jul 16, 2026
@ajbalogh ajbalogh linked an issue Jul 16, 2026 that may be closed by this pull request
@ajbalogh

ajbalogh commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

If there are any schema changes lets add a link in the MR description that points to redocly which allows a user to easily review the openapi.yaml file. The format is the following and just the branch name needs to be replaced (in this case feature-query-graph):
https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/Keysight/infragraph/feature-query-graph/artifacts/openapi.yaml&nocors

Comment thread schema/query.yaml Outdated
Comment thread schema/query.yaml Outdated
name:
description: Name of this node filter.
type: string
node_filter:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did we decide on an array of filters at the node/edge/graph level?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes - array of node identifiers having an array of attributes inside - same for edges and for graph filter - just an array of attributes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update shortest path test to use API

3 participants