Skip to content

Commit

Permalink
Cleanup more deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
andrjohns committed May 18, 2024
1 parent de8ff1e commit 1e886a0
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 312 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/R-CMD-check-wsl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
# Github Actions workflow to check CmdStanR
# yamllint disable rule:line-length

name: Unit tests - WSL Backend
name: v1.0 Branch Unit tests - WSL Backend

'on':
push:
branches:
- master
pull_request:
branches:
- master
- v1.0

jobs:
WSL-R-CMD-check:
Expand Down Expand Up @@ -61,7 +58,7 @@ jobs:
- name: Install cmdstan
run: |
cmdstanr::check_cmdstan_toolchain(fix = TRUE)
cmdstanr::install_cmdstan(cores = 2, wsl = TRUE, overwrite = TRUE)
cmdstanr::install_cmdstan(cores = 2, wsl = TRUE, overwrite = TRUE, version = "2.35.0-rc2")
shell: Rscript {0}

- name: Session info
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
# Github Actions workflow to check CmdStanR
# yamllint disable rule:line-length

name: Unit tests
name: v1.0 Branch Unit tests

'on':
push:
branches:
- master
pull_request:
branches:
- master
- v1.0

jobs:
R-CMD-check:
Expand Down Expand Up @@ -63,7 +60,7 @@ jobs:
- name: Install cmdstan
run: |
cmdstanr::check_cmdstan_toolchain(fix = TRUE)
cmdstanr::install_cmdstan(cores = 2)
cmdstanr::install_cmdstan(cores = 2, version = "2.35.0-rc2")
shell: Rscript {0}

- name: Session info
Expand Down
23 changes: 2 additions & 21 deletions R/args.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,8 @@ CmdStanArgs <- R6::R6Class(
self$output_dir <- ifelse(is.null(output_dir),
file.path(wsl_dir_prefix(), wsl_tempdir()),
wsl_safe_path(output_dir))
} else if (getRversion() < "3.5.0") {
self$output_dir <- output_dir %||% tempdir()
} else {
if (getRversion() < "3.5.0") {
self$output_dir <- output_dir %||% tempdir()
} else {
self$output_dir <- output_dir %||% tempdir(check = TRUE)
}
self$output_dir <- output_dir %||% tempdir(check = TRUE)
}
self$output_dir <- repair_path(self$output_dir)
self$output_basename <- output_basename
Expand Down Expand Up @@ -698,9 +692,6 @@ validate_cmdstan_args <- function(self) {
checkmate::assert_integerish(self$refresh, lower = 0, null.ok = TRUE)
checkmate::assert_integerish(self$sig_figs, lower = 1, upper = 18, null.ok = TRUE)
checkmate::assert_integerish(self$save_cmdstan_config, lower = 0, upper = 1, len = 1, null.ok = TRUE)
if (!is.null(self$sig_figs) && cmdstan_version() < "2.25") {
warning("The 'sig_figs' argument is only supported with cmdstan 2.25+ and will be ignored!", call. = FALSE)
}
if (!is.null(self$refresh)) {
self$refresh <- as.integer(self$refresh)
}
Expand All @@ -716,9 +707,6 @@ validate_cmdstan_args <- function(self) {
validate_init(self$init, num_inits)
validate_seed(self$seed, num_procs)
if (!is.null(self$opencl_ids)) {
if (cmdstan_version() < "2.26") {
stop("Runtime selection of OpenCL devices is only supported with CmdStan version 2.26 or newer.", call. = FALSE)
}
checkmate::assert_vector(self$opencl_ids, len = 2)
}
invisible(TRUE)
Expand Down Expand Up @@ -836,9 +824,6 @@ validate_optimize_args <- function(self) {
choices = c("bfgs", "lbfgs", "newton"))
checkmate::assert_flag(self$jacobian, null.ok = TRUE)
if (!is.null(self$jacobian)) {
if (cmdstan_version() < "2.32") {
warning("The 'jacobian' argument is only supported with cmdstan 2.32+ and will be ignored!", call. = FALSE)
}
self$jacobian <- as.integer(self$jacobian)
}

Expand Down Expand Up @@ -1476,11 +1461,7 @@ validate_seed <- function(seed, num_procs) {
if (is.null(seed)) {
return(invisible(TRUE))
}
if (cmdstan_version() < "2.26") {
lower_seed <- 1
} else {
lower_seed <- 0
}
lower_seed <- 1
checkmate::assert_integerish(seed, lower = lower_seed)
if (length(seed) > 1 && length(seed) != num_procs) {
stop("If 'seed' is specified it must be a single integer or one per chain.",
Expand Down
2 changes: 1 addition & 1 deletion R/cmdstanr-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
#'
"_PACKAGE"

if (getRversion() >= "2.15.1") utils::globalVariables(c("self", "private", "super"))
utils::globalVariables(c("self", "private", "super"))
8 changes: 0 additions & 8 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,6 @@ process_data <- function(data, model_variables = NULL) {
} else if (is.character(data)) {
path <- absolute_path(data)
} else if (is.list(data) && !is.data.frame(data)) {
if (cmdstan_version() < "2.22" && any_zero_dims(data)) {
stop(
"Data includes 0-dimensional data structures. To use this data please ",
"either update your CmdStan installation with install_cmdstan() ",
"or specify data as a file created by rstan::stan_rdump().",
call. = FALSE
)
}
if (!is.null(model_variables)) {
data_variables <- model_variables$data
is_data_supplied <- names(data_variables) %in% names(data)
Expand Down
13 changes: 0 additions & 13 deletions R/example.R
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,3 @@ write_stan_file <- function(code,
}
file
}


#' Write Stan code to a temporary file
#'
#' This function is deprecated. Please use [write_stan_file()] instead.
#' @keywords internal
#' @export
#' @inheritParams write_stan_file
write_stan_tempfile <- function(code, dir = tempdir()) {
warning("write_stan_tempfile() is deprecated. Please use write_stan_file() instead.",
call. = FALSE)
write_stan_file(code, dir)
}
28 changes: 5 additions & 23 deletions R/install.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ install_cmdstan <- function(dir = NULL,
warning("version and release_url shouldn't both be specified!",
"\nrelease_url will be ignored.", call. = FALSE)
}

release_url <- paste0("https://github.com/stan-dev/cmdstan/releases/download/v",
version, "/cmdstan-", version, cmdstan_arch_suffix(version), ".tar.gz")
}
Expand All @@ -151,6 +150,10 @@ install_cmdstan <- function(dir = NULL,
tar_name <- utils::tail(split_url[[1]], n = 1)
tar_name <- gsub("-linux-(.*).tar.gz", ".tar.gz", tar_name)
cmdstan_ver <- substr(tar_name, 0, nchar(tar_name) - 7)
if (cmdstan_ver < "2.35.0") {
warning("CmdStanR 1.0 and later only officially support CmdStan >= 2.35",
call. = FALSE)
}
tar_gz_file <- paste0(cmdstan_ver, ".tar.gz")
dir_cmdstan <- file.path(dir, cmdstan_ver)
dest_file <- file.path(dir, tar_gz_file)
Expand Down Expand Up @@ -224,15 +227,6 @@ install_cmdstan <- function(dir = NULL,
)
}

# Building fails on Apple silicon with < v2.31 due to a makefiles setting
# for stanc3, so manually implement the patch if needed from:
# https://github.com/stan-dev/cmdstan/pull/1127
stanc_makefile <- readLines(file.path(dir_cmdstan, "make", "stanc"))
stanc_makefile <- gsub("\\bxattr -d com.apple.quarantine bin/stanc",
"-xattr -d com.apple.quarantine bin/stanc",
stanc_makefile)
writeLines(stanc_makefile, con = file.path(dir_cmdstan, "make", "stanc"))

# Suppress noisy warnings from Boost
cmdstan_make_local(
dir = dir_cmdstan,
Expand Down Expand Up @@ -321,12 +315,8 @@ cmdstan_make_local <- function(dir = cmdstan_path(),

#' @rdname install_cmdstan
#' @export
#' @param fix For `check_cmdstan_toolchain()`, should CmdStanR attempt to fix
#' any detected toolchain problems? Currently this option is only available on
#' Windows. The default is `FALSE`, in which case problems are only reported
#' along with suggested fixes.
#'
check_cmdstan_toolchain <- function(fix = FALSE, quiet = FALSE) {
check_cmdstan_toolchain <- function(quiet = FALSE) {
if (os_is_windows()) {
if (os_is_wsl()) {
check_wsl_toolchain()
Expand Down Expand Up @@ -645,11 +635,6 @@ check_unix_cpp_compiler <- function() {

cmdstan_arch_suffix <- function(version = NULL) {
os_needs_arch <- os_is_linux() || os_is_wsl()
if ((!is.null(version) && version < "2.26") || !os_needs_arch) {
# pre-CmdStan 2.26, only the x86 tarball was provided
return(NULL)
}

arch <- NULL
if (os_is_wsl()) {
arch <- wsl_compatible_run(command = "uname", args = "-m")$stdout
Expand Down Expand Up @@ -719,9 +704,6 @@ rtools4x_home_path <- function() {

rtools_home_path <- function() {
path <- NULL
if (R.version$major == "3") {
path <- Sys.getenv("RTOOLS_HOME")
}
if (R.version$major == "4") {
path <- rtools4x_home_path()
}
Expand Down
Loading

0 comments on commit 1e886a0

Please sign in to comment.