Skip to content

feat: add --descendant and --ancestor flags to verdi node list#7300

Open
Khushi281300 wants to merge 1 commit intoaiidateam:mainfrom
Khushi281300:feat/node-list-relationships
Open

feat: add --descendant and --ancestor flags to verdi node list#7300
Khushi281300 wants to merge 1 commit intoaiidateam:mainfrom
Khushi281300:feat/node-list-relationships

Conversation

@Khushi281300
Copy link
Copy Markdown

PR Description

Overview

This PR introduces the --descendant and --ancestor flags to verdi node list, addressing issue #6782. These options allow users to explore the provenance graph directly from the CLI by filtering nodes based on their relationships.

What’s Included

  • New CLI Options
    Added DESCENDANT and ANCESTOR options in src/aiida/cmdline/params/options/main.py using NodeParamType.

  • Enhanced Query Logic
    Refactored the node_list command in src/aiida/cmdline/commands/cmd_node.py to use a custom QueryBuilder.
    This enables:

    • with_ancestors
    • with_descendants
      with explicit tagging (tag='node') to ensure correct filtering.
  • Backward Compatibility
    All existing features (sorting, projections, limits, and entry-point filters) remain unchanged.

Testing & Verification

1. Unit Tests
Added tests/cmdline/commands/test_node_list_relationship.py with test cases for:

  • Ancestor filtering
  • Descendant filtering
  • Combined usage

Result:
3 passed

Screenshot 2026-03-23 185102

2. Manual Verification
Tested on a local SQLite profile using a simple provenance chain:

Data (PK 3) → CalcJobNode (PK 4)
  • verdi node list --ancestor 3 → returns node 4
  • verdi node list --descendant 4 → returns node 3
Screenshot 2026-03-23 190248

3. Regression Check
Executed tests/cmdline/commands/test_node.py to ensure no regressions.

  • Observed some pre-existing failures on Windows (related to graphviz and prompt formatting), which are unrelated to this PR.

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.

1 participant