-
Notifications
You must be signed in to change notification settings - Fork 261
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 db directory creation to rosbag2_cpp #450
Conversation
@Karsten1987 can you review this (if in your domain)? This is blocking some porting efforts and seems relatively small |
thanks a lot for picking this up. However, I think this logic makes more sense within |
@@ -97,6 +97,16 @@ void SequentialWriter::open( | |||
|
|||
const auto storage_uri = format_storage_uri(base_folder_, 0); | |||
|
|||
rcpputils::fs::path db_path(storage_uri); | |||
if (!db_path.parent_path().is_directory()) { |
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.
what happens if the directory exists already?
I think the logic should be inverted here: There should be an exception being raised the moment the directory exists already. That's the current behavior in ros2bag
. Simply because we don't want to overwrite any files.
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.
That makes sense, should be changed now.
@@ -97,6 +97,16 @@ void SequentialWriter::open( | |||
|
|||
const auto storage_uri = format_storage_uri(base_folder_, 0); | |||
|
|||
rcpputils::fs::path db_path(storage_uri); |
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.
why not using base_folder_
? That should avoid the need to verify the parent_path
of it.
friendly ping @Marwan99 |
Sorry for the radio silence, just picked it back again today. |
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.
This looks good to me.
I think you'd need to address the resulting test failures though as well, mainly the tests within rosbag2_cpp
, but I have seen other packages fail as well, i.e. rosbag2_tests
.
You can verify the tests with colcon test --packages-select-regex rosbag2
.
Thinking a bit more about this, I would assume we have to delete the logic within |
@Karsten1987 ready for review |
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.
Thanks, this looks already quite good. One more round of small comments inline.
@@ -47,6 +47,9 @@ class SequentialWriterTest : public Test | |||
storage_options_ = rosbag2_cpp::StorageOptions{}; | |||
storage_options_.uri = "uri"; | |||
|
|||
rcpputils::fs::path dir(storage_options_.uri); | |||
rcpputils::fs::remove(dir); |
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 actually think that this should be remove_all
in case the directory is not empty.
@@ -559,7 +559,7 @@ TEST_F(RecordFixture, record_fails_gracefully_if_bag_already_exists) { | |||
TEST_F(RecordFixture, record_fails_if_both_all_and_topic_list_is_specified) { | |||
internal::CaptureStderr(); | |||
auto exit_code = | |||
execute_and_wait_until_completion("ros2 bag record -a /some_topic", temporary_dir_path_); | |||
WEXITSTATUS(std::system("ros2 bag record -a /some_topic")); |
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.
why this change? Same below
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.
These tests were failing and that fix gave me a placebo of fixing the root cause, apparently the issue was somewhere else. Double checked local and that is not needed anymore, should be reverted back now.
Just curious, why is the CI not happy with |
the |
@Marwan99 do you mind rebasing your branch on top of master? |
Signed-off-by: Marwan Taher <[email protected]>
Signed-off-by: Marwan Taher <[email protected]>
Signed-off-by: Marwan Taher <[email protected]>
…_compression_writer and refactored dir creation in sequential_writer Signed-off-by: Marwan Taher <[email protected]>
Signed-off-by: Marwan Taher <[email protected]>
Signed-off-by: Marwan Taher <[email protected]>
Sure, just to confirm I will need to force push after rebasing. Is that okay? |
yes! |
9e9db06
to
3529fc2
Compare
rosbag2_compression/src/rosbag2_compression/sequential_compression_writer.cpp
Outdated
Show resolved
Hide resolved
rosbag2_compression/src/rosbag2_compression/sequential_compression_writer.cpp
Outdated
Show resolved
Hide resolved
* added db directory creation to storage factory Signed-off-by: Marwan Taher <[email protected]> * moved db directory creation to rosbag2_cpp Signed-off-by: Marwan Taher <[email protected]> * rasing exception if dir already exists Signed-off-by: Marwan Taher <[email protected]> * removed dir creation from record.py, added dir creation to sequential_compression_writer and refactored dir creation in sequential_writer Signed-off-by: Marwan Taher <[email protected]> * fixed failing tests Signed-off-by: Marwan Taher <[email protected]> * fixing review comments Signed-off-by: Marwan Taher <[email protected]> * Apply suggestions from code review Co-authored-by: Karsten Knese <[email protected]>
* added db directory creation to storage factory Signed-off-by: Marwan Taher <[email protected]> * moved db directory creation to rosbag2_cpp Signed-off-by: Marwan Taher <[email protected]> * rasing exception if dir already exists Signed-off-by: Marwan Taher <[email protected]> * removed dir creation from record.py, added dir creation to sequential_compression_writer and refactored dir creation in sequential_writer Signed-off-by: Marwan Taher <[email protected]> * fixed failing tests Signed-off-by: Marwan Taher <[email protected]> * fixing review comments Signed-off-by: Marwan Taher <[email protected]> * Apply suggestions from code review Co-authored-by: Karsten Knese <[email protected]> Signed-off-by: Emerson Knapp <[email protected]>
per #448
Please let me know if you think this functionality should be implemented elsewhere instead of storage implementation.