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

laplace_sample service console output has too many newlines #3151

Closed
mitzimorris opened this issue Nov 9, 2022 · 5 comments
Closed

laplace_sample service console output has too many newlines #3151

mitzimorris opened this issue Nov 9, 2022 · 5 comments
Assignees

Comments

@mitzimorris
Copy link
Member

Summary:

The console output of the laplace_sample method contains hundreds of blank lines.

Description:

This arises from two things:

To fix the former, remove newlines.
To fix the latter, check the stringstream before calling the logger.

 model.write_array(rng, unc_draw, draw_vec, include_tp, include_gq, &write_array_msgs);
    if (refresh > 0) {
      if (write_array_msgs.peek() != std::char_traits<char>::eof())
        logger.info(write_array_msgs);

Reproducible Steps:

Use CmdStan branch https://github.com/stan-dev/cmdstan/tree/feature/1123-laplace-approx to invoke the laplace_sample method, model and input files are in the src/test/test-models/ directory.

>  src/test/test-models/multi_normal_model laplace mode=src/test/test-models/multi_normal_mode.csv

Current Output:

the beginning of the console ouput from call to laplace_sample - refresh is default 100, so lots of whitespace between iteration messages.

Calculating Hessian




Calculating inverse of Cholesky factor


Generating draws


iteration: 
0





Expected Output:

Calculating Hessian
Calculating inverse of Cholesky factor
Generating draws
iteration: 0
iteration: 100
iteration: 200
iteration: 300
iteration: 400
iteration: 500
iteration: 600
iteration: 700
iteration: 800
iteration: 900

Additional Information:

Provide any additional information here.

Current Version:

v2.30.0

@mitzimorris mitzimorris self-assigned this Nov 9, 2022
@bob-carpenter
Copy link
Contributor

Thanks for figuring this out. This is why I was asking if there was a newline appended to all of the callbacks. I had thought the answer was "no", but it's apparently "yes"!

@WardBrian
Copy link
Member

There is a longstanding issue to make the logger ignore blank lines: #2577. Partial fix was started in #3098

@bob-carpenter
Copy link
Contributor

The issue arose because I assumed there wasn't a newline inserted at the end of each message. If we are going to add newlines, then we probably do not want to ignore blank lines, as they correspond to newlines in the output.

@WardBrian
Copy link
Member

In that case we can probably close those two

@WardBrian
Copy link
Member

Closed by #3153

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants