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

(API) Generate bagfile metadata in Writer #184

Merged
merged 31 commits into from
Oct 24, 2019

Conversation

zmichaels11
Copy link
Contributor

@zmichaels11 zmichaels11 commented Oct 17, 2019

This is part of an effort to rework PR #158 into multiple, smaller PRs.

Changes

  • Writer can now create BagMetadata, this enables splitting of bagfiles without having to merge intermediate bagfile metadata.

Dependent PRs

Issues

  • ros-security/aws-roadmap#11

Copy link
Collaborator

@Karsten1987 Karsten1987 left a comment

Choose a reason for hiding this comment

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

looks good to me except one comment.
Will reiterate once the dependent PRs are addressed.

rosbag2/src/rosbag2/writer.cpp Outdated Show resolved Hide resolved
rosbag2/include/rosbag2/writer.hpp Outdated Show resolved Hide resolved
rosbag2/src/rosbag2/writer.cpp Outdated Show resolved Hide resolved
rosbag2/src/rosbag2/writer.cpp Outdated Show resolved Hide resolved
rosbag2/src/rosbag2/writer.cpp Outdated Show resolved Hide resolved
@zmichaels11
Copy link
Contributor Author

@Karsten1987 I merged #184 into this PR and rebased onto master.
Please review this one.

Copy link
Collaborator

@Karsten1987 Karsten1987 left a comment

Choose a reason for hiding this comment

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

So I think I stick to my point that having a metadata class instance makes things easier. In the generate_metadata() function, we can then tackle remaining things like the duration, but in general I think it's easier to update the metadata on the fly.


With that, are you going to remove the function get_metadata() from the storage interfaces here as well? I feel like that should be part of that PR as well.

rosbag2/include/rosbag2/writer.hpp Outdated Show resolved Hide resolved
rosbag2/src/rosbag2/writer.cpp Outdated Show resolved Hide resolved
@zmichaels11
Copy link
Contributor Author

@Karsten1987 ok I reworked it so that it can build as much of BagMetadata inline.
I replaced generate_metadata() with finalize_metadata. The only operations that occur within that function are summing up bagfile size and moving the TopicInformation from the Writer owned hashmap to the metadata's vector.

Copy link
Collaborator

@Karsten1987 Karsten1987 left a comment

Choose a reason for hiding this comment

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

really only a few nitpicks. But generally looks good.

rosbag2/src/rosbag2/writer.cpp Outdated Show resolved Hide resolved
rosbag2_storage/test/rosbag2_storage/test_plugin.cpp Outdated Show resolved Hide resolved
rosbag2/src/rosbag2/writer.cpp Outdated Show resolved Hide resolved
rosbag2/src/rosbag2/writer.cpp Outdated Show resolved Hide resolved
rosbag2/src/rosbag2/writer.cpp Outdated Show resolved Hide resolved
rosbag2/src/rosbag2/writer.cpp Outdated Show resolved Hide resolved
rosbag2/src/rosbag2/writer.cpp Outdated Show resolved Hide resolved
rosbag2/src/rosbag2/writer.cpp Show resolved Hide resolved
rosbag2/src/rosbag2/writer.cpp Show resolved Hide resolved
Copy link
Contributor

@thomas-moulard thomas-moulard left a comment

Choose a reason for hiding this comment

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

Left a few comments, I am worried that we may not have proper testing here around the implicit FSM declared in this class (ctor / open / create_topic / remote_topic / read / write / close / dtor being states and not all transitions being allowed).
edit: ^ this is a general concern, probably too big to be addressed in this PR.

The dtor also is doing more than calling close, which makes me nervous (storage factory reset being put aside, which anyway is not necessary here IIUC).

We should also add test to this PR

@zmichaels11 zmichaels11 force-pushed the splitting/writer-metadata branch 2 times, most recently from 4b98107 to 7567751 Compare October 24, 2019 01:08
@zmichaels11
Copy link
Contributor Author

Opened Issue #195 regarding tests on FSM since the logic in Writer's FSM was not changed in this PR.

