Skip to content

Allow instantiation of CmdStanModel with just an executable #564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Oct 13, 2021
Merged

Conversation

rok-cesnovar
Copy link
Member

Summary

Fixes #488

With this we could do the following:

library(cmdstanr)

stan_file <- file.path(path.package("cmdstanr"), "logistic.stan")
# the current way
mod <- cmdstan_model(stan_file = stan_file)

new_loc <- "~/logistic"
file.copy(mod$exe_file(), new_loc)

# create if with exe file only
mod_exe <- cmdstan_model(exe_file = new_loc)
data_file <- file.path(path.package("cmdstanr"), "logistic.data.json")
mod_exe$sample(data = data_file)


# you can also specify both
# it will compile it to the exe_file location if compilation is needed
mod_exe <- cmdstan_model(stan_file = stan_file, exe_file = new_loc)
data_file <- file.path(path.package("cmdstanr"), "logistic.data.json")
mod_exe$sample(data = data_file)

Copyright and Licensing

Please list the copyright holder for the work you are submitting
(this will be you or your assignee, such as a university or company):
Rok Češnovar

By submitting this pull request, the copyright holder is agreeing to
license the submitted work under the following licenses:

@rok-cesnovar rok-cesnovar changed the title Allow instation of cmdstanmodel with just an executable Allow instantiation of CmdStanModel with just an executable Oct 5, 2021
@codecov-commenter
Copy link

codecov-commenter commented Oct 8, 2021

Codecov Report

Merging #564 (9d203f4) into master (32ac2d5) will increase coverage by 0.03%.
The diff coverage is 98.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #564      +/-   ##
==========================================
+ Coverage   93.07%   93.10%   +0.03%     
==========================================
  Files          12       12              
  Lines        3191     3206      +15     
==========================================
+ Hits         2970     2985      +15     
  Misses        221      221              
Impacted Files Coverage Δ
R/model.R 93.15% <98.00%> (+0.19%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 32ac2d5...9d203f4. Read the comment docs.

@rok-cesnovar rok-cesnovar requested a review from jgabry October 11, 2021 06:42
Copy link
Member

@jgabry jgabry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks! I pushed a few minor doc edits and added a few very minor review comments/suggestions.

@rok-cesnovar
Copy link
Member Author

Should be ready to review again.

Copy link
Member

@jgabry jgabry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Merging now

@jgabry jgabry merged commit fe5e951 into master Oct 13, 2021
@jgabry jgabry deleted the exe_file branch October 13, 2021 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow instantiation of CmdStanModel object from exe file only, no stan file
3 participants