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

Adding the option to print values in the print action #63

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

stefaniereuter
Copy link
Contributor

This is something I sometimes used when debugging actions. I also have a different version in another branch, where I added an option to output just flushes. I will add this in another PR as it's orthogonal. Need to write a test to move from draft to mergable, unless you all decide you don't want this option in the print action
How it works:

  • type: print
    prefix: "Prefix"
    stream: cout
    include-data-values: true
    value-count: 10

@codecov-commenter
Copy link

codecov-commenter commented Mar 11, 2025

Codecov Report

Attention: Patch coverage is 30.76923% with 9 lines in your changes missing coverage. Please review.

Project coverage is 53.04%. Comparing base (8712a46) to head (1037de5).

Files with missing lines Patch % Lines
src/multio/action/print/Print.cc 30.76% 9 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #63      +/-   ##
===========================================
- Coverage    53.06%   53.04%   -0.03%     
===========================================
  Files          217      217              
  Lines        14644    14656      +12     
  Branches      1213     1216       +3     
===========================================
+ Hits          7771     7774       +3     
- Misses        6873     6882       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -21,6 +21,8 @@ namespace multio::action {
Print::Print(const ComponentConfiguration& compConf) : ChainedAction(compConf) {
stream_ = compConf.parsedConfig().getString("stream", "info");
onlyFields_ = compConf.parsedConfig().getBool("only-fields", false);
includeValues_ = compConf.parsedConfig().getBool("include-data-values",false);
numberOfValues_ = compConf.parsedConfig().getInt("value-count",0);
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a start-index option (default to 0) to indicate at which index to start printing? I think this would be especially useful if the data starts with missing values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do we know from which index missing values begin/end?

Copy link
Member

Choose a reason for hiding this comment

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

I guess you can look at the bitmap and count. We could automate this and accept this option to be set to "first-non-missing", but that requires a bit more work.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would probably rather just have a mechanism to print missing values, i.e. write the string 'missing' or 'n/a' instead of a numeric value.

(*os_) << msg << "\n";
if(includeValues_) {
const auto* data = static_cast<const double*>(msg.payload().data());
const auto* end = data + (msg.payload().size() / sizeof(double));
Copy link
Member

Choose a reason for hiding this comment

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

I think our data can also be in 32 bits float instead of 64 bits double. In that case we should check the precision key and handle floats slightly different from doubles.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah you're right. That was a hack that I did because I knew it was a double field that came in. We should discuss if we want to have this in at all.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I think this would only be useful for tiny payloads. I guess there may not be harm including it, but the code will need a bit of tightening up beforehand. Apart from the precision support, we may want to make sure that we always use reference to ostream and a bit more 'modern' C++ for loops.

@stefaniereuter
Copy link
Contributor Author

I have used it and before deleting it after this debug work I thought I'll bring it up for discussion if we want to have it added. But I agree that the precision part would need some work. I've also already added an filter that only fields are allowed because currently flushes would try to print a payload as well

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