-
Notifications
You must be signed in to change notification settings - Fork 6
fix: fix nat crash in nvbug 6336437 #417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gabwow
wants to merge
2
commits into
main
Choose a base branch
from
nvbug6336437-fix-nat-crash/agabow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+65
−1
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Guard against nvidia-nat package-family version drift. | ||
|
|
||
| The agentic-base image installs the NAT family unpinned (see | ||
| Dockerfile.agentic-base / tests/agentic-use/requirements-nat.txt). The CLI/meta | ||
| package historically lagged the plugin packages (e.g. ``nvidia-nat==1.4.3`` vs | ||
|
Comment on lines
+6
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Update stale docstring claim about pinning. Line 6 says NAT is installed “unpinned,” but Dockerfile.agentic-base now pins 🤖 Prompt for AI Agents |
||
| ``nvidia-nat-core``/``-eval``/``-langchain==1.7.0``), which silently produced | ||
| ``ImportError: cannot import name 'register_dataset_loader'`` at plugin | ||
| discovery and crashed ``nat start fastapi`` with exit code 1 — only surfacing in | ||
| slow, GPU-bound end-to-end runs. | ||
|
|
||
| This is the cheapest layer that can catch the mismatch: enumerate the installed | ||
| ``nvidia-nat*`` distributions and assert they all report the same version. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from importlib import metadata | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| def _nat_distributions() -> dict[str, str]: | ||
| """Return {normalized_name: version} for every installed nvidia-nat* dist.""" | ||
| found: dict[str, str] = {} | ||
| for dist in metadata.distributions(): | ||
| name = dist.metadata["Name"] | ||
| if not name: | ||
| continue | ||
| normalized = name.lower().replace("_", "-") | ||
| if normalized == "nvidia-nat" or normalized.startswith("nvidia-nat-"): | ||
| found[normalized] = dist.version | ||
| return found | ||
|
|
||
|
|
||
| def test_nvidia_nat_family_versions_are_aligned() -> None: | ||
| """All installed nvidia-nat* packages must share the same version. | ||
|
|
||
| Skips when NAT is not installed (NAT lives in an isolated venv and is only | ||
| present in the agentic-base image / the .venv-nat dev environment). | ||
| """ | ||
| dists = _nat_distributions() | ||
| if not dists: | ||
| pytest.skip("No nvidia-nat* packages installed; NAT runs in an isolated venv.") | ||
|
|
||
| versions = set(dists.values()) | ||
| if len(versions) > 1: | ||
| detail = "\n".join(f" {name}=={version}" for name, version in sorted(dists.items())) | ||
| pytest.fail( | ||
| "nvidia-nat package family version mismatch — all nvidia-nat* packages " | ||
| "must be pinned to the same version (a lagging meta/CLI package crashes " | ||
| "`nat start fastapi` at plugin discovery):\n" | ||
| f"{detail}\n" | ||
| "Pin every nvidia-nat* package to one version in Dockerfile.agentic-base " | ||
| "and tests/agentic-use/requirements-nat.txt." | ||
| ) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a way this can be enforced in one place, i.e., a text file or smth we copy in? this is good to fix though