Skip to content

fix: honor explicit Docker runtime before checking nvidia-ctk#199

Merged
wyli merged 1 commit into
mainfrom
fix/configurable-container-toolkit
Jul 7, 2026
Merged

fix: honor explicit Docker runtime before checking nvidia-ctk#199
wyli merged 1 commit into
mainfrom
fix/configurable-container-toolkit

Conversation

@wyli

@wyli wyli commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Honor an explicitly supplied Docker --runtime from --docker-opts before validating nvidia-ctk.

Launches without a runtime override retain the existing NVIDIA runtime and NVIDIA Container Toolkit check.

Context

The container launcher currently performs the nvidia-ctk preflight before Docker receives caller-provided options. This blocks an explicit alternative runtime such as --docker-opts='--runtime runc' before Docker can use it.

Scope

This is a narrow preflight fix for callers that explicitly select a non-NVIDIA Docker runtime. It does not add or claim official support for running Holoscan workloads without the NVIDIA Container Toolkit, GPU-free configurations, or alternative runtimes generally.

Existing NVIDIA runtime behavior and GPU-related Docker arguments are unchanged.

Validation

  • PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=src pytest -q -o addopts='' tests/unit/test_container_core.py
  • Ruff and Black checks

AI-assisted: Created with Codex/GPT at the user's request.

Summary by CodeRabbit

  • Bug Fixes
    • Improved container run behavior when a custom Docker runtime is specified.
    • Prevented the app from overriding an explicitly selected runtime.
    • Avoided unnecessary NVIDIA environment checks unless the NVIDIA runtime is actually used.
  • Tests
    • Updated container run tests to cover custom runtime usage and confirm NVIDIA checks are skipped in that case.

Co-authored-by: Codex <noreply@openai.com>
@copy-pr-bot

copy-pr-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@wyli
wyli marked this pull request as ready for review July 7, 2026 09:11
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

HoloscanContainer.run() now parses configured docker run arguments early to detect an explicit --runtime option and conditionally skips NVIDIA Container Toolkit checks when the resolved runtime isn't "nvidia". get_gpu_runtime_args() gains an optional runtime parameter controlling injected runtime flags. Tests updated accordingly.

Changes

Custom runtime handling

Layer / File(s) Summary
Runtime detection and conditional CTK check in run()
src/holoscan_cli/container/core.py
run() parses default and extra docker args to extract a configured --runtime, resolves a runtime value, conditionally calls check_nvidia_ctk() only when resolved to "nvidia", and passes runtime through to get_gpu_runtime_args to avoid double --runtime injection.
get_gpu_runtime_args parameterization
src/holoscan_cli/container/core.py
get_gpu_runtime_args(runtime="nvidia") now conditionally adds NVIDIA runtime args, a custom --runtime flag, or nothing based on the runtime value.
Tests for custom runtime bypassing CTK
tests/unit/test_container_core.py
New test verifies that supplying --runtime runc in docker_opts results in the assembled command using runc while check_nvidia_ctk is not invoked.

Estimated code review effort: 2 (Simple) | ~10 minutes

Related issues: None specified.

Related PRs: None specified.

Suggested labels: bug, tests

Suggested reviewers: None specified.

🐰 A runtime whispered, "runc, not nvidia today,"
So the CTK checks quietly stepped away.
Flags parsed early, no double injecting,
Tests now confirm the paths I'm selecting.
Hop, hop, ship it—clean code, no delay!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: honoring an explicit Docker runtime before running the nvidia-ctk check.
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.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/unit/test_container_core.py (1)

496-513: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep a default-runtime CTK assertion in this file.
tests/unit/test_container_core.py no longer has a test that runs c.run() without --runtime and asserts check_nvidia_ctk() is called, so this branch is now uncovered.

🤖 Prompt for 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.

In `@tests/unit/test_container_core.py` around lines 496 - 513, Add back a unit
test in test_run_assembles_docker_command_without_ctk_for_custom_runtime or
nearby that calls c.run() without specifying a custom --runtime and asserts
check_nvidia_ctk() is invoked; the current test only covers the custom-runtime
path. Use the existing container_core, run_command, and check_nvidia_ctk symbols
to locate the right branch and keep the default-runtime NVIDIA Container Toolkit
validation covered.
🧹 Nitpick comments (1)
tests/unit/test_container_core.py (1)

557-559: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Consider asserting no duplicate --runtime flag.

Add assert cmd.count("--runtime") == 1 alongside the existing --cidfile duplicate check, to directly guard against get_gpu_runtime_args re-injecting --runtime when a custom one is already present in docker_opts.

✅ Suggested addition
     assert container_core.get_cli_arg_value(cmd, "--runtime") == "runc"
+    assert cmd.count("--runtime") == 1
     assert not ctk_checks
🤖 Prompt for 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.

In `@tests/unit/test_container_core.py` around lines 557 - 559, The test around
get_gpu_runtime_args should also verify that a custom --runtime passed through
docker_opts is not duplicated in the final cmd. Update the existing assertions
in the container core test to add a direct count check for --runtime, alongside
the current cidfile duplicate guard, so the test explicitly catches any
re-injection of the runtime flag while still validating the resolved runtime
value from get_cli_arg_value.
🤖 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.

Outside diff comments:
In `@tests/unit/test_container_core.py`:
- Around line 496-513: Add back a unit test in
test_run_assembles_docker_command_without_ctk_for_custom_runtime or nearby that
calls c.run() without specifying a custom --runtime and asserts
check_nvidia_ctk() is invoked; the current test only covers the custom-runtime
path. Use the existing container_core, run_command, and check_nvidia_ctk symbols
to locate the right branch and keep the default-runtime NVIDIA Container Toolkit
validation covered.

---

Nitpick comments:
In `@tests/unit/test_container_core.py`:
- Around line 557-559: The test around get_gpu_runtime_args should also verify
that a custom --runtime passed through docker_opts is not duplicated in the
final cmd. Update the existing assertions in the container core test to add a
direct count check for --runtime, alongside the current cidfile duplicate guard,
so the test explicitly catches any re-injection of the runtime flag while still
validating the resolved runtime value from get_cli_arg_value.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e802d82f-8b52-4dbe-9fe2-6ab6cdaf25f8

📥 Commits

Reviewing files that changed from the base of the PR and between e1c0db7 and e312d16.

📒 Files selected for processing (2)
  • src/holoscan_cli/container/core.py
  • tests/unit/test_container_core.py

@wyli
wyli requested a review from tbirdso July 7, 2026 09:21
@wyli
wyli merged commit ae1e8be into main Jul 7, 2026
27 checks passed
@wyli
wyli deleted the fix/configurable-container-toolkit branch July 7, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants