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

expose_functions errors after update to 2.33 #845

Closed
jgabry opened this issue Sep 7, 2023 · 6 comments · Fixed by #843
Closed

expose_functions errors after update to 2.33 #845

jgabry opened this issue Sep 7, 2023 · 6 comments · Fixed by #843
Assignees
Labels
bug Something isn't working

Comments

@jgabry
Copy link
Member

jgabry commented Sep 7, 2023

Describe the bug

@andrjohns I can't expose stan functions anymore after installing 2.33. Have you run into this? Or any ideas what's going on?

To Reproduce

The example at ?expose_functions now errors when it didn't before:

stan_file <- write_stan_file(
  "
 functions {
   real a_plus_b(real a, real b) {
     return a + b;
   }
 }
 parameters {
   real x;
 }
 model {
   x ~ std_normal();
 }
 "
)
mod <- cmdstan_model(stan_file)
mod$expose_functions()
Compiling standalone functions...
Error in 1:first_decl : NA/NaN argument

Expected behavior
No error

Operating system

Mac Big Sur

CmdStanR version number

Current master branch (v 0.6.1.9000)

@jgabry jgabry added the bug Something isn't working label Sep 7, 2023
@jgabry
Copy link
Member Author

jgabry commented Sep 7, 2023

The error seems to be coming from get_plain_rtn() in utils.R. Is that because something in the generated c++ code changed that cmdstanr was assuming wouldn't change between cmdstan versions?

@jgabry
Copy link
Member Author

jgabry commented Sep 7, 2023

Not sure why but finding the first function declaration returns NA now:

# this now returns NA_integer_
first_decl <- grep(paste0(fun_name,"\\("), model_lines)[1]

Edit: the reason is that fun_name is now "double a_plus_b" but that doesn't appear anywhere in model_lines. In model_lines we only have

a_plus_b(const T0__& a, const T1__& b, std::ostream* pstream__);

but double a_plus_b doesn't occur.

@jgabry
Copy link
Member Author

jgabry commented Sep 7, 2023

we should probably run cmdstanr unit tests against the release candidate version of cmdstan going forward so we can catch this sooner

@WardBrian
Copy link
Member

I'm guessing this is because of stan-dev/stanc3#1313 which @andrjohns requested to make this feature easier for cmdstanr

We do run the cmdstanr unit tests during the release candidates, it's not always clear if the failures are significant - this time a few looked like they were due to the deprecations

@jgabry
Copy link
Member Author

jgabry commented Sep 8, 2023

Yeah that looks like it would cause the issue I'm seeing. Thankfully this doesn't affect running any models. But it does cause a bunch of unit tests to fail that aren't just due to the deprecations:

https://github.com/stan-dev/cmdstanr/actions/runs/6114306271/job/16595596153?pr=843#step:13:3398

@jgabry
Copy link
Member Author

jgabry commented Sep 13, 2023

Closing now that #843 was merged

@jgabry jgabry closed this as completed Sep 13, 2023
@jgabry jgabry linked a pull request Sep 13, 2023 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants