diff --git a/R/install.R b/R/install.R index 53f4d3b..37f552d 100644 --- a/R/install.R +++ b/R/install.R @@ -27,8 +27,7 @@ install_pyspark <- function(envname = "r-sparklyr", "delta-spark" ) - pip_options <- "--index-url https://packagemanager.posit.co/pypi/latest/simple" - # pip_options <- "--index-url https://packagemanager.posit.co/pypi/2023-06-15/simple" + pip_options <- "--index-url https://packagemanager.posit.co/pypi/2023-06-15/simple" # in cause user supplied pip_options in ... pip_options <- c(pip_options, list(...)$pip_options) diff --git a/R/spark-connect.R b/R/spark-connect.R index 1a3dac4..b6add1e 100644 --- a/R/spark-connect.R +++ b/R/spark-connect.R @@ -79,20 +79,8 @@ py_spark_connect <- function(master, cluster_id = cluster_id ) - check_rstudio <- try(RStudio.Version(), silent = TRUE) - - if (inherits(check_rstudio, "try-error")) { - rstudio_chr <- NULL - } else { - rstudio_chr <- glue("rstudio/{check_rstudio$long_version}") - } + user_agent <- build_user_agent() - user_agent <- glue( - paste( - "sparklyr/{packageVersion('sparklyr')}", - rstudio_chr - ) - ) conn <- remote$userAgent(user_agent) con_class <- "connect_databricks" master_label <- glue("Databricks Connect - Cluster: {cluster_id}") @@ -211,3 +199,48 @@ python_sdf <- function(x) { } out } + + +build_user_agent <- function() { + product <- NULL + in_rstudio <- FALSE + in_connect <- FALSE + + if (Sys.getenv("RSTUDIO_PRODUCT") == "CONNECT") { + product <- "posit-connect" + } + + if (is.null(product)) { + check_rstudio <- try(RStudio.Version(), silent = TRUE) + if (!inherits(check_rstudio, "try-error")) { + prod <- "rstudio" + + edition <- check_rstudio$edition + if (length(edition) == 0) edition <- "" + + mod <- check_rstudio$mode + if (length(mod) == 0) mod <- "" + + if (edition == "Professional") { + if (mod == "server") { + prod <- "workbench-rstudio" + } else { + prod <- "rstudio-pro" + } + } + + if (Sys.getenv("R_CONFIG_ACTIVE") == "rstudio_cloud") { + prod <- "cloud-rstudio" + } + + product <- glue("posit-{prod}/{check_rstudio$long_version}") + } + } + + glue( + paste( + "sparklyr/{packageVersion('sparklyr')}", + product + ) + ) +}