← Back to Pull requests

Strip docstrings from large dependency wheels (~8 MB) #26094

Closed
unknown closed this pull request without merging on Nov 24, 2026 10:38 UTC
View on GitHub
unknown unknown commented on Nov 18, 2026 17:00 UTC
Author

<!-- dd-meta {"pullId":"1c4bffc7-d3a6-4d0a-bf59-060decaba34f","source":"chat","resourceId":"fdf897f8-0a91-46e7-ab63-5474025decc4","workflowId":"7a6f0c35-1723-4cf9-a60b-c478f6c213fb","codeChangeId":"7a6f0c35-1723-4cf9-a60b-c478f6c213fb","sourceType":"code_channel"} -->

What does this PR do?

<!-- Give a minimal but complete description of the change and how it works. -->

Adds strip_docstrings = true rules to .builders/scripts/lines_to_remove.toml, so clean_wheel() empties the docstrings of these dependencies when building the Agent's wheels (installed size saved):

  • kubernetes 35.0.0, kubernetes/client/models/.py only: 2.81 MB

  • cm-client 45.0.4: 2.06 MB

  • openstacksdk 4.18.0: 1.20 MB

  • ddtrace 4.16.3: 1.06 MB

  • redis 8.1.0: 0.63 MB

  • hazelcast-python-client 5.7.0: 0.45 MB
  • About 8.2 MB installed (1.6 MB compressed) per platform, measured with clean_wheel() on the pinned linux-x86_64 releases against the current rules.

    kubernetes keeps its API docstrings: kubernetes.watch.Watch reads them with pydoc.getdoc (:return: picks the event model, :param bool follow: picks follow over watch). Stripping kubernetes/client/api would save 6.8 MB more but break Watch.stream() for custom checks, though no integration here uses Watch.

    The new rules omit line_patterns, which _load_line_removal_rules() already defaults to an empty list, so no code change is needed. Patterns end in - (ddtrace-*) so they don't match ddtrace_internal.

    Tests check that kubernetes API docstrings survive while model docstrings are emptied, and that each rule matches its real wheel filename. The resolution workflow regenerates .deps/resolved.

    Motivation

    <!--
    Briefly explain why this change is needed and how it fits in: is it part of a bigger project, and
    how does it fit into it? Are there related or follow-up PRs? Link only the references a reviewer
    needs (e.g. Jira ticket, design doc, upstream docs or changelog, related PRs).-->

    Shrinks the Agent's embedded Python dependencies by extending the pymongo docstring rule from #25517 to the next largest pure-Python packages.

    How I checked that stripping is safe:

  • I searched each package for __doc__, inspect.getdoc, pydoc, and docstring-driven CLIs or parsers. The only hits were kubernetes Watch (described above), the ddtrace Google ADK integration reading __doc__ on user-defined tools, and hazelcast assigning one __doc__.

  • With the cleaned wheels installed, all 3,341 modules import with the same results as the originals, and smoke tests pass (kubernetes Watch and model decoding, cm-client deserialization, openstacksdk config loader, redis command packing, hazelcast serialization, ddtrace spans).
  • Checklist before requesting review

    <!--
    The pr-description validation (Run Validations) fails until every item below is ticked and
    the visible description (excluding HTML comments) is at most 3,000 characters. CI, the changelog,
    and the QA label have their own checks. Request review only once all checks pass:
    gh pr checks <PR> --repo DataDog/integrations-core --watch.-->

  • I self-reviewed the full diff, and this description matches the final change

  • <!--
    How to verify: run gh pr diff <PR> --repo DataDog/integrations-core, review every changed line,
    and compare the final diff with the description above.-->
  • Tests cover the change, or this description explains why none are needed

  • <!--
    How to verify: check the diff for relevant tests and run them as described in AGENTS.md.-->
  • Automated review comments, including Codex review, were addressed or answered

  • <!--
    How to verify: run gh api repos/DataDog/integrations-core/pulls/<PR>/comments and
    gh pr view <PR> --repo DataDog/integrations-core --json reviews,comments, then fix each
    finding or reply with the reason no change is needed.-->
  • I, the human author, understand this change, can explain it to reviewers, and believe it meets the repository standards

  • <!-- Coding agents: never tick this item. Only the human author may tick it. -->

    <!--
    QA label: PRs that only change code owned exclusively by @DataDog/agent-integrations (see
    .github/CODEOWNERS) always use qa/skip-qa, never qa/required.-->

    🤖 Generated with <span>Claude Code</span> (<span>https://claude.com/claude-code</span>)

    ---

    PR by Bits - View session in Datadog • Open in Slack

    Comment @datadog to request changes

    Diff: 587 lines (+440 / -147) across 7 files Reviewer: aiuto Review duration: 8257m
    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 · 587 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.382
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #26094"
    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: 49.9% (MEDIUM) · Higher = larger blast radius
    49.9%
    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.7% · Safe to merge
    19.7%