ENH enable sandbox env overrides in generate#1107
Conversation
Signed-off-by: George Armstrong <georgea@nvidia.com>
Signed-off-by: George Armstrong <georgea@nvidia.com>
Signed-off-by: George Armstrong <georgea@nvidia.com>
Signed-off-by: George Armstrong <georgea@nvidia.com>
📝 WalkthroughWalkthroughThis pull request adds support for sandbox environment variable overrides in the pipeline generation feature and modifies the Dockerfile to skip Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
dockerfiles/Dockerfile.sandbox (1)
78-82: Verify the impact of skipping dependencies on arm64 architectures.The conditional installation guard excludes
uvand STEM dependencies (/app/stem_requirements.txt) on arm64 architectures. This is problematic because the stem_requirements.txt file contains 150+ critical packages including torch, numpy, scipy, pandas, tensorflow, and others. These packages are actively imported throughout the codebase (e.g., innemo_skills/training/nemo_rl/average_checkpoints.py,nemo_skills/inference/retrieve_similar.py,nemo_skills/inference/eval/scicode_utils.py, and other modules) and are not optional. While the dockerfiles/README.md documents how to build for arm64 architectures, it does not explain or justify the exclusion of these packages. Code execution requests that depend on numpy, torch, scipy, or other STEM libraries will fail at runtime on arm64 platforms without graceful error handling or a documented fallback mechanism.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
dockerfiles/Dockerfile.sandbox(1 hunks)nemo_skills/pipeline/generate.py(4 hunks)
🧰 Additional context used
🪛 Ruff (0.14.8)
nemo_skills/pipeline/generate.py
254-258: Do not perform function call typer.Option in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
(B008)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: pre-commit
- GitHub Check: unit-tests
🔇 Additional comments (3)
nemo_skills/pipeline/generate.py (3)
60-60: LGTM!The parameter addition properly supports environment override propagation through the function chain.
254-258: LGTM!The CLI parameter is correctly defined. The static analysis hint about
typer.Optionin function signatures is a false positive—this is the standard pattern for typer CLI applications.
472-472: LGTM!The sandbox environment overrides are correctly passed to the command group creation function.
| # Apply user-specified environment overrides for the sandbox | ||
| if sandbox_env_overrides: | ||
| sandbox_env = metadata.get("environment", {}) | ||
| for override in sandbox_env_overrides: | ||
| key, value = override.split("=", 1) | ||
| sandbox_env[key] = value | ||
| metadata["environment"] = sandbox_env |
There was a problem hiding this comment.
Add error handling for malformed environment overrides.
Line 130 will raise ValueError if an override string doesn't contain "=". This would crash the pipeline with an unclear error message.
Apply this diff to add validation:
# Apply user-specified environment overrides for the sandbox
if sandbox_env_overrides:
sandbox_env = metadata.get("environment", {})
for override in sandbox_env_overrides:
+ if "=" not in override:
+ raise ValueError(
+ f"Invalid sandbox environment override format: '{override}'. "
+ f"Expected KEY=VALUE format (e.g., NEMO_SKILLS_SANDBOX_BLOCK_NETWORK=1)"
+ )
key, value = override.split("=", 1)
sandbox_env[key] = value
metadata["environment"] = sandbox_env📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # Apply user-specified environment overrides for the sandbox | |
| if sandbox_env_overrides: | |
| sandbox_env = metadata.get("environment", {}) | |
| for override in sandbox_env_overrides: | |
| key, value = override.split("=", 1) | |
| sandbox_env[key] = value | |
| metadata["environment"] = sandbox_env | |
| # Apply user-specified environment overrides for the sandbox | |
| if sandbox_env_overrides: | |
| sandbox_env = metadata.get("environment", {}) | |
| for override in sandbox_env_overrides: | |
| if "=" not in override: | |
| raise ValueError( | |
| f"Invalid sandbox environment override format: '{override}'. " | |
| f"Expected KEY=VALUE format (e.g., NEMO_SKILLS_SANDBOX_BLOCK_NETWORK=1)" | |
| ) | |
| key, value = override.split("=", 1) | |
| sandbox_env[key] = value | |
| metadata["environment"] = sandbox_env |
🤖 Prompt for AI Agents
In nemo_skills/pipeline/generate.py around lines 126 to 132, the loop that
parses sandbox_env_overrides uses override.split("=", 1) which will raise a
ValueError for strings without "="; update the code to validate each override
before splitting (e.g., check if "=" in override), and handle malformed entries
by either raising a clear ValueError with the offending string or
skipping/logging them—implement input validation, provide a descriptive error
message mentioning the bad override and that expected format is KEY=VALUE, and
ensure metadata["environment"] is only updated for valid pairs.
Signed-off-by: George Armstrong <georgea@nvidia.com>
Signed-off-by: George Armstrong <georgea@nvidia.com> Signed-off-by: wasiahmad <wasiahmad@ucla.edu>
Signed-off-by: George Armstrong <georgea@nvidia.com> Signed-off-by: Cheng-Ping Hsieh <chsieh@nvidia.com>
Signed-off-by: George Armstrong <georgea@nvidia.com>
Signed-off-by: George Armstrong <georgea@nvidia.com>
Signed-off-by: George Armstrong <georgea@nvidia.com> Signed-off-by: dgitman <dgitman@nvidia.com>
Summary by CodeRabbit
Release Notes
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.