Conversation
- Add `document` parameter to R `vm()` function matching Python's `vm.init()` - Set R_HOME automatically so rpy2 can find the R installation - Fix deprecated rpy2 pandas2ri.activate() with localconverter context manager - Convert R FloatVector predict output to numpy arrays - Fix stale test_ds attribute reference in RModel - Register R models in input registry so run_documentation_tests can find them - Add plain-text fallbacks for preview_template() and preview_test_config() - Skip HTML progress/display rendering when not in a Jupyter notebook - Add quickstart_model_documentation.Rmd and quickstart_model_validation.Rmd - Sync R package version with Python (Makefile version target updates both) - Update R README with prerequisites, rpy2 install notes, and API examples Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Pull requests must include at least one of the required labels: |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Upgrade 2_run_comparison_tests.ipynb from nbformat 4.2 to 4.5 and add missing cell IDs so the copyright verification passes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
I was able to run the developer R notebook with a setup tweak to sort out a rpy2 issue with reticulate when doing init_r_model, but not consistently. This might need looking at by @cachafla @AnilSorathiya or @juanmleng.
For the validator R notebook, I was never able to run through the full notebook, again because of the same issue with init_r_model. I also ran into some issues with the ClassImbalance test, but those are possibly related to not having any model documentation uploaded first, as I had to switch to a different model on prod when setting the validation template 404'ed for me on dev.
I suggested a few usability tweaks that I can address tomorrow. , but the code snippet user experience is not great as you need to basically copy the snippet, paste it into an editor window, grab the right lines, paste those in and then fix the line indents and whitespace. It works, but it's not elegant.
Info on my env:
> packageVersion("validmind")
[1] ‘2.12.3’
> R.version.string
[1] "R version 4.5.3 (2026-03-11)"
… add python_version guidance - Put api_host before api_key in notebook vm() calls for easier copy-paste - Add RPY2_CFFI_MODE=ABI env var for rpy2/reticulate compatibility - Remove unsupported feature importance tests (PFI, SHAP) from validation notebook - Add lead-in text explaining how to find python_version path - Add plain-text fallback for format_dataframe outside notebooks - Add local source install option to R README - Revert init_r_model to save-to-file approach (direct model pass doesn't work) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
LGTM. 🚀
EDIT: I haven't been able to retest fully (was testing when we were asked to delete all our pyenvs locally ...), but if the version mismatch explains the issues I was running into, then let's ship this. The docs page for R will go out shortly.
Thanks! I'm adding a generic fix to not require manually specifying the location of the Python executable. This should make it easy to test, in combination with an updated JupyterHub deployment. |
- vm() now defaults python_version to VALIDMIND_PYTHON env var, falling
back to system Python. Resolves relative paths against working directory.
- Update all R notebooks to use Sys.getenv("VALIDMIND_PYTHON") pattern
instead of hardcoded placeholder paths
- Remove python_version from vm() calls in notebooks (now auto-configured)
- Reorder vm() args: api_host first for easier copy-paste from platform
- Remove exposed credentials from r_time_series_model_validation.Rmd
- Document VALIDMIND_PYTHON configuration in R README (env file, .Renviron)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…e error messages - Make .Renviron the recommended first option for VALIDMIND_PYTHON config - Add .Renviron to .gitignore - Add required=TRUE to use_python() calls so misconfig fails fast - Show actual import error in init_r_model instead of generic "install rpy2" - Load demo data via Python module instead of hardcoded CSV paths - Remove hardcoded "Exited" references, use customer_churn module constants Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
PR SummaryThis PR introduces several functional improvements and bug fixes across the project. Key changes include:
These changes enhance integration between R and Python workflows, improve user documentation and usability across different environments, and ensure that model testing and validation workflows function more reliably. Test Suggestions
|
Pull Request Description
What and why?
The ValidMind R package (
r/validmind/) hadn't been updated to match the current Python API. This PR brings R up to speed:R Package (
r/validmind/)documentparameter tovm()function to match Python'svm.init(document=...)R_HOMEautomatically sorpy2can find the R installationversiontarget now updates both)rpy2install notes, and API examplesPython-side fixes for R compatibility
validmind/models/r_model.py: Replace deprecatedpandas2ri.activate()withlocalconvertercontext manager (rpy2 3.6+), convert RFloatVectorpredict output to numpy arrays, fix staletest_dsattribute referencevalidmind/client.py: Register R models in the input registry (log_input+input_registry.addwere missing frominit_r_model), sorun_documentation_testscan find them byinput_idvalidmind/template.py: Add plain-text fallback forpreview_template()when not in a Jupyter notebookvalidmind/utils.py: Add plain-text fallback forpreview_test_config(); skip HTMLdisplay()when not in a notebookvalidmind/vm_models/html_progress.py: Skip HTML progress bar/label/box rendering when not in a notebook (eliminates<IPython.core.display.HTML object>noise in R)New quickstart notebooks
notebooks/code_sharing/r/quickstart_model_documentation.Rmd— End-to-end model documentation with GLMnotebooks/code_sharing/r/quickstart_model_validation.Rmd— End-to-end model validation with GLMHow to test
install.packages(c("reticulate", "dplyr", "caTools", "knitr", "glue", "plotly", "htmltools", "rmarkdown", "DT", "base64enc"))pip install rpy2(on macOS may need--no-binary :all:)install.packages("r/validmind", repos = NULL, type = "source")quickstart_model_documentation.Rmdchunk by chunkWhat needs special review?
r_model.pychanges topredict()— replacedpandas2ri.activate()with context manager and added numpy conversion of R predict outputinit_r_modelregistration fix inclient.py— this was a bug where R models weren't added to the input registryis_notebook()guards inhtml_progress.pyandutils.py— ensure they don't affect normal Jupyter notebook behaviorDependencies, breaking changes, and deployment notes
rpy2is now required in the Python environment when usinginit_r_model(was already the case, but previously failed with an unhelpful error)sed -i ''in the Makefile version target uses macOS syntax; may need adjustment for Linux CIRelease notes
Updated the ValidMind R package to support the current Python API, including the
documentparameter forvm.init(), proper model registration, and modernrpy2compatibility. Added two new R quickstart notebooks for model documentation and validation workflows. Fixed several issues with running ValidMind outside of Jupyter notebooks (plain-text fallbacks for template preview, test config preview, and progress display).Checklist
🤖 Generated with Claude Code