Model methods fail on a reloaded fit when the data was passed in memory
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start with the $save_object() and $init_model_methods() methods on the fit object, and with $save_data_file(), which the issue says is the only way the data survives. Reproduce by saving a fit whose data was passed as a list, reloading it in a new session, and calling $log_prob(). Done means the model methods compile on the reloaded fit when data is supplied to $init_model_methods(), and the existing save/reload tests still pass.
Written by the indexing model from the issue text.
Description
A fit created with data = list(...), saved with $save_object() and reloaded in a new R session compiles the model methods and then errors:
# session 1
fit <- cmdstanr_example("logistic")
fit$save_object("fit.rds")
# session 2
fit <- readRDS("fit.rds")
fit$log_prob(rep(0, 4))
#> Error : Error in JSON parsing
#> at offset 0:
#> The document is empty.
The fitted model object only stores the path to the JSON file CmdStanR wrote in the first session's tempdir, and $save_object() reads in the draws and diagnostics but not the data (on purpose since data files can be very large). This means that in the new session the path points nowhere unless the user had previously called fit$save_data_file() before the end of the initial session.
Instead of storing the data in the fit (we want to avoid this), we can add a data argument to $init_model_methods() for the cases when it's needed.
- Dominant language
- R
- Stars
- 164
- Forks
- 69
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 48
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from stan-dev/cmdstanr
-
internal-code
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
stan-dev/cmdstanr#506 · 7 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
internal-code
Difficulty 4/5 3-5 days Newbie friendliness 48/100
stan-dev/cmdstanr#1314 · 4 comments ·
Maintainers usually reply within 1 day
-
feature
Difficulty 4/5 3-5 days Newbie friendliness 35/100
stan-dev/cmdstanr#1175 · 1 comment · 2 reactions ·
Maintainers usually reply within 1 day
-
CmdStanR 1.0 releaseOpen
Difficulty 5/5 Over a week Newbie friendliness 20/100
stan-dev/cmdstanr#1059 · 8 comments ·
Maintainers usually reply within 1 day
All issues in stan-dev/cmdstanr
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
mitchelloharawild/ggtime#39 ·
-
enhancement good first issue help wanted
Difficulty 2/5 Half a day Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
GSK-Biostatistics/multigrain#43 ·
Maintainers usually reply within 1 day