Skip to content

Commit

Permalink
Merge pull request #20 from mlverse/updates
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
edgararuiz authored Aug 22, 2023
2 parents 69d6ae5 + 18873cf commit 1b908f3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 15 deletions.
3 changes: 1 addition & 2 deletions R/install.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
59 changes: 46 additions & 13 deletions R/spark-connect.R
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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
)
)
}

0 comments on commit 1b908f3

Please sign in to comment.