R notebooks: add py_print() helper and document Jupyter output limitations#492
Merged
R notebooks: add py_print() helper and document Jupyter output limitations#492
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Generate py_print.Rd (was missing) - Update vm.Rd to reflect document param and python_version default Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
PR SummaryThis PR introduces a new helper function,
These enhancements aim to improve usability for users running R in hybrid Python environments by providing a consistent mechanism for capturing and displaying Python Test Suggestions
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Description
What and why?
Follow-up to #490. When running R notebooks in Jupyter (via IRkernel), Python
print()output is not displayed automatically — this is a reticulate limitation where Python's stdout doesn't route to the R kernel's display system.This PR adds a
py_print()helper to the R package that captures Python print output and displays it via R'scat(). It works for functions that useprint()(likepreview_template(),preview_test_config()). Python logging output (fromrun_documentation_tests(),assign_predictions()) cannot be captured due to how reticulate manages stdout between calls — these run silently and users check the ValidMind Platform for results.Changes:
py_print()function tor/validmind/R/platform.Rusingreticulate::py_capture_output()with NSEpy_printinNAMESPACEpreview_template()andpreview_test_config()calls in notebooks withpy_print()How to test
install.packages("r/validmind", repos = NULL, type = "source")notebooks/quickstart/quickstart_model_documentation.Rmdin Jupyter with an R kernelpy_print(vm_r$preview_template())cell — should display the template treerun_documentation_tests()runs without error (output is silent in Jupyter, check the platform)What needs special review?
py_print()NSE implementation (substitute+evalinparent.frame())Dependencies, breaking changes, and deployment notes
Depends on #490 being merged (already merged). No breaking changes.
Release notes
Added
py_print()helper to the R package for displaying Python print output in R Jupyter notebooks, and documented known limitations with Python logging output in the Jupyter environment.Checklist
🤖 Generated with Claude Code