Skip to content

perf(evaluator): lazy load values module - #1162

Merged
ngoncharenko merged 1 commit into
mainfrom
ngoncharenko/aalgo-311-lighten-values-module
Aug 11, 2026
Merged

perf(evaluator): lazy load values module#1162
ngoncharenko merged 1 commit into
mainfrom
ngoncharenko/aalgo-311-lighten-values-module

Conversation

@ngoncharenko

@ngoncharenko ngoncharenko commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Lazily resolves the evaluator SDK's public and value exports and defers optional imports so the agent_eval import path does not load the execution stack or unrelated heavy dependencies. Adds direct dependency declarations and stripped-install CI coverage for the source package and generated SDK mirror.

Related Issue

Closes AALGO-311.

Changes

  • Add PEP 562 lazy public APIs for the evaluator SDK root and values barrel, mirrored into the generated Python SDK.
  • Defer optional/heavy imports in agent inference, aggregation, and value result paths while improving Docker-runtime installation guidance.
  • Declare the SDK's direct httpx dependency and update the lockfile/package metadata.
  • Add lazy-public-API regression tests and a stripped dependency-closure smoke job.
  • Trigger the closure smoke for changes anywhere in the evaluator SDK source tree, including transitive import dependencies.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with documentation updates
  • Documentation only
  • Contributor tooling or automation
  • CI, build, or test infrastructure

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Documentation updated for user-visible behavior
  • Documentation not applicable — justification: Internal import behavior and CI coverage only; no user-facing API changes.

Verification

  • Pull request title follows the repository's Conventional Commit format
  • Every commit includes an appropriate Signed-off-by: trailer
  • uv run pre-commit run -a passes, or any blocked checks are identified below
  • Targeted tests pass, or tests are marked not applicable above
  • No secrets, API keys, or credentials are included

Targeted validation:

  • uv run --frozen pytest packages/nemo_evaluator_sdk/tests/test_lazy_public_api.py -q — 5 passed.
  • actionlint 1.7.12 — passed against all GitHub workflows and actions.
  • git diff --check origin/main...HEAD — passed.
  • uv run pre-commit run -a with uv 0.9.14 first on PATH — all hooks passed, including both lock checks and Studio lint.
  • bash tools/lint/lint-sdk-vendored.sh — passed; vendoring is idempotent.
  • bash tools/lint/lint-cli.sh — passed; CLI generation is idempotent.

Summary by CodeRabbit

  • Improvements

    • SDK modules now load dependencies lazily, improving startup behavior and allowing lightweight imports without optional packages.
    • Public APIs provide clearer discovery and consistent errors for unavailable or invalid attributes.
    • JSONPath, table conversion, metrics, and related functionality defer heavy dependencies until needed.
    • Docker runtime errors now include clearer installation guidance for supported SDK setups.
    • Added required HTTP client support for SDK operations.
  • Quality

    • Expanded validation of lazy imports, public APIs, dependency isolation, and runtime error messages.

@ngoncharenko
ngoncharenko requested review from a team as code owners August 7, 2026 07:32
@github-actions github-actions Bot added the perf conventional-commit type label Aug 7, 2026
Base automatically changed from ngoncharenko/aalgo-429-lighten-init to main August 7, 2026 19:21
@ngoncharenko ngoncharenko changed the title perf(evaluator): lighten the values barrel and declare the SDK dependency closure perf(evaluator): lazy load values module Aug 7, 2026
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 899f9075-42ba-40e2-a8e6-41819c6649de

📥 Commits

Reviewing files that changed from the base of the PR and between cecf833 and 3a18f0f.

