Skip to content

ci: fix unbound CONDA_PREFIX in test_doc_examples.sh#1462

Open
ramakrishnap-nv wants to merge 3 commits into
mainfrom
fix/conda-prefix-unbound
Open

ci: fix unbound CONDA_PREFIX in test_doc_examples.sh#1462
ramakrishnap-nv wants to merge 3 commits into
mainfrom
fix/conda-prefix-unbound

Conversation

@ramakrishnap-nv

@ramakrishnap-nv ramakrishnap-nv commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

@copy-pr-bot

copy-pr-bot Bot commented Jun 24, 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.

@ramakrishnap-nv ramakrishnap-nv self-assigned this Jun 24, 2026
@ramakrishnap-nv ramakrishnap-nv added bug Something isn't working non-breaking Introduces a non-breaking change labels Jun 24, 2026
@ramakrishnap-nv

Copy link
Copy Markdown
Collaborator Author

/ok to test 60ef2ce

@ramakrishnap-nv

Copy link
Copy Markdown
Collaborator Author

/ok to test fca6276

@ramakrishnap-nv ramakrishnap-nv force-pushed the fix/conda-prefix-unbound branch from fca6276 to 6a9a7d9 Compare June 25, 2026 19:06
@ramakrishnap-nv

Copy link
Copy Markdown
Collaborator Author

/ok to test 6a9a7d9

@ramakrishnap-nv

Copy link
Copy Markdown
Collaborator Author

/ok to test 51de84a

ramakrishnap-nv and others added 2 commits June 25, 2026 14:34
CONDA_PREFIX is unset in wheel test environments. Use \${CONDA_PREFIX:-}
so the variable defaults to empty rather than tripping set -o nounset.
The search loop already skips empty entries, so behavior is unchanged
in conda environments.

Fixes #1459.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
The MIP C examples directory had .c files but no Makefile, causing
test_doc_examples.sh to mark all 2 examples as failed. The convex
examples Makefile is generic (auto-discovers .c files) so copy it here.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
@ramakrishnap-nv ramakrishnap-nv force-pushed the fix/conda-prefix-unbound branch 2 times, most recently from fd1f3e4 to d0bf6f5 Compare June 25, 2026 21:19
@ramakrishnap-nv ramakrishnap-nv marked this pull request as ready for review June 25, 2026 21:19
@ramakrishnap-nv ramakrishnap-nv requested review from a team as code owners June 25, 2026 21:19
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR updates a shell script to handle an unset CONDA_PREFIX and adds a Makefile for cuOpt C MIP examples with source discovery, build, cleanup, validation, listing, and help targets.

Changes

CI doc example script fix

Layer / File(s) Summary
Header and CONDA_PREFIX fallback
ci/test_doc_examples.sh
The SPDX header year range is updated and search_dirs uses ${CONDA_PREFIX:-} in the library search path setup.

cuOpt C MIP example Makefile

Layer / File(s) Summary
Header and build discovery
docs/cuopt/source/cuopt-c/mip/examples/Makefile
The Makefile adds purpose and usage text, compiler and linker variable setup, *.c auto-discovery, derived targets, and phony target declarations.
Build targets
docs/cuopt/source/cuopt-c/mip/examples/Makefile
The default all target builds every discovered executable, and the %.c pattern rule compiles each source with the configured flags.
Cleanup and path checks
docs/cuopt/source/cuopt-c/mip/examples/Makefile
The clean target removes generated executables, and check-paths verifies INCLUDE_PATH and LIBCUOPT_LIBRARY_PATH before building.
Listing and help output
docs/cuopt/source/cuopt-c/mip/examples/Makefile
The list target prints discovered sources and build targets, and the help target prints usage instructions and configuration examples.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the main fix in ci/test_doc_examples.sh.
Linked Issues check ✅ Passed The PR fixes the unbound CONDA_PREFIX failure and adds missing doc-example build support.
Out of Scope Changes check ✅ Passed The added Makefile appears to support the doc-example workflow and is not unrelated to the fix.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed The description matches the changeset by fixing CONDA_PREFIX handling and adding the missing examples Makefile.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/conda-prefix-unbound

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.

Actionable comments posted: 2

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