@piraka9011
Copy link
Contributor

  • Windows Build Status

@zmichaels11
Copy link
Contributor Author

zmichaels11 commented Oct 24, 2019

The problem in Windows builds was due to Windows including min and max as macros.
The exact same problem was found here: nlohmann/json#506.

Edit:
Solution was to add to all the CMakelists.txt:

if(WIN32)
  add_definitions(-DNOMINMAX)
endif()

Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
@piraka9011
Copy link
Contributor

piraka9011 commented Oct 24, 2019

  • Windows Build Status

Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
@piraka9011
Copy link
Contributor

  • Windows Build Status

@zmichaels11 zmichaels11 changed the title Generate bagfile metadata in Writer (API) Generate bagfile metadata in Writer Oct 24, 2019
Copy link
Contributor

@thomas-moulard thomas-moulard left a comment

Choose a reason for hiding this comment

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

The code LGTM, we should just resolve Karsten's comment on returning dummy paths and testing for those.

zmichaels11 and others added 3 commits October 24, 2019 11:57
Co-Authored-By: Thomas Moulard <thomas.moulard@gmail.com>
Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
Co-Authored-By: Thomas Moulard <thomas.moulard@gmail.com>
Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
Copy link
Contributor

@thomas-moulard thomas-moulard left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@zmichaels11
Copy link
Contributor Author

@piraka9011 one last time, but with more unit tests

Copy link
Collaborator

@Karsten1987 Karsten1987 left a comment

Choose a reason for hiding this comment

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

This looks good to me (with green CI).
Just a nitpick with renaming the constants header file.

rosbag2_storage/test/rosbag2_storage/test_plugin.cpp Outdated Show resolved Hide resolved
rosbag2_storage/test/rosbag2_storage/plugin_constants.hpp Outdated Show resolved Hide resolved
Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
@zmichaels11
Copy link
Contributor Author

  • Renamed plugin_constants -> test_constants
  • Moved default_max_bagfile_size into test_constants

@Karsten1987
Copy link
Collaborator

Please run a new round of CI on this. Also make sure you build packages up to ros2bag and rosbag2_tests and test with packages-select-regex rosbag2

@piraka9011
Copy link
Contributor

Gist: https://gist.githubusercontent.com/piraka9011/d15a12ab0ff8cd4c3f20c7c1f14180b8/raw/7cda0198d9bee189ba8f61a3da0f8801c1ee378e/ros2.repos
BUILD args: --packages-up-to rosbag2 rosbag2_tests
TEST args: --packages-select rosbag2
Job: ci_launcher

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@Karsten1987
Copy link
Collaborator

Given that this PR is touching more than one package, I think we should test all rosbag2 related packages.
Therefore I proposed to set packages-select-regex rosbag2 as test args instead of just testing rosbag2 to avoid regression.

@piraka9011
Copy link
Contributor

Sorry I missed that. Here's the new build:

Gist: https://gist.githubusercontent.com/piraka9011/d15a12ab0ff8cd4c3f20c7c1f14180b8/raw/7cda0198d9bee189ba8f61a3da0f8801c1ee378e/ros2.repos
BUILD args: --packages-up-to rosbag2 rosbag2_tests
TEST args: --packages-select-regex rosbag2
Job: ci_launcher

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Signed-off-by: Zachary Michaels <zmichaels11@gmail.com>
@piraka9011
Copy link
Contributor

Gist: https://gist.githubusercontent.com/piraka9011/21c04ad8e74d0f75a3f6bfae01264072/raw/7cda0198d9bee189ba8f61a3da0f8801c1ee378e/ros2.repos
BUILD args: --packages-up-to rosbag2 rosbag2_tests
TEST args: --packages-select-regex rosbag2
Job: ci_launcher

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@zmichaels11
Copy link
Contributor Author

@Karsten1987 we're green!

@Karsten1987 Karsten1987 merged commit f7096d1 into ros2:master Oct 24, 2019
@zmichaels11 zmichaels11 deleted the splitting/writer-metadata branch October 28, 2019 16:15
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.

None yet

4 participants