Skip to content

Commit

Permalink
Merge pull request #122 from mlverse/updates
Browse files Browse the repository at this point in the history
Fixes #121
  • Loading branch information
edgararuiz authored Jul 19, 2024
2 parents 39748e1 + 3e37446 commit b3b91ea
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: pysparklyr
Title: Provides a 'PySpark' Back-End for the 'sparklyr' Package
Version: 0.1.5
Version: 0.1.5.9000
Authors@R: c(
person("Edgar", "Ruiz", , "[email protected]", role = c("aut", "cre")),
person(given = "Posit Software, PBC", role = c("cph", "fnd"))
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# pysparklyr (dev)

* Adds IDE check for positron (#121)

# pysparklyr 0.1.5

### Improvements
Expand Down
31 changes: 19 additions & 12 deletions R/sparklyr-spark-connect.R
Original file line number Diff line number Diff line change
Expand Up @@ -240,33 +240,40 @@ build_user_agent <- function() {
}

if (is.null(product)) {
pr <- NULL
if (check_rstudio()) {
rstudio_version <- int_rstudio_version()
prod <- "rstudio"
edition <- rstudio_version$edition
mode <- rstudio_version$mode
version <- rstudio_version$long_version
pr <- "rstudio"
if (length(edition) == 0) edition <- ""
mod <- rstudio_version$mode
if (length(mod) == 0) mod <- ""

if (length(mode) == 0) mode <- ""
if (edition == "Professional") {
if (mod == "server") {
prod <- "workbench-rstudio"
if (mode == "server") {
pr <- "workbench-rstudio"
} else {
prod <- "rstudio-pro"
pr <- "rstudio-pro"
}
}
if (Sys.getenv("R_CONFIG_ACTIVE") == "rstudio_cloud") {
prod <- "cloud-rstudio"
pr <- "cloud-rstudio"
}
product <- glue("posit-{prod}/{rstudio_version$long_version}")
}
if(Sys.getenv("POSITRON", unset = "0") == "1") {
pr <- "positron"
version <- Sys.getenv("POSITRON_VERSION", unset = NA)
}
if(!is.null(pr)) {
product <- glue("posit-{pr}/{version}")
}
}

glue(
paste(
"sparklyr/{packageVersion('sparklyr')}",
product
"sparklyr/{packageVersion('sparklyr')} {product}",
.null = NULL
)
)
}

int_rstudio_version <- function() {
Expand Down
18 changes: 18 additions & 0 deletions tests/testthat/test-sparklyr-spark-connect.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,21 @@ test_that("User agent builder works with Connect env var", {
}
)
})

test_that("User agent builder for Positron", {
withr::with_envvar(
new = c(
"RSTUDIO_PRODUCT" = NA,
"POSITRON" = "1",
"POSITRON_VERSION" = "12345"
),
{
expect_equal(
build_user_agent(),
glue(
"sparklyr/{packageVersion('sparklyr')} posit-positron/12345"
)
)
}
)
})

0 comments on commit b3b91ea

Please sign in to comment.