Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions notebooks/quickstart/quickstart_model_documentation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ vm_r <- vm(
Verify the connection and see the documentation structure:

```{r}
vm_r$preview_template()
py_print(vm_r$preview_template())
```

## Load the demo dataset
Expand Down Expand Up @@ -202,7 +202,7 @@ Preview the test configuration:

```{r}
vm_utils <- reticulate::import("validmind.utils")
vm_utils$preview_test_config(test_config)
py_print(vm_utils$preview_test_config(test_config))
```

Run the full documentation test suite and upload results to the ValidMind Platform:
Expand Down
2 changes: 1 addition & 1 deletion notebooks/quickstart/quickstart_model_validation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ vm_r <- vm(
Verify the connection and see the validation report structure:

```{r}
vm_r$preview_template()
py_print(vm_r$preview_template())
```

## Identify available tests
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "validmind"
version = "2.12.4"
version = "2.12.5"
description = "ValidMind Library"
readme = "README.pypi.md"
requires-python = ">=3.9,<3.15"
Expand Down
4 changes: 2 additions & 2 deletions r/validmind/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: validmind
Type: Package
Title: Interface to the 'ValidMind' Platform
Version: 2.12.4
Version: 2.12.5
Authors@R: c(person("Andres", "Rodriguez", role = c("aut", "cre","cph"),
email = "andres@validmind.ai"))
Maintainer: Andres Rodriguez <andres@validmind.ai>
Expand All @@ -14,7 +14,7 @@ Encoding: UTF-8
LazyData: true
URL: https://github.com/validmind/validmind-library
BugReports: https://github.com/validmind/validmind-library/issues
RoxygenNote: 7.3.2
RoxygenNote: 7.3.3
Imports:
glue,
reticulate,
Expand Down
2 changes: 2 additions & 0 deletions r/validmind/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

export(display_report)
export(process_result)
export(py_print)
export(register_custom_test)
export(run_custom_test)
export(save_model)
Expand All @@ -17,5 +18,6 @@ importFrom(htmltools,div)
importFrom(htmltools,tags)
importFrom(plotly,plotly_build)
importFrom(reticulate,import)
importFrom(reticulate,py_capture_output)
importFrom(reticulate,py_config)
importFrom(reticulate,use_python)
20 changes: 20 additions & 0 deletions r/validmind/R/platform.R
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,26 @@ display_report <- function(processed_results) {
return(all_widgets)
}

#' Run a Python expression and display its print() output in R
#'
#' Wraps a Python call with \code{reticulate::py_capture_output()} and
#' displays the result with \code{cat()}. Useful in R Jupyter notebooks
#' where Python print() output is not displayed automatically.
#'
#' Note: Python logging output (e.g. from \code{run_documentation_tests})
#' is not captured due to reticulate limitations.
#'
#' @param expr A Python expression to evaluate
#'
#' @importFrom reticulate py_capture_output
#'
#' @export
py_print <- function(expr) {
output <- py_capture_output(eval(substitute(expr), envir = parent.frame()))
if (nchar(output) > 0) cat(output, "\n")
invisible(output)
}

#' Save an R model to a temporary file
#'
#' This function saves a given R model object to a randomly named `.RData` file
Expand Down
55 changes: 54 additions & 1 deletion r/validmind/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Since the R package returns the full Python `validmind` module, you can call any

```r
# Preview the documentation template
vm_r$preview_template()
py_print(vm_r$preview_template())

# Initialize datasets
vm_dataset <- vm_r$init_dataset(dataset=df, input_id="my_dataset", target_column="target")
Expand All @@ -128,6 +128,23 @@ vm_r$tests$list_tests(tags=list("data_quality"), task="classification")
vm_r$tests$list_tasks_and_tags()
```

### Python output in R Jupyter notebooks

When running R notebooks in Jupyter (via IRkernel), Python `print()` output is not
displayed automatically due to a reticulate limitation. Use the `py_print()` helper
to capture and display output from Python functions:

```r
# These produce print() output — wrap with py_print()
py_print(vm_r$preview_template())
py_print(vm_utils$preview_test_config(test_config))
```

Note: Python logging output (e.g. progress from `run_documentation_tests()` or
`assign_predictions()`) cannot be captured this way. These functions run silently
in R Jupyter — check the ValidMind Platform for results. This is not an issue in
terminal R sessions where all Python output is displayed normally.

## Troubleshooting

### Initializating vm() on Mac
Expand Down Expand Up @@ -173,3 +190,39 @@ pip install -U numba
```

And restart the R session.

## Publishing to CRAN

### 1. Update version

The R package version is kept in sync with the Python package. Running `make version tag=patch` from the repo root updates both `pyproject.toml` and `r/validmind/DESCRIPTION`.

### 2. Regenerate documentation

```bash
cd r/validmind
Rscript -e 'roxygen2::roxygenise()'
```

This updates the `man/` Rd files and `NAMESPACE` from the roxygen comments in `R/platform.R`.

### 3. Build and check

```bash
cd r/validmind
R CMD build .
R CMD check --as-cran validmind_*.tar.gz
```

Fix all ERRORs and WARNINGs before submitting. NOTEs are generally acceptable.

### 4. Submit

Upload the `.tar.gz` at https://cran.r-project.org/submit.html

### 5. After submission

- CRAN sends a confirmation email — click the link to confirm
- CRAN runs automated checks on Windows and Linux — fix any issues they flag
- A CRAN volunteer manually reviews — this can take days to weeks
- They may email back with requests for changes before accepting
20 changes: 20 additions & 0 deletions r/validmind/man/py_print.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions r/validmind/man/vm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion validmind/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.12.4"
__version__ = "2.12.5"
Loading