Skip to content

add a scriptlet to put cuopt_grpc_server on the default path#1100

Open
tmckayus wants to merge 3 commits intoNVIDIA:mainfrom
tmckayus:grpcpath
Open

add a scriptlet to put cuopt_grpc_server on the default path#1100
tmckayus wants to merge 3 commits intoNVIDIA:mainfrom
tmckayus:grpcpath

Conversation

@tmckayus
Copy link
Copy Markdown
Contributor

This changes adds a scriptlet for cuopt_grpc_server so that after installation of the cuopt-server-cuXX packages the binary is on the default path, similar to cuopt_cli.

@tmckayus tmckayus requested a review from a team as a code owner April 14, 2026 16:39
@tmckayus tmckayus requested a review from jakirkham April 14, 2026 16:39
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 696db095-75cf-458f-a897-233b0926a213

📥 Commits

Reviewing files that changed from the base of the PR and between 714fa48 and 1d3fa00.

📒 Files selected for processing (2)
  • python/cuopt_server/cuopt_server/_grpc_server_wrapper.py
  • python/cuopt_server/cuopt_server/tests/test_grpc_server_entry_point.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • python/cuopt_server/cuopt_server/_grpc_server_wrapper.py
  • python/cuopt_server/cuopt_server/tests/test_grpc_server_entry_point.py

📝 Walkthrough

Walkthrough

Adds a console script entry cuopt_grpc_server, a Python wrapper main() that launches the packaged bin/cuopt_grpc_server binary forwarding args, and corresponding conda recipe test and unit tests validating the installed executable and its --help output.

Changes

Cohort / File(s) Summary
Console script configuration
python/cuopt_server/pyproject.toml
Added [project.scripts] entry registering cuopt_grpc_server = "cuopt_server._grpc_server_wrapper:main".
Python wrapper module
python/cuopt_server/cuopt_server/_grpc_server_wrapper.py
New module defining main() that imports libcuopt, builds the path to bin/cuopt_grpc_server in the library install location, invokes it with subprocess.call forwarding sys.argv[1:], and exits with the child return code.
Unit tests (Python)
python/cuopt_server/cuopt_server/tests/test_grpc_server_entry_point.py
New tests: one checks shutil.which("cuopt_grpc_server") is non-empty; another runs cuopt_grpc_server --help (10s timeout) and asserts return code 0 and stdout contains cuopt_grpc_server.
Conda recipe tests
conda/recipes/cuopt-server/recipe.yaml
Added tests entry using package_contents to assert bin/cuopt_grpc_server exists in the built package.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'add a scriptlet to put cuopt_grpc_server on the default path' accurately describes the main objective of the pull request—adding a mechanism to make the cuopt_grpc_server binary accessible on the default PATH after package installation.
Description check ✅ Passed The description directly relates to the changeset, explaining that the pull request adds a scriptlet for cuopt_grpc_server to place the binary on the default path following package installation, mirroring the existing behavior for cuopt_cli.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@rgsl888prabhu rgsl888prabhu added non-breaking Introduces a non-breaking change improvement Improves an existing functionality labels Apr 14, 2026
] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.

[project.scripts]
cuopt_grpc_server = "cuopt_server._grpc_server_wrapper:main"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@tmckayus Would we need a test for this ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added, and realize I left out the wrapper

@tmckayus tmckayus requested a review from a team as a code owner April 14, 2026 19:28
@tmckayus tmckayus requested a review from Iroy30 April 14, 2026 19:28
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

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 the current code and only fix it if needed.

Inline comments:
In `@python/cuopt_server/cuopt_server/tests/test_grpc_server_entry_point.py`:
- Around line 14-26: The test_cuopt_grpc_server_help currently calls
subprocess.run on the bare "cuopt_grpc_server" and only checks stdout, which can
raise FileNotFoundError and miss help output printed to stderr; update the test
to first locate the executable with shutil.which("cuopt_grpc_server") and call
pytest.skip if not found, or alternatively invoke the module via sys.executable
-m if an importable entrypoint exists, then call subprocess.run with
stderr=subprocess.STDOUT (or combine stdout/stderr) and a controlled env (e.g.,
env=os.environ.copy() with GPU vars like CUDA_VISIBLE_DEVICES cleared) so the
call is stream-agnostic and environment-isolated, and assert on the combined
output and returncode.
🪄 Autofix (Beta)

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: Pro Plus

Run ID: 9c80b148-7cb0-405c-b790-842b0fdb0941

📥 Commits

Reviewing files that changed from the base of the PR and between 2d48c97 and 714fa48.

📒 Files selected for processing (4)
  • conda/recipes/cuopt-server/recipe.yaml
  • python/cuopt_server/cuopt_server/_grpc_server_wrapper.py
  • python/cuopt_server/cuopt_server/tests/test_grpc_server_entry_point.py
  • python/cuopt_server/pyproject.toml
✅ Files skipped from review due to trivial changes (1)
  • python/cuopt_server/pyproject.toml

Comment on lines +14 to +26
def test_cuopt_grpc_server_help():
result = subprocess.run(
["cuopt_grpc_server", "--help"],
capture_output=True,
text=True,
timeout=10,
)
assert result.returncode == 0, (
f"cuopt_grpc_server --help failed (rc={result.returncode}): {result.stderr}"
)
assert "cuopt_grpc_server" in result.stdout, (
f"Expected 'cuopt_grpc_server' in --help output, got: {result.stdout}"
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Make test_cuopt_grpc_server_help self-contained and stream-agnostic.

On Line 16, invoking the bare command can raise FileNotFoundError when this test runs independently in a misconfigured environment, and Line 24 only inspects stdout even though many CLIs print help to stderr.

Proposed test hardening
 def test_cuopt_grpc_server_help():
+    exe = shutil.which("cuopt_grpc_server")
+    assert exe is not None, "cuopt_grpc_server should be on PATH before help test"
+
     result = subprocess.run(
-        ["cuopt_grpc_server", "--help"],
+        [exe, "--help"],
         capture_output=True,
         text=True,
         timeout=10,
     )
     assert result.returncode == 0, (
         f"cuopt_grpc_server --help failed (rc={result.returncode}): {result.stderr}"
     )
-    assert "cuopt_grpc_server" in result.stdout, (
-        f"Expected 'cuopt_grpc_server' in --help output, got: {result.stdout}"
+    output = f"{result.stdout}\n{result.stderr}"
+    assert "cuopt_grpc_server" in output, (
+        f"Expected 'cuopt_grpc_server' in --help output, got: {output}"
     )

As per coding guidelines, "Ensure test isolation: prevent GPU state, cached memory, and global variables from leaking between test cases; verify each test independently initializes its environment".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@python/cuopt_server/cuopt_server/tests/test_grpc_server_entry_point.py`
around lines 14 - 26, The test_cuopt_grpc_server_help currently calls
subprocess.run on the bare "cuopt_grpc_server" and only checks stdout, which can
raise FileNotFoundError and miss help output printed to stderr; update the test
to first locate the executable with shutil.which("cuopt_grpc_server") and call
pytest.skip if not found, or alternatively invoke the module via sys.executable
-m if an importable entrypoint exists, then call subprocess.run with
stderr=subprocess.STDOUT (or combine stdout/stderr) and a controlled env (e.g.,
env=os.environ.copy() with GPU vars like CUDA_VISIBLE_DEVICES cleared) so the
call is stream-agnostic and environment-isolated, and assert on the combined
output and returncode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants