Skip to content

Commit cdb1a51

Browse files
committed
add check for cmdstanmodel does not exist
1 parent b13db84 commit cdb1a51

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

R/utilities.R

+6-2
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,11 @@ vb_iterative = function(model,
316316
return(my_res)
317317
},
318318
error = function(e) {
319-
320-
writeLines(sprintf("Further attempt with Variational Bayes: %s", e))
319+
if(e$message |> str_detect("The Stan file used to create the `CmdStanModel` object does not exist\\.")) {
320+
clear_stan_model_cache()
321+
model <<- load_model(model_name, force=TRUE, threads = cores)
322+
}
323+
else writeLines(sprintf("Further attempt with Variational Bayes: %s", e))
321324

322325
return(NULL)
323326
},
@@ -586,6 +589,7 @@ fit_model = function(
586589

587590

588591
} else{
592+
589593
if(inference_method=="pathfinder") init = pf
590594
else if(inference_method=="variational") init = list(init_list)
591595

0 commit comments

Comments
 (0)