-
Notifications
You must be signed in to change notification settings - Fork 321
Introduce ros2 bag reindex #539
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
Closed
Closed
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
55a3d03
Distro A, OPSEC #4584
3d3afba
Remove Boost
b26db0a
Remove extra newline
3153d81
Change exception to be in line with Unix
1654cd5
Fixed syntax error
28c48a4
Linux reindexer now working
94acad2
FIXED USING WRONG LICENSE
5e533ff
Remove sneaky boost reference
0444bd4
Test reordering license header
d161c03
Test another license reordering
eea8638
Convert to rosbag2_storage::StorageOptions
b5e7f10
Missed a StorageOptions in the previous commit
9b6d8ec
Add test data
5152360
Ignore __pycache__ in commits
1495ddd
Re-use Python tests
bb0d5af
Implement Unit Testing
caeb348
Fixes that were suggested but buried in PR
a2d6321
Fix init_metadata function call
b5f74f8
Add missing reindexer_ parameters
7d43d3f
Disable compression testing
f47aba9
Linting fixes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,3 +5,4 @@ cmake-build-release/ | |
| build/ | ||
| venv/ | ||
| **/.pytest_cache/ | ||
| **/__pycache__/** | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # Copyright 2018 Open Source Robotics Foundation, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import os | ||
|
|
||
| from ros2bag.api import check_path_exists | ||
| from ros2bag.verb import VerbExtension | ||
|
|
||
|
|
||
| class ReindexVerb(VerbExtension): | ||
| """Generate metadata from a bag.""" | ||
|
|
||
| def add_arguments(self, parser, cli_name): # noqa: D102 | ||
| parser.add_argument( | ||
| 'bag_file', type=check_path_exists, help='Bag file to reindex') | ||
| parser.add_argument( | ||
| '-s', '--storage', default='sqlite3', | ||
| help="storage identifier to be used, defaults to 'sqlite3'") | ||
| parser.add_argument( | ||
| '-f', '--serialization-format', default='', | ||
| help='rmw serialization format in which the messages are saved, defaults to the' | ||
| ' rmw currently in use') | ||
| parser.add_argument( | ||
| '--compression-format', type=str, default='', choices=['zstd'], | ||
| help='Specify the compression format/algorithm. Default is none.' | ||
| ) | ||
| self._subparser = parser | ||
|
|
||
| def main(self, *, args): # noqa: D102 | ||
| uri = args.bag_file | ||
|
|
||
| # NOTE(hidmic): in merged install workspaces on Windows, Python entrypoint lookups | ||
| # combined with constrained environments (as imposed by colcon test) | ||
| # may result in DLL loading failures when attempting to import a C | ||
| # extension. Therefore, do not import rosbag2_transport at the module | ||
| # level but on demand, right before first use. | ||
| from rosbag2_transport import rosbag2_transport_py | ||
|
|
||
| rosbag2_transport_py.reindex( | ||
| uri=uri, | ||
| storage_id=args.storage, | ||
| serialization_format=args.serialization_format, | ||
| compression_format=args.compression_format | ||
| ) | ||
|
|
||
| if os.path.isdir(uri) and not os.listdir(uri): | ||
| os.rmdir(uri) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+6.42 KB
ros2bag/test/resources/reindex_test_bags/file_compression/file_compression_0.db3.zstd
Binary file not shown.
Binary file added
BIN
+6.26 KB
ros2bag/test/resources/reindex_test_bags/file_compression/file_compression_1.db3.zstd
Binary file not shown.
Binary file added
BIN
+6.11 KB
ros2bag/test/resources/reindex_test_bags/file_compression/file_compression_2.db3.zstd
Binary file not shown.
Binary file added
BIN
+1.85 KB
ros2bag/test/resources/reindex_test_bags/file_compression/file_compression_3.db3.zstd
Binary file not shown.
34 changes: 34 additions & 0 deletions
34
ros2bag/test/resources/reindex_test_bags/file_compression/file_compression_target.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| rosbag2_bagfile_information: | ||
| version: 4 | ||
| storage_identifier: sqlite3 | ||
| relative_file_paths: | ||
| - file_compression/file_compression_0.db3.zstd | ||
| - file_compression/file_compression_1.db3.zstd | ||
| - file_compression/file_compression_2.db3.zstd | ||
| - file_compression/file_compression_3.db3.zstd | ||
| duration: | ||
| nanoseconds: 59997866716 | ||
| starting_time: | ||
| nanoseconds_since_epoch: 1604357089919704830 | ||
| message_count: 775 | ||
| topics_with_message_count: | ||
| - topic_metadata: | ||
| name: /topic | ||
| type: std_msgs/msg/String | ||
| serialization_format: cdr | ||
| offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 2\n deadline:\n sec: 2147483647\n nsec: 4294967295\n lifespan:\n sec: 2147483647\n nsec: 4294967295\n liveliness: 1\n liveliness_lease_duration:\n sec: 2147483647\n nsec: 4294967295\n avoid_ros_namespace_conventions: false" | ||
| message_count: 383 | ||
| - topic_metadata: | ||
| name: /parameter_events | ||
| type: rcl_interfaces/msg/ParameterEvent | ||
| serialization_format: cdr | ||
| offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 2\n deadline:\n sec: 2147483647\n nsec: 4294967295\n lifespan:\n sec: 2147483647\n nsec: 4294967295\n liveliness: 1\n liveliness_lease_duration:\n sec: 2147483647\n nsec: 4294967295\n avoid_ros_namespace_conventions: false" | ||
| message_count: 0 | ||
| - topic_metadata: | ||
| name: /rosout | ||
| type: rcl_interfaces/msg/Log | ||
| serialization_format: cdr | ||
| offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 1\n deadline:\n sec: 2147483647\n nsec: 4294967295\n lifespan:\n sec: 10\n nsec: 0\n liveliness: 1\n liveliness_lease_duration:\n sec: 2147483647\n nsec: 4294967295\n avoid_ros_namespace_conventions: false" | ||
| message_count: 392 | ||
| compression_format: zstd | ||
| compression_mode: FILE |
Binary file added
BIN
+84 KB
ros2bag/test/resources/reindex_test_bags/message_compression/message_compression_0.db3
Binary file not shown.
Binary file added
BIN
+80 KB
ros2bag/test/resources/reindex_test_bags/message_compression/message_compression_1.db3
Binary file not shown.
Binary file added
BIN
+80 KB
ros2bag/test/resources/reindex_test_bags/message_compression/message_compression_2.db3
Binary file not shown.
Binary file added
BIN
+16 KB
ros2bag/test/resources/reindex_test_bags/message_compression/message_compression_3.db3
Binary file not shown.
34 changes: 34 additions & 0 deletions
34
ros2bag/test/resources/reindex_test_bags/message_compression/message_compression_target.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| rosbag2_bagfile_information: | ||
| version: 4 | ||
| storage_identifier: sqlite3 | ||
| relative_file_paths: | ||
| - message_compression/message_compression_0.db3 | ||
| - message_compression/message_compression_1.db3 | ||
| - message_compression/message_compression_2.db3 | ||
| - message_compression/message_compression_3.db3 | ||
| duration: | ||
| nanoseconds: 59872587605 | ||
| starting_time: | ||
| nanoseconds_since_epoch: 1604581538133709023 | ||
| message_count: 1127 | ||
| topics_with_message_count: | ||
| - topic_metadata: | ||
| name: /parameter_events | ||
| type: rcl_interfaces/msg/ParameterEvent | ||
| serialization_format: cdr | ||
| offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 2\n deadline:\n sec: 2147483647\n nsec: 4294967295\n lifespan:\n sec: 2147483647\n nsec: 4294967295\n liveliness: 1\n liveliness_lease_duration:\n sec: 2147483647\n nsec: 4294967295\n avoid_ros_namespace_conventions: false\n- history: 3\n depth: 0\n reliability: 1\n durability: 2\n deadline:\n sec: 2147483647\n nsec: 4294967295\n lifespan:\n sec: 2147483647\n nsec: 4294967295\n liveliness: 1\n liveliness_lease_duration:\n sec: 2147483647\n nsec: 4294967295\n avoid_ros_namespace_conventions: false" | ||
| message_count: 0 | ||
| - topic_metadata: | ||
| name: /rosout | ||
| type: rcl_interfaces/msg/Log | ||
| serialization_format: cdr | ||
| offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 1\n deadline:\n sec: 2147483647\n nsec: 4294967295\n lifespan:\n sec: 10\n nsec: 0\n liveliness: 1\n liveliness_lease_duration:\n sec: 2147483647\n nsec: 4294967295\n avoid_ros_namespace_conventions: false\n- history: 3\n depth: 0\n reliability: 1\n durability: 1\n deadline:\n sec: 2147483647\n nsec: 4294967295\n lifespan:\n sec: 10\n nsec: 0\n liveliness: 1\n liveliness_lease_duration:\n sec: 2147483647\n nsec: 4294967295\n avoid_ros_namespace_conventions: false" | ||
| message_count: 758 | ||
| - topic_metadata: | ||
| name: /topic | ||
| type: std_msgs/msg/String | ||
| serialization_format: cdr | ||
| offered_qos_profiles: "" | ||
| message_count: 369 | ||
| compression_format: zstd | ||
| compression_mode: MESSAGE |
Binary file added
BIN
+52 KB
ros2bag/test/resources/reindex_test_bags/multiple_files/multiple_files_0.db3
Binary file not shown.
Binary file added
BIN
+32 KB
ros2bag/test/resources/reindex_test_bags/multiple_files/multiple_files_0.db3-shm
Binary file not shown.
Empty file.
Binary file added
BIN
+48 KB
ros2bag/test/resources/reindex_test_bags/multiple_files/multiple_files_1.db3
Binary file not shown.
Binary file added
BIN
+32 KB
ros2bag/test/resources/reindex_test_bags/multiple_files/multiple_files_1.db3-shm
Binary file not shown.
Empty file.
Binary file added
BIN
+52 KB
ros2bag/test/resources/reindex_test_bags/multiple_files/multiple_files_2.db3
Binary file not shown.
Binary file added
BIN
+32 KB
ros2bag/test/resources/reindex_test_bags/multiple_files/multiple_files_2.db3-shm
Binary file not shown.
Empty file.
Binary file added
BIN
+24 KB
ros2bag/test/resources/reindex_test_bags/multiple_files/multiple_files_3.db3
Binary file not shown.
Binary file added
BIN
+32 KB
ros2bag/test/resources/reindex_test_bags/multiple_files/multiple_files_3.db3-shm
Binary file not shown.
Empty file.
34 changes: 34 additions & 0 deletions
34
ros2bag/test/resources/reindex_test_bags/multiple_files/multiple_files_target.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| rosbag2_bagfile_information: | ||
| version: 4 | ||
| storage_identifier: sqlite3 | ||
| relative_file_paths: | ||
| - multiple_files_0.db3 | ||
| - multiple_files_1.db3 | ||
| - multiple_files_2.db3 | ||
| - multiple_files_3.db3 | ||
| duration: | ||
| nanoseconds: 59997863418 | ||
| starting_time: | ||
| nanoseconds_since_epoch: 1604356847420232242 | ||
| message_count: 766 | ||
| topics_with_message_count: | ||
| - topic_metadata: | ||
| name: /topic | ||
| type: std_msgs/msg/String | ||
| serialization_format: cdr | ||
| offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 2\n deadline:\n sec: 2147483647\n nsec: 4294967295\n lifespan:\n sec: 2147483647\n nsec: 4294967295\n liveliness: 1\n liveliness_lease_duration:\n sec: 2147483647\n nsec: 4294967295\n avoid_ros_namespace_conventions: false" | ||
| message_count: 378 | ||
| - topic_metadata: | ||
| name: /parameter_events | ||
| type: rcl_interfaces/msg/ParameterEvent | ||
| serialization_format: cdr | ||
| offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 2\n deadline:\n sec: 2147483647\n nsec: 4294967295\n lifespan:\n sec: 2147483647\n nsec: 4294967295\n liveliness: 1\n liveliness_lease_duration:\n sec: 2147483647\n nsec: 4294967295\n avoid_ros_namespace_conventions: false" | ||
| message_count: 0 | ||
| - topic_metadata: | ||
| name: /rosout | ||
| type: rcl_interfaces/msg/Log | ||
| serialization_format: cdr | ||
| offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 1\n deadline:\n sec: 2147483647\n nsec: 4294967295\n lifespan:\n sec: 10\n nsec: 0\n liveliness: 1\n liveliness_lease_duration:\n sec: 2147483647\n nsec: 4294967295\n avoid_ros_namespace_conventions: false" | ||
| message_count: 388 | ||
| compression_format: "" | ||
| compression_mode: "" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Both
compression-formatandcompression-modechoices shouldn't be duplicated. Perhaps they should be factored out ofrecord.pyand this file into a common place - or you could at least pull the values out ofrecord.py'sadd_argumentcalls into a global level variable for that module, andfrom ros2bag.verb.record import COMPRESSION_MODES- something like that. The duplication will inevitable get desynchronized in the future