⛔ Files ignored due to path filters (5)
  • sdk/python/nemo-platform/src/nemo_platform/beta/evaluator/__init__.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/beta/evaluator/agent_eval/runtimes/docker_sandbox.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/beta/evaluator/values/__init__.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/beta/evaluator/values/results.py is excluded by !sdk/**
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_eval/runtimes/docker_sandbox.py
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/values/results.py
  • packages/nemo_evaluator_sdk/tests/agent_eval/test_docker_sandbox_runtime.py
  • packages/nemo_platform/pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/nemo_platform/pyproject.toml
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/values/results.py
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_eval/runtimes/docker_sandbox.py

📝 Walkthrough

Walkthrough

The evaluator SDK now defers public API and optional dependency imports. It adds bounded httpx dependencies, expanded lazy API tests, and CI smoke coverage for package-only installation.

Changes

Evaluator SDK closure

Layer / File(s) Summary
Root lazy public API
packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/__init__.py
The root package resolves public names on demand, caches objects, reports them through __dir__, and supports version fallback.
Deferred nested and optional imports
packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/values/*, packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_inference.py, packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_eval/runtimes/docker_sandbox.py, packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/metrics/aggregation.py, packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/values/results.py, packages/nemo_evaluator_sdk/pyproject.toml, packages/nemo_platform/pyproject.toml
The SDK defers optional imports. Docker installation guidance distinguishes standalone and vendored installations. httpx is declared as a bounded dependency.
Lazy API validation
packages/nemo_evaluator_sdk/tests/test_lazy_public_api.py, packages/nemo_evaluator_sdk/tests/agent_eval/test_docker_sandbox_runtime.py
Tests verify import isolation, public API resolution, dir(), invalid attributes, submodule fallback, vendored package coverage, and Docker dependency guidance.
Dependency-closure CI enforcement
.github/actions/changes/action.yaml, .github/workflows/ci.yaml
Change filters expose evaluator SDK closure changes. CI runs a package-only smoke job and includes it in required status checks.

Sequence Diagram(s)

sequenceDiagram
  participant CI
  participant ChangesAction
  participant SmokeJob
  participant EvaluatorSDK
  participant LazyAPITest
  CI->>ChangesAction: evaluate evaluator SDK closure paths
  ChangesAction-->>CI: expose evaluator-sdk-closure
  CI->>SmokeJob: start package-only smoke job
  SmokeJob->>EvaluatorSDK: install without extras or workspace packages
  SmokeJob->>LazyAPITest: run lazy public API test
  LazyAPITest->>EvaluatorSDK: import and resolve public names
  EvaluatorSDK-->>LazyAPITest: return cached public objects
Loading

Suggested labels: refactor

Suggested reviewers: arpitsardhana, mckornfield, sandychapman

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main lazy-loading change in the evaluator package.
Docstring Coverage ✅ Passed Docstring coverage is 88.89% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ngoncharenko/aalgo-311-lighten-values-module

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/actions/changes/action.yaml:
- Around line 92-100: Update the evaluator-sdk-closure paths in the changes
filter to cover the entire nemo_evaluator_sdk source tree, including modules
such as agent_inference.py imported by agent_eval/evaluator.py. Retain the
existing dependency, workflow, and self-coverage entries while replacing the
narrower source-directory patterns with a source-tree-wide match.

In @.github/workflows/ci.yaml:
- Around line 991-995: Update the “Run lazy-import closure unit test under the
stripped install” step to bypass the repository pytest configuration by invoking
pytest with a null config and importlib import mode, while preserving the
existing targeted test path and verbose output.

In `@packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/__init__.py`:
- Around line 13-17: Update the module docstring in the package initializer to
reflect that values/__init__.py is now lazy and that the agent_eval import path
keeps pyarrow, numpy, jinja2, and jsonschema unloaded. Remove the outdated claim
that the values barrel eagerly re-exports names and that AALGO-311 is pending,
while preserving the guarantee for the execution and metric stack.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 38669c09-6ef5-4a9c-a2d3-b8dd29d20f4f

📥 Commits

Reviewing files that changed from the base of the PR and between 6d94b69 and db2fd71.

⛔ Files ignored due to path filters (7)
  • sdk/python/nemo-platform/pyproject.toml is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/beta/evaluator/__init__.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/beta/evaluator/agent_eval/runtimes/docker_sandbox.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/beta/evaluator/agent_inference.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/beta/evaluator/values/__init__.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/beta/evaluator/values/results.py is excluded by !sdk/**
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • .github/actions/changes/action.yaml
  • .github/workflows/ci.yaml
  • packages/nemo_evaluator_sdk/pyproject.toml
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/__init__.py
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_eval/runtimes/docker_sandbox.py
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_inference.py
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/values/__init__.py
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/values/results.py
  • packages/nemo_evaluator_sdk/tests/test_lazy_public_api.py
  • packages/nemo_platform/pyproject.toml

Comment thread .github/actions/changes/action.yaml
Comment thread .github/workflows/ci.yaml
Comment thread packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/__init__.py Outdated
@ngoncharenko
ngoncharenko force-pushed the ngoncharenko/aalgo-311-lighten-values-module branch from db2fd71 to 1ad8b22 Compare August 10, 2026 06:08
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/nemo_evaluator_sdk/tests/test_lazy_public_api.py`:
- Line 83: Update both subprocess probes in
packages/nemo_evaluator_sdk/tests/test_lazy_public_api.py at lines 83-83 and
137-142 to invoke Python through the frozen uv command, replacing sys.executable
with the uv Python command while preserving the existing probe arguments and
behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 105526e8-8492-4e06-a2c9-c4e5a1543e23

📥 Commits

Reviewing files that changed from the base of the PR and between 0c4dc81 and 1ad8b22.

⛔ Files ignored due to path filters (8)
  • sdk/python/nemo-platform/pyproject.toml is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/beta/evaluator/__init__.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/beta/evaluator/agent_eval/runtimes/docker_sandbox.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/beta/evaluator/agent_inference.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/beta/evaluator/metrics/aggregation.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/beta/evaluator/values/__init__.py is excluded by !sdk/**
  • sdk/python/nemo-platform/src/nemo_platform/beta/evaluator/values/results.py is excluded by !sdk/**
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • .github/actions/changes/action.yaml
  • .github/workflows/ci.yaml
  • packages/nemo_evaluator_sdk/pyproject.toml
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/__init__.py
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_eval/runtimes/docker_sandbox.py
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_inference.py
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/metrics/aggregation.py
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/values/__init__.py
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/values/results.py
  • packages/nemo_evaluator_sdk/tests/test_lazy_public_api.py
  • packages/nemo_platform/pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (9)
  • packages/nemo_platform/pyproject.toml
  • packages/nemo_evaluator_sdk/pyproject.toml
  • .github/actions/changes/action.yaml
  • .github/workflows/ci.yaml
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/values/results.py
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_eval/runtimes/docker_sandbox.py
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/init.py
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/agent_inference.py
  • packages/nemo_evaluator_sdk/src/nemo_evaluator_sdk/values/init.py

Comment thread packages/nemo_evaluator_sdk/tests/test_lazy_public_api.py
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 32000/40622 78.8% 63.5%
Integration Tests 18552/38548 48.1% 20.8%

@ngoncharenko
ngoncharenko force-pushed the ngoncharenko/aalgo-311-lighten-values-module branch from 1ad8b22 to cecf833 Compare August 10, 2026 06:33

@arpitsardhana arpitsardhana left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

may need to rebase and fix conflicts

@ngoncharenko
ngoncharenko force-pushed the ngoncharenko/aalgo-311-lighten-values-module branch from 7f3ffbf to 3a18f0f Compare August 10, 2026 22:35
Signed-off-by: Nick Goncharenko <ngoncharenko@nvidia.com>
@ngoncharenko
ngoncharenko force-pushed the ngoncharenko/aalgo-311-lighten-values-module branch from 6b4af6b to 98f1403 Compare August 11, 2026 06:19
@ngoncharenko
ngoncharenko added this pull request to the merge queue Aug 11, 2026
Merged via the queue into main with commit 68ac07d Aug 11, 2026
55 checks passed
@ngoncharenko
ngoncharenko deleted the ngoncharenko/aalgo-311-lighten-values-module branch August 11, 2026 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf conventional-commit type

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants