← Back to Pull requests

feat(tools): add list_cached_rdds tool for RDD storage info #252

Closed
unknown closed this pull request without merging on Nov 27, 2026 20:22 UTC
View on GitHub
unknown unknown commented on Nov 16, 2026 20:37 UTC
Author

🔄 Pull Request

📝 Description


Adds a list_cached_rdds tool. It returns the data behind the Spark UI's Storage tab, so an agent can check whether cache()/persist() worked. Each entry has the RDD or DataFrame name, its storage level, how many of its partitions are cached, and the bytes it uses in memory and on disk. Until now no tool exposed this data. Issue #27 lists it as list_rdds, and the CLI's storage command is still a stub.

  • Smaller output by default. For every RDD, GET /applications/{app}/storage/rdd returns one entry per cached partition and a breakdown per executor. Both lists grow with the partition count and make up most of the response. The tool drops them unless include_distribution or include_partitions is set.

  • Order and pagination. RDDs come largest first (memory plus disk). offset/length work as in list_executors.

  • Single RDD. rdd_id uses GET /storage/rdd/{rddId}. That endpoint also returns a persisted RDD that has no cached partitions. The listing leaves those out.

  • Client. SparkRestClient gains list_storage_rdds and get_storage_rdd. Both use _resilient_call, so a YARN app with no attempt given falls back to its latest attempt, as the other methods do.

  • History Server limitation. The History Server only learns about cached blocks if the application ran with spark.eventLog.logBlockUpdates.enabled=true (default false). Without it, the History Server reports no cached RDDs. A live Spark UI always tracks them. The tool docstring says this, and so does the README's Running Applications (Live Spark UI) section.
  • 🎯 Type of Change


    <!-- Mark with [x] -->
  • 🐛 Bug fix (non-breaking change that fixes an issue)

  • ✨ New feature (non-breaking change that adds functionality)

  • 💥 Breaking change (fix or feature that would cause existing functionality to change)

  • 📖 Documentation update

  • 🧪 Test improvement

  • 🔧 Refactoring (no functional changes)
  • 🧪 Testing


    <!-- Describe how you tested your changes -->
  • ✅ All existing tests pass (task test)

  • 🔬 Tested with MCP Inspector

  • 📊 Tested with sample Spark data

  • 🚀 Tested with real Spark History Server (if applicable)
  • 🔬 Test Commands Run


    uv run pytest
    uv run ruff check .
    uv run ruff format --check .
    uv run pytest tests/e2e.py   # HTTP connections, against the e2e corpus on apache/spark:4.1.0
    

  • Unit tests: 203 passed. New tests cover:

  • - the client's app paths, plus the retry with the latest attempt
    - ordering largest first, with ties broken by RDD ID
    - trimming the lists by default, and each include_* combination
    - pagination, and rejection of a negative offset/length
    - the rdd_id lookup
  • e2e: two new tests run on the shared corpus.

  • - app1 caches a DataFrame, but its event log has no block updates, so the tool returns [].
    - An unknown rdd_id returns the History Server's 404 as a tool error.
    - The whole HTTP e2e suite passes: 124 passed. The stdio tests were not run locally.
  • End to end with a Spark 4.1.0 History Server, on a real event log from spark-submit on apache/spark:4.1.0 with spark.eventLog.logBlockUpdates.enabled=true. The job did the following:

  • - persisted a DataFrame with MEMORY_AND_DISK (8 partitions)
    - cached a small DataFrame (2 partitions)
    - cached and then unpersisted a third DataFrame
    - persisted an RDD named named-rdd with DISK_ONLY (4 partitions)

    Results:
    - list_cached_rdds returned RDDs 7 (25.6 MB in memory), 49 (30.6 KB on disk) and 23 (6 KB), in that order. The unpersisted DataFrame was absent.
    - The default output was 1.1 KB. The raw endpoint returned 4.2 KB for these 14 cached partitions, and its size grows with the partition count.
    - include_distribution, rdd_id with include_partitions, offset, and server all returned what was expected.

    🛠️ New Tools Added (if applicable)


    <!-- For new MCP tools -->
  • Tool Name: list_cached_rdds

  • Purpose: List the cached RDDs and DataFrames of an application (Storage tab): storage level, cached vs. total partitions, memory and disk used, largest first. The per-executor and per-partition detail is opt-in.

  • Usage: {"app_id": "app-123"}, {"app_id": "app-123", "length": 5, "include_distribution": true}, {"app_id": "app-123", "rdd_id": 7, "include_partitions": true}
  • 📸 Screenshots (if applicable)


    N/A

    ✅ Checklist


  • 🔍 Code follows project style guidelines

  • 🧪 Added tests for new functionality

  • 📖 Updated documentation (README, TESTING.md, etc.)

  • 🔧 Pre-commit hooks pass (ruff lint/format)

  • 📝 Added entry to CHANGELOG.md (if significant change)
  • 📚 Related Issues


    Related to #27

    🤔 Additional Context


    The tool returns the generated RDDStorageInfo model, as get_environment returns Environment. The trimmed lists are set to None, so they are left out of the serialized result. The other endpoints listed in #27 are left out of this PR.

    Diff: 623 lines (+467 / -156) across 7 files Reviewer: nabuskey Review duration: 15825m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 623 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.385
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #252"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 50.3% (MEDIUM) · Higher = larger blast radius
    50.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.9% · Safe to merge
    19.9%