-
Notifications
You must be signed in to change notification settings - Fork 15
fix: rewrite version pins with dependency extras #154
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
Merged
rapids-bot
merged 1 commit into
NVIDIA:release/0.1
from
AnuradhaKaruppiah:ak-version-rewrite
Jul 29, 2026
Merged
Changes from all commits
Commits
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,70 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import re | ||
| import sys | ||
| import tomllib | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| PROJECT_VERSION_PATTERN = re.compile(r'^version\s*=\s*"[^"]+"$', flags=re.MULTILINE) | ||
| INTERNAL_PIN_PATTERN = re.compile( | ||
| r"(?P<prefix>nemo-fabric-[a-z0-9-]+(?:\[[^\]]+\])?\s*==\s*)" | ||
| r'(?P<version>[^"\s,;]+)' | ||
| ) | ||
|
|
||
|
|
||
| def set_python_project_versions(root: Path, version: str) -> None: | ||
| project_paths = ( | ||
| root / "pyproject.toml", | ||
| *sorted((root / "adapters").glob("**/pyproject.toml")), | ||
| ) | ||
|
|
||
| for path in project_paths: | ||
| text = path.read_text(encoding="utf-8") | ||
| updated, count = PROJECT_VERSION_PATTERN.subn( | ||
| f'version = "{version}"', | ||
| text, | ||
| count=1, | ||
| ) | ||
| if count != 1: | ||
| raise SystemExit(f"Failed to find exactly one project version in {path}") | ||
| updated = INTERNAL_PIN_PATTERN.sub( | ||
| lambda match: f"{match.group('prefix')}{version}", | ||
| updated, | ||
| ) | ||
| if updated != text: | ||
| path.write_text(updated, encoding="utf-8") | ||
| print( | ||
| f"{path.relative_to(root)} version and internal pins updated to {version}" | ||
| ) | ||
| else: | ||
| print(f"{path.relative_to(root)} already set to {version}") | ||
|
|
||
| runtime_path = root / "python" / "pyproject.toml" | ||
| runtime = tomllib.loads(runtime_path.read_text(encoding="utf-8")) | ||
| project = runtime.get("project", {}) | ||
| if "version" in project or "version" not in project.get("dynamic", []): | ||
| raise SystemExit( | ||
| "python/pyproject.toml must keep a dynamic version derived from Cargo.toml" | ||
| ) | ||
|
AnuradhaKaruppiah marked this conversation as resolved.
|
||
|
|
||
| mismatched_pins = [] | ||
| for path in project_paths: | ||
| for match in INTERNAL_PIN_PATTERN.finditer(path.read_text(encoding="utf-8")): | ||
| if match.group("version") != version: | ||
| mismatched_pins.append(f"{path.relative_to(root)}: {match.group(0)}") | ||
| if mismatched_pins: | ||
| raise SystemExit( | ||
| "Internal Python dependency pins are not synchronized: " | ||
| + ", ".join(mismatched_pins) | ||
| ) | ||
| print("python/pyproject.toml continues to derive its version from Cargo.toml") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| if len(sys.argv) != 2: | ||
| raise SystemExit("Usage: set_python_project_versions.py <version>") | ||
| set_python_project_versions(Path.cwd(), sys.argv[1]) | ||
|
AnuradhaKaruppiah marked this conversation as resolved.
|
||
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,87 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import sys | ||
| import tomllib | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| CI_SCRIPTS = Path(__file__).resolve().parents[2] / "scripts" / "ci" | ||
| sys.path.insert(0, str(CI_SCRIPTS)) | ||
|
|
||
| import set_python_project_versions # noqa: E402 | ||
|
|
||
|
|
||
| def test_set_python_project_versions_updates_internal_pins_with_extras( | ||
| tmp_path: Path, | ||
| ): | ||
| (tmp_path / "adapters" / "claude").mkdir(parents=True) | ||
| (tmp_path / "python").mkdir() | ||
| (tmp_path / "pyproject.toml").write_text( | ||
| """\ | ||
| [project] | ||
| name = "nemo-fabric" | ||
| version = "0.2.0" | ||
| dependencies = [ | ||
| "nemo-fabric-runtime == 0.2.0", | ||
| ] | ||
|
|
||
| [project.optional-dependencies] | ||
| claude = [ | ||
| "nemo-fabric-adapters-claude[harness] == 0.2.0", | ||
| ] | ||
| hermes-agent = [ | ||
| "nemo-fabric-adapters-hermes[harness] == 0.2.0; python_version < '3.14'", | ||
| ] | ||
| """, | ||
| encoding="utf-8", | ||
| ) | ||
| (tmp_path / "adapters" / "claude" / "pyproject.toml").write_text( | ||
| """\ | ||
| [project] | ||
| name = "nemo-fabric-adapters-claude" | ||
| version = "0.2.0" | ||
| dependencies = [ | ||
| "nemo-fabric-adapters-common == 0.2.0", | ||
| ] | ||
| """, | ||
| encoding="utf-8", | ||
| ) | ||
| runtime_path = tmp_path / "python" / "pyproject.toml" | ||
| runtime_path.write_text( | ||
| """\ | ||
| [project] | ||
| name = "nemo-fabric-runtime" | ||
| dynamic = ["version"] | ||
| """, | ||
| encoding="utf-8", | ||
| ) | ||
|
|
||
| set_python_project_versions.set_python_project_versions(tmp_path, "0.2.0rc5") | ||
|
|
||
| root_project = tomllib.loads( | ||
| (tmp_path / "pyproject.toml").read_text(encoding="utf-8") | ||
| )["project"] | ||
| adapter_project = tomllib.loads( | ||
| (tmp_path / "adapters" / "claude" / "pyproject.toml").read_text( | ||
| encoding="utf-8" | ||
| ) | ||
| )["project"] | ||
|
|
||
| assert root_project["version"] == "0.2.0rc5" | ||
| assert root_project["dependencies"] == ["nemo-fabric-runtime == 0.2.0rc5"] | ||
| assert root_project["optional-dependencies"]["claude"] == [ | ||
| "nemo-fabric-adapters-claude[harness] == 0.2.0rc5" | ||
| ] | ||
| assert root_project["optional-dependencies"]["hermes-agent"] == [ | ||
| "nemo-fabric-adapters-hermes[harness] == 0.2.0rc5; python_version < '3.14'" | ||
| ] | ||
| assert adapter_project["version"] == "0.2.0rc5" | ||
| assert adapter_project["dependencies"] == [ | ||
| "nemo-fabric-adapters-common == 0.2.0rc5" | ||
| ] | ||
| assert tomllib.loads(runtime_path.read_text(encoding="utf-8"))["project"][ | ||
| "dynamic" | ||
| ] == ["version"] | ||
|
AnuradhaKaruppiah marked this conversation as resolved.
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.