Skip to content

Conversation

@cpcloud
Copy link
Contributor

@cpcloud cpcloud commented Feb 10, 2026

What

Replaces the custom info_summary_append pytest fixture with standard Python logging, writing test diagnostic info to a file uploaded as a GHA artifact instead of printing a terminal summary.

Why

  • The terminal INFO summary was verbose and noisy in CI output
  • Grep-based verification of the summary (grep '^INFO test_' in run-tests) was brittle
  • A file artifact is easier to inspect on-demand without cluttering logs

Changes

  • conftest.py -- info_summary_append fixture and pytest_terminal_summary hook replaced by two fixtures: a session-scoped _info_summary_handler (manages a logging.FileHandler) and a function-scoped info_log (yields a LoggerAdapter with the test node name). Log file is keyed off CUDA_PATHFINDER_TEST_LOAD_NVIDIA_DYNAMIC_LIB_STRICTNESS env var so both CI runs produce separate files.
  • 3 test files -- info_summary_append(...) calls become info_log.info(...).
  • ci/tools/run-tests -- Removed tee pipe and grep verification for pathfinder.
  • Both test-wheel workflows -- Added upload-artifact step (pinned v6.0.0) after the last pathfinder test run with if-no-files-found: error.

Made with Cursor

… logging

Replace the custom `info_summary_append` pytest fixture and terminal summary
with standard Python `logging`. Test diagnostic info now writes to a per-
strictness log file (`test-info-summary-{strictness}.log`) via a
`logging.FileHandler`, uploaded as a GHA run artifact.

- Drop `custom_info` list, `pytest_terminal_summary`, and the
  `info_summary_append` fixture from conftest
- Add session-scoped `_info_summary_handler` yield fixture (FileHandler
  lifecycle) and function-scoped `info_log` fixture (LoggerAdapter with
  test node name)
- Update test call sites to use `info_log.info(...)` instead of
  `info_summary_append(...)`
- Remove `tee` + `grep` verification from `ci/tools/run-tests`
- Add `upload-artifact` step to both test-wheel workflows with
  `if-no-files-found: error`

Co-authored-by: Cursor <cursoragent@cursor.com>
@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Feb 10, 2026

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

Contributors can view more details about this message here.

@cpcloud
Copy link
Contributor Author

cpcloud commented Feb 10, 2026

/ok to test

Co-authored-by: Cursor <cursoragent@cursor.com>
@cpcloud
Copy link
Contributor Author

cpcloud commented Feb 10, 2026

/ok to test

Co-authored-by: Cursor <cursoragent@cursor.com>
@cpcloud
Copy link
Contributor Author

cpcloud commented Feb 10, 2026

/ok to test

@github-actions
Copy link

Copy link
Collaborator

@rwgk rwgk left a comment

Choose a reason for hiding this comment

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

I'm OK with it, although I want to note that breaking currently certainly coherent output into pieces has pitfalls. Definitely, we need to clean up at the beginning. We should also add the new log file to .gitignore.

"FH:${CUDA_PATHFINDER_TEST_FIND_NVIDIA_HEADERS_STRICTNESS}"
pytest -ra -s -v --durations=0 tests/ |& tee /tmp/pathfinder_test_log.txt
# Fail if no "INFO test_" lines are found; capture line count otherwise
line_count=$(grep '^INFO test_' /tmp/pathfinder_test_log.txt | wc -l)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What I wanted to achieve here originally (in the early pathfinder days):

  • fail if somehow this didn't run (e.g. empty lists):

def test_load_nvidia_dynamic_lib(info_summary_append, libname):

  • make it easy to harvest the Number of "INFO test_ lines" run simply by grepping the CI logs.

With this PR that's lost, but pathfinder is more stable now, so that should be an OK loss.

The change delta of this PR is net positive (b/o the upload steps) and IIUC introduces a layer of indirection to get to the information?

I think I can get used to the INFO lines being written to cuda_pathfinder/test-info-summary-default.log, but could we just cat ./test-info-summary-default.log here? Then the information will be as easily accessible as before, and we don't even need the changes in the test-wheel-*.yml files. It'd be nice to add

echo "Number of \"INFO test_\" lines: $(wc -l test-info-summary-default.log)"

because then I could still do a simple grep over the CI logs as before, to quickly check if everything is as expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am actively trying to avoid spewing the log in CI. Every time I've had to look at CI logs for a pathfinder failure, I always spend 50% of that time scrolling through these logs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Happy to print the number of lines.


@pytest.fixture(scope="session")
def _info_summary_handler(request):
strictness = os.environ.get("CUDA_PATHFINDER_TEST_LOAD_NVIDIA_DYNAMIC_LIB_STRICTNESS", "default")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's better and simpler to hardwire the filename. The strictness level is only for controlling hard asserts. Also, maybe make it easy to know what the file is about even when it's pulled into another context, e.g. by adding in pathfinder:

log_path = request.config.rootpath / f"pathfinder-test-info-summary-log.txt"

Naming it .txt makes for the smoothest experience viewing, uploading, etc. Other extensions tend to confuse one tool or another.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there ever a case where the pathfinder tests are run twice CI? Once with see_what_works and once with the other setting?

@pytest.fixture(scope="session")
def _info_summary_handler(request):
strictness = os.environ.get("CUDA_PATHFINDER_TEST_LOAD_NVIDIA_DYNAMIC_LIB_STRICTNESS", "default")
log_path = request.config.rootpath / f"test-info-summary-{strictness}.log"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We want to be sure we're not accidentally using a file from a previous run (e.g. if there is a segfault but some follow-on logic still looks for that file). Cursor generated the code below. If we hard-wire the filename as suggested, we don't even need the glob.

diff --git a/cuda_pathfinder/tests/conftest.py b/cuda_pathfinder/tests/conftest.py
index 2a82cca0c..a10278f2d 100644
--- a/cuda_pathfinder/tests/conftest.py
+++ b/cuda_pathfinder/tests/conftest.py
@@ -7,9 +7,15 @@ import os

 import pytest

+_INFO_LOG_GLOB = "test-info-summary-*.log"
 _LOGGER_NAME = "cuda_pathfinder.test_info"


+def pytest_configure(config):
+    for log_path in config.rootpath.glob(_INFO_LOG_GLOB):
+        log_path.unlink(missing_ok=True)
+
+
 @pytest.fixture(scope="session")
 def _info_summary_handler(request):
     strictness = os.environ.get("CUDA_PATHFINDER_TEST_LOAD_NVIDIA_DYNAMIC_LIB_STRICTNESS", "default")

handler.setFormatter(logging.Formatter("%(test_node)s: %(message)s"))

def pytest_terminal_summary(terminalreporter, exitstatus, config): # noqa: ARG001
if not config.getoption("verbose"):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, what about deleting only the verbose condition, but keeping the other two? Otherwise the file will be overwritten 99 times or so?

However, we should unconditionally remove the file when the _info_summary_handler fixture runs. (I've been really confused a few times in the past by stale output, correlating it wrongly to a more recent action.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's getting overwritten 99 times?

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