Inline comments:
In `@docs/cuopt/source/cuopt-c/mip/examples/Makefile`:
- Line 49: `LDFLAGS` in the MIP example Makefile assumes `LIBCUOPT_LIBRARY_PATH`
is a directory, but the documented setup can populate it with the full
`libcuopt.so` file path. Update the Makefile to normalize that variable before
using it with `-L` and `-Wl,-rpath`, or change the contract so
`LIBCUOPT_LIBRARY_PATH` is explicitly directory-only; use the `LDFLAGS`
assignment as the fix point and keep it consistent with the `mip-examples.rst`
setup instructions.
- Around line 58-69: The single-example build path bypasses the path validation
step, so `make <example_name>` can fail later with missing include/library flags
instead of a clear prerequisite message. Update the `Makefile` so `check-paths`
is also required by individual target builds, either by making `$(TARGETS)`
depend on it or by adding it to the `%: %.c` pattern rule alongside the existing
`all` target behavior. Keep the fix aligned with the `all` target and
`check-paths` logic so both full and single-example builds validate paths
consistently.
🪄 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: Enterprise

Run ID: afe6ab17-6bd6-4534-8204-e0aa7f618620

📥 Commits

Reviewing files that changed from the base of the PR and between 229c0d8 and b3ad39a.

📒 Files selected for processing (2)
  • ci/test_doc_examples.sh
  • docs/cuopt/source/cuopt-c/mip/examples/Makefile


# Compiler flags
CFLAGS = -I$(INCLUDE_PATH) -Wall -Wextra
LDFLAGS = -L$(LIBCUOPT_LIBRARY_PATH) -lcuopt -Wl,-rpath,$(LIBCUOPT_LIBRARY_PATH)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Normalize LIBCUOPT_LIBRARY_PATH before passing it to -L.

Line 49 treats LIBCUOPT_LIBRARY_PATH as a directory, but the MIP example docs currently tell users to set it from find ... -name "libcuopt.so", which returns the full .so path. Following the documented setup will therefore produce an invalid -L.../libcuopt.so and break the build. Either convert file paths to $(dir ...) here or make the docs/variable contract explicitly directory-only. As per path instructions, docs changes should keep examples accurate and consistent with code. Based on docs/cuopt/source/cuopt-c/mip/mip-examples.rst:16-27, the current setup command assigns the library file path, not its parent directory.

🤖 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 `@docs/cuopt/source/cuopt-c/mip/examples/Makefile` at line 49, `LDFLAGS` in the
MIP example Makefile assumes `LIBCUOPT_LIBRARY_PATH` is a directory, but the
documented setup can populate it with the full `libcuopt.so` file path. Update
the Makefile to normalize that variable before using it with `-L` and
`-Wl,-rpath`, or change the contract so `LIBCUOPT_LIBRARY_PATH` is explicitly
directory-only; use the `LDFLAGS` assignment as the fix point and keep it
consistent with the `mip-examples.rst` setup instructions.

Source: Path instructions

Comment on lines +58 to +69
# Default target: build all examples
all: check-paths $(TARGETS)
@echo "==================================="
@echo "All examples built successfully!"
@echo "Built $(words $(TARGETS)) executables:"
@for target in $(TARGETS); do echo " - $$target"; done
@echo "==================================="

# Pattern rule: build any executable from corresponding .c file
%: %.c
@echo "Building $@ from $<..."
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Run check-paths for single-example builds too.

The file advertises make <example_name>, but only all depends on check-paths. make foo drops straight into gcc with empty -I/-L flags, so users get a compiler/linker failure instead of the intended prerequisite message. Please make $(TARGETS) (or the pattern rule) depend on check-paths as well. As per path instructions, docs changes should keep examples runnable and clear for users.

🤖 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 `@docs/cuopt/source/cuopt-c/mip/examples/Makefile` around lines 58 - 69, The
single-example build path bypasses the path validation step, so `make
<example_name>` can fail later with missing include/library flags instead of a
clear prerequisite message. Update the `Makefile` so `check-paths` is also
required by individual target builds, either by making `$(TARGETS)` depend on it
or by adding it to the `%: %.c` pattern rule alongside the existing `all` target
behavior. Keep the fix aligned with the `all` target and `check-paths` logic so
both full and single-example builds validate paths consistently.

Source: Path instructions

@jameslamb jameslamb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems you might have included something you didn't mean to, will re-review once you clarify.

@@ -0,0 +1,148 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What's the goal with this file?

It seems totally unrelated to the title / description / linked issue.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Apologies, so it started with doc testing failing silently and once I fixed it, there was another error where one of the test missed a Cmake file, so I fixed that, but missed to update the description.

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

Labels

bug Something isn't working non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: test_doc_examples.sh fails silently in wheel-tests-cuopt-server due to unbound CONDA_PREFIX

2 participants