Skip to content

Commit

Permalink
Merge pull request #798 from stan-dev/store-return-codes
Browse files Browse the repository at this point in the history
Store return codes instead of always querying exit status
  • Loading branch information
jgabry authored Jul 27, 2023
2 parents 5b3426f + b5a33bf commit 8505e5b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions R/fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ CmdStanFit <- R6::R6Class(
checkmate::assert_r6(runset, classes = "CmdStanRun")
self$runset <- runset

private$return_codes_ <- self$runset$procs$return_codes()

private$model_methods_env_ <- new.env()
if (!is.null(runset$model_methods_env())) {
for (n in ls(runset$model_methods_env(), all.names = TRUE)) {
Expand All @@ -33,8 +35,7 @@ CmdStanFit <- R6::R6Class(
}
# Need to update the output directory path to one that can be accessed
# from Windows, for the post-processing of results
self$runset$args$output_dir <- wsl_safe_path(self$runset$args$output_dir,
revert = TRUE)
self$runset$args$output_dir <- wsl_safe_path(self$runset$args$output_dir, revert = TRUE)
invisible(self)
},
num_procs = function() {
Expand Down Expand Up @@ -91,7 +92,8 @@ CmdStanFit <- R6::R6Class(
metadata_ = NULL,
init_ = NULL,
profiles_ = NULL,
model_methods_env_ = NULL
model_methods_env_ = NULL,
return_codes_ = NULL
)
)

Expand Down Expand Up @@ -1129,7 +1131,7 @@ CmdStanFit$set("public", name = "metadata", value = metadata)
#' }
#'
return_codes <- function() {
self$runset$procs$return_codes()
private$return_codes_
}
CmdStanFit$set("public", name = "return_codes", value = return_codes)

Expand Down
Binary file added fit-temp.rds
Binary file not shown.
1 change: 1 addition & 0 deletions tests/testthat/test-fit-shared.R
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ test_that("save_object() method works", {
fit$save_object(temp_rds_file)
fit2 <- readRDS(temp_rds_file)
expect_identical(fit2$summary(), fit$summary())
expect_identical(fit2$return_codes(), fit$return_codes())
}

# check after garbage collection too
Expand Down

0 comments on commit 8505e5b

Please sign in to comment.