parthSundarka
Databricks Employee
Databricks Employee

Hi @AntonDBUser,

Please refer to these posts for R Shiny using Databricks Apps - https://docs.databricks.com/en/sparkr/shiny.html#id8, https://community.databricks.com/t5/machine-learning/host-r-shiny-app/m-p/22992

For R Models hosting, we recommend using Posit Connect.

While it is technically possible to serve R models without Posit Connect, it involves several complex adjustments.

Below are the steps and options available:

  1. Create a MLflow Run and Log the R Model and get a MLflow URI:

  • Use the 'crate' flavor to log the R model within an experiment

  • Include a list of required package versions or an renv lockfile.

 

  1. Add Additional Artifacts:

  • Create a `pyfunc` that wraps the R model

  •   Copy the model artifacts into a new model.

  •   Generate `conda.yml`.

  •   Adjust the `conda_env.yaml` to include `r-base` to add R to the container image.

  •   Detect the version of R.

  •   Use `rpy2` to set up the predict method and pass parameters to it.

  •  The `pyfunc` must use `rpy2` to load and invoke the R model.