Skip to content
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

suggest format method after error due to old syntax #852

Merged
merged 6 commits into from
Sep 15, 2023

Conversation

jgabry
Copy link
Member

@jgabry jgabry commented Sep 13, 2023

Submission Checklist

  • Run unit tests
  • Declare copyright holder and agree to license (see below)

Summary

Advances #849 (doesn't address the interactive part)

Suggests format method if compilation error due to old syntax. This doesn't yet do the formatting if in interactive mode, just suggests looking at the example in the doc for format. I added an example to that doc showing how to change old syntax.

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):
Columbia University

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

@jgabry
Copy link
Member Author

jgabry commented Sep 13, 2023

Example

f <- write_stan_file(
"
parameters {
  real x[3];
}
model {
 x ~ normal(0, 1);
}
"
)
m <- cmdstan_model(f)
Compiling Stan program...
Error in '/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpjGrUuu/model-14ede482935d4.stan', line 3, column 2: Declaration
    of arrays by placing brackets after a variable name was removed in Stan
    2.33.0. Instead use the array keyword before the type. This can be
    changed automatically using the auto-format flag to stanc

make: *** [/var/folders/s0/zfzm55px2nd2v__zlw5xfj2h0000gn/T/RtmpjGrUuu/model-14ede482935d4.hpp] Error 65

Error: An error occured during compilation! See the message above for more information. 
To fix deprecated or removed syntax please see ?cmdstanr::format for an example.

The last line of the error message is new. But instead of suggesting how to call the format method I have it point to the example in the format doc that I updated. The user needs to set compile=FALSE when calling cmdstan_model and then run the format method, which is a bit much to describe in the error message. Easier to just see the example in the doc.

We can also do this interactively in the future, but as a start this message should help.

@jgabry
Copy link
Member Author

jgabry commented Sep 13, 2023

This might conflict with changes in #836, so we should merge that first.

@jgabry
Copy link
Member Author

jgabry commented Sep 13, 2023

This might conflict with changes in #836, so we should merge that first.

Just merged that branch into this one, so I can avoid conflicts

@jgabry jgabry marked this pull request as ready for review September 13, 2023 18:10
@jgabry
Copy link
Member Author

jgabry commented Sep 13, 2023

@andrjohns @rok-cesnovar @avehtari This is ready for a look if any of you have a chance. We should wait to merge it until #836 is merged (I'll merge that one if the checks that are running pass).

@codecov-commenter
Copy link

codecov-commenter commented Sep 14, 2023

Codecov Report

Merging #852 (1dc3b50) into master (22ee5fc) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 1dc3b50 differs from pull request most recent head 480a775. Consider uploading reports for the commit 480a775 to get more accurate results

@@           Coverage Diff           @@
##           master     #852   +/-   ##
=======================================
  Coverage   88.18%   88.19%           
=======================================
  Files          12       12           
  Lines        4215     4218    +3     
=======================================
+ Hits         3717     3720    +3     
  Misses        498      498           
Files Changed Coverage Δ
R/model.R 91.82% <100.00%> (+0.03%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@jgabry jgabry changed the title suggest format method for auto-formatting suggest format method after error due to old syntax Sep 14, 2023
Copy link
Contributor

@avehtari avehtari left a comment

Choose a reason for hiding this comment

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

The proposed error message is fine, I'd make changes to the format doc

R/model.R Outdated Show resolved Hide resolved
Copy link
Member

@rok-cesnovar rok-cesnovar left a comment

Choose a reason for hiding this comment

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

Awesome, thanks!

@jgabry
Copy link
Member Author

jgabry commented Sep 15, 2023

I updated the doc based on @avehtari's suggestion. Will merge if everything passes.

@jgabry jgabry merged commit 17678d5 into master Sep 15, 2023
12 checks passed
@jgabry jgabry deleted the auto-format-suggestion branch September 15, 2023 22: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.

4 participants