Skip to content

Work-around slow import issue for google-adk#1192

Merged
rapids-bot[bot] merged 3 commits intoNVIDIA:developfrom
dagardner-nv:david-work-around-slow-adk-import
Nov 19, 2025
Merged

Work-around slow import issue for google-adk#1192
rapids-bot[bot] merged 3 commits intoNVIDIA:developfrom
dagardner-nv:david-work-around-slow-adk-import

Conversation

@dagardner-nv
Copy link
Contributor

@dagardner-nv dagardner-nv commented Nov 19, 2025

Description

  • Reduce test runtime by 60s by importing google-adk early.

Explanation:
google-adk has a known slow import issue (google/adk-python#2433), where the library takes ~8 seconds to import. However since we run the tests in the packages dir last (after tests and examples), the ADK related tests run close to last. For some reason when ADK is imported late, it takes 60-70s.

By Submitting this PR I confirm:

  • I am familiar with the Contributing Guidelines.
  • We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license.
    • Any contribution which contains commits that are not Signed-Off will not be accepted.
  • When the PR is ready for review, new or existing tests cover these changes.
  • When the PR is ready for review, the documentation is up to date with these changes.

Summary by CodeRabbit

  • Tests
    • Added a session-scoped, automatically applied test fixture that attempts an early ADK import during test collection/run and silently ignores ImportError when ADK is not present, improving test initialization stability and reliability without affecting outcomes if ADK is absent.

Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
@dagardner-nv dagardner-nv self-assigned this Nov 19, 2025
@dagardner-nv dagardner-nv requested a review from a team as a code owner November 19, 2025 01:01
@dagardner-nv dagardner-nv added improvement Improvement to existing functionality non-breaking Non-breaking change labels Nov 19, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 19, 2025

Walkthrough

Adds an autouse, session-scoped pytest fixture import_adk_early that attempts to import google.adk during test session setup and silently suppresses ImportError so test collection/run proceeds whether ADK is present or not.

Changes

Cohort / File(s) Change Summary
Test Plugin Fixture Addition
packages/nvidia_nat_test/src/nat/test/plugin.py
Adds autouse session-scoped pytest fixture import_adk_early() which tries import google.adk and ignores ImportError (early ADK import workaround).

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Pytest as Pytest (session start)
    participant Fixture as import_adk_early fixture
    participant ADK as google.adk
    participant Tests as Tests (collection & run)

    rect rgb(240,248,255)
    Pytest->>Fixture: invoke at session start (autouse)
    end

    rect rgb(240,255,240)
    Fixture->>ADK: try import google.adk
    alt import succeeds
        ADK-->>Fixture: module loaded
    else ImportError
        ADK-->>Fixture: raises ImportError (caught & suppressed)
    end
    end

    Fixture-->>Pytest: fixture completes
    Pytest->>Tests: continue collection & run
Loading

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Single-file, small try/except fixture addition.
  • Files to inspect: packages/nvidia_nat_test/src/nat/test/plugin.py (verify fixture scope/autouse and import handling).

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a work-around for a slow google-adk import issue, matching the actual implementation of an early import fixture.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 321381e and fa36991.

📒 Files selected for processing (1)
  • packages/nvidia_nat_test/src/nat/test/plugin.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*

⚙️ CodeRabbit configuration file

**/*: # Code Review Instructions

  • Ensure the code follows best practices and coding standards. - For Python code, follow
    PEP 20 and
    PEP 8 for style guidelines.
  • Check for security vulnerabilities and potential issues. - Python methods should use type hints for all parameters and return values.
    Example:
    def my_function(param1: int, param2: str) -> bool:
        pass
  • For Python exception handling, ensure proper stack trace preservation:
    • When re-raising exceptions: use bare raise statements to maintain the original stack trace,
      and use logger.error() (not logger.exception()) to avoid duplicate stack trace output.
    • When catching and logging exceptions without re-raising: always use logger.exception()
      to capture the full stack trace information.

Documentation Review Instructions - Verify that documentation and comments are clear and comprehensive. - Verify that the documentation doesn't contain any TODOs, FIXMEs or placeholder text like "lorem ipsum". - Verify that the documentation doesn't contain any offensive or outdated terms. - Verify that documentation and comments are free of spelling mistakes, ensure the documentation doesn't contain any

words listed in the ci/vale/styles/config/vocabularies/nat/reject.txt file, words that might appear to be
spelling mistakes but are listed in the ci/vale/styles/config/vocabularies/nat/accept.txt file are OK.

Misc. - All code (except .mdc files that contain Cursor rules) should be licensed under the Apache License 2.0,

and should contain an Apache License 2.0 header comment at the top of each file.

  • Confirm that copyright years are up-to date whenever a file is changed.

Files:

  • packages/nvidia_nat_test/src/nat/test/plugin.py
packages/**/*

⚙️ CodeRabbit configuration file

packages/**/*: - This directory contains optional plugin packages for the toolkit, each should contain a pyproject.toml file. - The pyproject.toml file should declare a dependency on nvidia-nat or another package with a name starting
with nvidia-nat-. This dependency should be declared using ~=<version>, and the version should be a two
digit version (ex: ~=1.0).

  • Not all packages contain Python code, if they do they should also contain their own set of tests, in a
    tests/ directory at the same level as the pyproject.toml file.

Files:

  • packages/nvidia_nat_test/src/nat/test/plugin.py
🪛 Ruff (0.14.5)
packages/nvidia_nat_test/src/nat/test/plugin.py

833-833: Unused noqa directive (non-enabled: F401)

Remove unused noqa directive

(RUF100)


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cb6c9d8 and 321381e.

📒 Files selected for processing (1)
  • packages/nvidia_nat_test/src/nat/test/plugin.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*

⚙️ CodeRabbit configuration file

**/*: # Code Review Instructions

  • Ensure the code follows best practices and coding standards. - For Python code, follow
    PEP 20 and
    PEP 8 for style guidelines.
  • Check for security vulnerabilities and potential issues. - Python methods should use type hints for all parameters and return values.
    Example:
    def my_function(param1: int, param2: str) -> bool:
        pass
  • For Python exception handling, ensure proper stack trace preservation:
    • When re-raising exceptions: use bare raise statements to maintain the original stack trace,
      and use logger.error() (not logger.exception()) to avoid duplicate stack trace output.
    • When catching and logging exceptions without re-raising: always use logger.exception()
      to capture the full stack trace information.

Documentation Review Instructions - Verify that documentation and comments are clear and comprehensive. - Verify that the documentation doesn't contain any TODOs, FIXMEs or placeholder text like "lorem ipsum". - Verify that the documentation doesn't contain any offensive or outdated terms. - Verify that documentation and comments are free of spelling mistakes, ensure the documentation doesn't contain any

words listed in the ci/vale/styles/config/vocabularies/nat/reject.txt file, words that might appear to be
spelling mistakes but are listed in the ci/vale/styles/config/vocabularies/nat/accept.txt file are OK.

Misc. - All code (except .mdc files that contain Cursor rules) should be licensed under the Apache License 2.0,

and should contain an Apache License 2.0 header comment at the top of each file.

  • Confirm that copyright years are up-to date whenever a file is changed.

Referenced Documentation Contents

ci/vale/styles/config/vocabularies/nat/reject.txt:
Contains regex patterns (case-insensitive) for terms we want to reject (e.g., Agent-IQ, blacklist, TODO). Actio...

Files:

  • packages/nvidia_nat_test/src/nat/test/plugin.py
packages/**/*

⚙️ CodeRabbit configuration file

packages/**/*: - This directory contains optional plugin packages for the toolkit, each should contain a pyproject.toml file. - The pyproject.toml file should declare a dependency on nvidia-nat or another package with a name starting
with nvidia-nat-. This dependency should be declared using ~=<version>, and the version should be a two
digit version (ex: ~=1.0).

  • Not all packages contain Python code, if they do they should also contain their own set of tests, in a
    tests/ directory at the same level as the pyproject.toml file.

Files:

  • packages/nvidia_nat_test/src/nat/test/plugin.py
🧠 Learnings (2)
📚 Learning: 2025-11-14T20:33:53.944Z
Learnt from: AnuradhaKaruppiah
Repo: NVIDIA/NeMo-Agent-Toolkit PR: 1181
File: packages/nvidia_nat_test/tests/test_test_llm.py:419-484
Timestamp: 2025-11-14T20:33:53.944Z
Learning: The NVIDIA NeMo-Agent-Toolkit project uses pytest-asyncio in strict mode (the default), which requires pytest.mark.asyncio decorator on all async test functions. All async tests in packages/nvidia_nat_test/tests/test_test_llm.py consistently follow this pattern.

Applied to files:

  • packages/nvidia_nat_test/src/nat/test/plugin.py
📚 Learning: 2025-10-09T22:21:15.944Z
Learnt from: onkkul
Repo: NVIDIA/NeMo-Agent-Toolkit PR: 859
File: packages/nvidia_nat_autogen/src/nat/plugins/autogen/tool_wrapper.py:115-118
Timestamp: 2025-10-09T22:21:15.944Z
Learning: In `packages/nvidia_nat_autogen/src/nat/plugins/autogen/tool_wrapper.py`, when extracting parameters from input_schema at line 136, the code must handle both dataclasses (standard and Pydantic) and Pydantic BaseModels differently. Pydantic dataclasses have `__pydantic_fields__` (not `model_fields`), so use `dataclasses.fields()` for dataclasses and `model_fields` for BaseModels to properly extract function parameters.

Applied to files:

  • packages/nvidia_nat_test/src/nat/test/plugin.py

Signed-off-by: David Gardner <dagardner@nvidia.com>
@dagardner-nv
Copy link
Contributor Author

/merge

@rapids-bot rapids-bot bot merged commit 729eb56 into NVIDIA:develop Nov 19, 2025
16 of 17 checks passed
saglave pushed a commit to snps-scm13/SNPS-NeMo-Agent-Toolkit that referenced this pull request Dec 11, 2025
* Reduce test runtime by 60s by importing google-adk early.

Explanation:
`google-adk` has a known slow import issue (google/adk-python#2433), where the library takes ~8 seconds to import. However since we run the tests in the `packages` dir last (after `tests` and `examples`), the ADK related tests run close to last. For some reason when ADK is imported late, it takes 60-70s.

## By Submitting this PR I confirm:
- I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md).
- We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license.
  - Any contribution which contains commits that are not Signed-Off will not be accepted.
- When the PR is ready for review, new or existing tests cover these changes.
- When the PR is ready for review, the documentation is up to date with these changes.

## Summary by CodeRabbit

* **Tests**
  * Added a session-scoped, automatically applied test fixture that attempts an early ADK import during test collection/run and silently ignores ImportError when ADK is not present, improving test initialization stability and reliability without affecting outcomes if ADK is absent.

Authors:
  - David Gardner (https://github.com/dagardner-nv)

Approvers:
  - Will Killian (https://github.com/willkill07)

URL: NVIDIA#1192
Signed-off-by: Sangharsh Aglave <aglave@synopsys.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement to existing functionality non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants