-
Notifications
You must be signed in to change notification settings - Fork 158
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
truncate arrays, bytes, and strings by default, add option to show in full or use custom threshold #31
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work in my testing.
My rational for using truncation by default is the following:
Additional improvements could be:
|
I'm not sure if the default behavior should be "not show the entire message". While making sense for large messages it seems odd that if I ask to print the content of a message I get only part of it. Maybe if you can clarify what is the use case we try to solve with this approach we can discuss alternatives and decide which one is the best suited default behaviour |
Well I guess I should have sent this message when I wrote it after the offline discussion 😖 and not 40 min late... thanks for providing a rationale. I see your reasoning, I agree that defaulting to something having bad performances is not ideal. I think that if this is to be merged we should at least allow users to chose the threshold. I'd like to have more input from @ros2/team before merging this because that's a change from ROS1 behavior (and general expected behavior) that should be discussed and considered carefully before imposing it to users. Then I agree we can iterate on it later so it could be rolled out as is in beta2 and modified later. |
I will add an additional option for this. I guess one threshold for all three types is sufficient?
Before discussing what we should do I would like to have a consensus on the goals. Do we agree about the two goals described in the first two bullets (non-broken for "large" msgs by default, see all values for "small" msgs by default)? If each of you could answer that question first that would be helpful. |
Yes I think that's sufficient
Yeah I think that's a good goal to have if we agree that someone calling Looking at the patch, this truncature also applies to fixed length arrays and not only the dynamic ones right ? |
Yes, good point. I will rename the constant to |
Yeah, I definitely agree with this. Otherwise the user has no idea what is wrong with their invocation of echo.
Seems sane to me.
I can see that option being useful here as well, but I'm happy to defer that until later. |
… full or use custom threshold
7f4d7bd
to
33fb094
Compare
I'm ok with having automatic truncating (or automatic summarizing, however you want to call it). +1 for the proposed changes. Though I'm dubious about the rationale that large messages are broken by default in this case. Whether or not it can print all the messages depends on the speed of your computer and the size of message. Not whether or not it is truncated. Presumably a large enough message (or high enough frequency messages) would result in not every message being printed even with truncating on. I like the proposed changes because it's a better user experience, i.e. the summary is more useful than the raw data in most cases, imo. |
I updated the patch. It has an option to pass a custom threshold (which can also be zero). Ready for re-review. |
I could remove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, though I was originally assuming that this would summarize the array's (a la ros/ros_comm#724), but the truncating is ok for now I guess.
ros2topic/ros2topic/verb/echo.py
Outdated
@@ -41,6 +54,15 @@ def add_arguments(self, parser, cli_name): | |||
'--csv', action='store_true', | |||
help='Output all recursive fields separated by commas (e.g. for ' | |||
'plotting)') | |||
parser.add_argument( | |||
'--full-length', action='store_true', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to have a short flag for this, maybe -f
or -a
. @ros2/team what does everyone else think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I also think it would be good to have short options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: 0777ef2
ros2topic/ros2topic/verb/echo.py
Outdated
"length > '--truncate-length', by default they are truncated " | ||
"after '--truncate-length' elements with '...''") | ||
parser.add_argument( | ||
'--truncate-length', type=unsigned_int, default=DEFAULT_TRUNCATE_LENGTH, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, maybe -l
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: 0777ef2
Personally I like the explicit |
I'd be OK with that, though if you did that, I would suggest changing the name of the flag to "max-print-length" or something like that. |
I will go ahead soon and merge this as-is if there are no further comments. |
that sounds good to me we can iterate on a summarize option or an alternative after the release |
Updated test accordingly in 1156c0d. |
* parameter values get evaluated by yaml rules Signed-off-by: Shane Loretz <sloretz@osrfoundation.org> * Use new variable type syntax Signed-off-by: Shane Loretz <sloretz@osrfoundation.org> * type_ -> last_subtype Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
This will allow to print every image message with:
ros2 topic echo /image