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

Suppress the remaining messages in cmdstan_model() if quiet is TRUE? #429

Closed
wlandau opened this issue Jan 7, 2021 · 9 comments · Fixed by #462
Closed

Suppress the remaining messages in cmdstan_model() if quiet is TRUE? #429

wlandau opened this issue Jan 7, 2021 · 9 comments · Fixed by #462

Comments

@wlandau
Copy link
Collaborator

wlandau commented Jan 7, 2021

I think it would be convenient if "Compiling Stan program..." and "Model executable is up to date!" were suppressed when quiet is TRUE.

library(cmdstanr)
#> This is cmdstanr version 0.2.2
#> - Online documentation and vignettes at mc-stan.org/cmdstanr
#> - CmdStan path set to: /Users/<CENSORED>/.cmdstanr/cmdstan-2.25.0
#> - Use set_cmdstan_path() to change the path
stan_program <- "
data {
  int<lower=0> N;
  int<lower=0,upper=1> y[N];
}
parameters {
  real<lower=0,upper=1> theta;
}
model {
  y ~ bernoulli(theta);
}
"
file <- write_stan_file(stan_program)

model <- cmdstan_model(file, quiet = TRUE)
#> Compiling Stan program...

model <- cmdstan_model(file, quiet = TRUE)
#> Model executable is up to date!

Created on 2021-01-06 by the reprex package (v0.3.0)

@rok-cesnovar
Copy link
Member

Thanks!

I think we want to have 3 levels of output:

  • no output (what you propose)
  • print informational messages (what we currently print with quiet = TRUE)
  • print all compile messages (what we currently print with quiet = FALSE)

I am not sure what would be the best way of adding the "no output" option. A new argument or some third value to quiet, like quiet = "really quiet" :)

@wlandau
Copy link
Collaborator Author

wlandau commented Jan 8, 2021

After more thought...what about a custom path to a log file? log = R.utils::nullfile() could be equivalent to totally quiet, and a text log would be super convenient for models that take days to run. I currently do this in stantargets: https://wlandau.github.io/stantargets/reference/tar_stan_mcmc.html#arguments.

@wlandau
Copy link
Collaborator Author

wlandau commented Jan 8, 2021

I know R CMD BATCH has a log of its own, but sometimes stdout does not come through, e.g. in HPC settings where it can be difficult or annoying to relay the output.

@mike-lawrence
Copy link
Collaborator

@wlandau See this feature discussion, the proposed implementation of which would involve stdout/stderr files, which should address the persistent verbosity of cmdstan.

@dpsimpson
Copy link

A different solution that might be useful regardless of the new features would be to only print out those messages when interactive() == TRUE. This would fix the problem for RMarkdown docs.

@rok-cesnovar
Copy link
Member

Oh, good point.

Will make a PR for that prior to what we agree on for the features. Rmd displaying messages from cmdstanr has annoyed me to no end. Didnt think of interactive...

@wlandau
Copy link
Collaborator Author

wlandau commented Mar 10, 2021

Noticed it has been a while. I can write the PR for if (interactive()) if you would like. May I?

@rok-cesnovar
Copy link
Member

Of course! Sorry, it was a bit busy the last month. Thank you!

@wlandau
Copy link
Collaborator Author

wlandau commented Mar 10, 2021

Thanks!

I forgot I need to go through a couple pre-approvals at my work before I start submitting PRs to cmdstanr. Hopefully that will go through this week.

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 a pull request may close this issue.

4 participants