feat(sdk): add graph traversal support for Infrahub 1.10+#1090
Open
minitriga wants to merge 5 commits into
Open
feat(sdk): add graph traversal support for Infrahub 1.10+#1090minitriga wants to merge 5 commits into
minitriga wants to merge 5 commits into
Conversation
Add traverse_paths(), path_exists(), and reachable_nodes() client methods (with sync equivalents) for discovering how nodes are connected without knowing the relationship path in advance. - traverse_paths: shortest path(s) between a source and destination node - path_exists: boolean convenience wrapper for checks - reachable_nodes: nodes of given kinds reachable from a source Source/destination accept node ids or InfrahubNode instances; kind filters accept kind strings or protocol classes; each result PathNode exposes .fetch() to resolve the full node (store-backed). Calling against a pre-1.10 server raises a clear VersionNotSupportedError. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Deploying infrahub-sdk-python with
|
| Latest commit: |
1fbfe9b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1bc57d87.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://infp-531-graph-traversal.infrahub-sdk-python.pages.dev |
There was a problem hiding this comment.
3 issues found across 38 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The async/sync signature parity test matches annotation strings against a known-equivalence map. Add the new traversal parameter annotations (str | InfrahubNode, list[str | type[SchemaType]] and its optional variant) so traverse_paths/path_exists/reachable_nodes pass the parity check. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is @@ Coverage Diff @@
## develop #1090 +/- ##
===========================================
- Coverage 82.32% 82.07% -0.25%
===========================================
Files 135 138 +3
Lines 11992 11870 -122
Branches 1793 1783 -10
===========================================
- Hits 9872 9742 -130
- Misses 1571 1581 +10
+ Partials 549 547 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
ajtmccarty
approved these changes
Jun 18, 2026
ajtmccarty
left a comment
Contributor
There was a problem hiding this comment.
looks good. few small comments
- Raise generic NodeNotSavedError in _resolve_node_id; wrap with traversal-specific context at the caller - Guard _get_schema_name against missing save attribute - Use isinstance(InfrahubNodeBase) instead of broad hasattr for node detection - Add full Args sections to traversal docstrings so generated reference documents keyword-only arguments - Clarify excluded-kinds and count/truncation guidance in the guide Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Avoid plural 'UUIDs' which is not in the Infrahub vocab. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ajtmccarty
reviewed
Jun 19, 2026
ajtmccarty
approved these changes
Jun 19, 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.
Overview
Adds graph-traversal support to the SDK (requires Infrahub 1.10+), letting users discover how nodes are connected without knowing the relationship path in advance. Purely additive — no existing signatures change.
What's new
Three client methods, each with a sync equivalent:
traverse_paths(source, destination, ...)— find the shortest path(s) between two nodes.path_exists(source, destination, ...)— boolean convenience wrapper for checks (requests a single path).reachable_nodes(source, target_kinds, ...)— find every node of given kinds reachable from a source, with the path to each.Ergonomics:
source/destinationaccept a node UUID string or anInfrahubNodeinstance.PathNodeis a lightweight identity exposing.fetch()to resolve the full node (store-backed).VersionNotSupportedErrorinstead of an opaque GraphQL failure.Implementation notes
infrahub_sdk/graph_traversal/package: typed pydantic result models (models.py) and GraphQL query strings + input builders (query.py). Pure logic is isolated so it's unit-tested without HTTP.VersionNotSupportedErrorexception.tasks.py), a how-to guide, generated SDK reference, and a changelog fragment.Testing
pytest tests/unit/sdk/test_graph_traversal.py— 23 passed (pure-logic builders/parsing + client methods mocked at the transport boundary, async + sync).ruff checkclean;lint-docs0 errors.🤖 Generated with Claude Code
Summary by cubic
Adds graph traversal to the Python SDK for Infrahub 1.10+, enabling shortest-path and dependency discovery across any relationships. Supports INFP-531 (Phase 1) by exposing traversal APIs the UI and GraphQL layer can use.
New Features
InfrahubClient.traverse_paths(),reachable_nodes(), andpath_exists()(with sync equivalents) to find shortest paths, discover reachable nodes by kind, and check connectivity.InfrahubNode; kind filters accept strings or protocol classes; results includePathNode.fetch()to resolve full nodes from the client store.VersionNotSupportedErrorwith a clear message.Bug Fixes
NodeNotSavedError, wrapped with role-specific context).saveis missing in_get_schema_name.isinstance(InfrahubNodeBase)to avoid false positives.operationNamein requests for better tracing.Written for commit 1fbfe9b. Summary will update on new commits.