feat(graph): add subset command to extract package-related subgraphs#915
feat(graph): add subset command to extract package-related subgraphs#915dhellmann wants to merge 2 commits intopython-wheel-build:mainfrom
Conversation
|
I ended up needing this to extract some details about a much larger build. |
56bc2c8 to
265a0c1
Compare
265a0c1 to
a77c67d
Compare
|
This is passing CI now and ready for review. |
rd4398
left a comment
There was a problem hiding this comment.
This looks good. I left one question but it is not a blocker for this MR
| find_why(graph, node, depth, 0, requirement_type) | ||
|
|
||
|
|
||
| @graph.command() |
There was a problem hiding this comment.
Can we please add documentation for this new command?
There was a problem hiding this comment.
The documentation for the CLI reference section is generated automatically, but I can add a how-to.
There was a problem hiding this comment.
I added some additional docs.
| for parent_edge in target_node.parents: | ||
| if parent_edge.destination_node.key == ROOT: | ||
| related_nodes.add(ROOT) | ||
| break |
There was a problem hiding this comment.
the code we have from line 555 to 560 is most likely dead code. Here is the analysis from a AI agent
The code is dead. By line 555, _collect_dependents (line 548) has already run. That function walks every ancestor of the target node all the way up to ROOT. ROOT is
always added to related_nodes because it's the ultimate ancestor of every node. We proved this empirically earlier:
_collect_dependents(pyyaml==6.0.2):
→ walks to imapautofiler==1.14.0
→ walks to ROOT ("")
→ ROOT.parents is empty, stops
So by the time execution reaches line 555, ROOT is already in related_nodes. The add() on line 559 is a no-op on a set that already contains the value.
There was a problem hiding this comment.
OK, I'll take a look through and see, thanks for catching that.
Add new `fromager graph subset` command to extract a subset of a build graph containing only nodes related to a specific package. Features: - Extracts dependencies and dependents of a target package - Optional version filtering with --version flag - Output to file or stdout - Comprehensive error handling for missing packages/versions - Full graph integrity preservation Usage: - fromager graph subset graph.json package-name - fromager graph subset graph.json package-name --version 1.0.0 - fromager graph subset graph.json package-name -o subset.json 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
a77c67d to
bac84f2
Compare
Add comprehensive documentation for the new `graph subset` command including: - Updated graph commands overview to include subset command - New dedicated tutorial with examples and use cases - Integration with existing documentation structure via toctree - CLI documentation auto-generates from command docstrings The tutorial covers basic usage, version filtering, file output, common use cases, and example workflows for debugging dependency issues. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
Add new
fromager graph subsetcommand to extract a subset of a build graph containing only nodes related to a specific package.Features:
Usage:
🤖 Generated with Claude Code