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 db directory creation to rosbag2_cpp #450

Merged
merged 7 commits into from
Jul 21, 2020

Conversation

Marwan99
Copy link
Contributor

@Marwan99 Marwan99 commented Jul 1, 2020

per #448

Please let me know if you think this functionality should be implemented elsewhere instead of storage implementation.

@SteveMacenski
Copy link

@Karsten1987 can you review this (if in your domain)? This is blocking some porting efforts and seems relatively small

@Karsten1987
Copy link
Collaborator

thanks a lot for picking this up. However, I think this logic makes more sense within rosbag2_cpp, as we're already dealing with file paths in there and take certain assumptions.

@@ -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()) {
Copy link
Collaborator

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.

Copy link
Contributor Author

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);
Copy link
Collaborator

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.

@Karsten1987
Copy link
Collaborator

friendly ping @Marwan99

@Marwan99
Copy link
Contributor Author

Sorry for the radio silence, just picked it back again today.

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.

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.

rosbag2_cpp/src/rosbag2_cpp/writers/sequential_writer.cpp Outdated Show resolved Hide resolved
@Karsten1987
Copy link
Collaborator

Thinking a bit more about this, I would assume we have to delete the logic within ros2bag here as this would conflict directly with the logic in this PR.

@Marwan99
Copy link
Contributor Author

@Karsten1987 ready for review

@Marwan99 Marwan99 changed the title Adding db directory creation to storage implementation Adding db directory creation to rosbag2_cpp Jul 17, 2020
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.

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);
Copy link
Collaborator

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"));
Copy link
Collaborator

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

Copy link
Contributor Author

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.

@Marwan99
Copy link
Contributor Author

Just curious, why is the CI not happy with rcpputils::fs::remove_all? Is it using a cached or released version of rcpputils?

@Karsten1987
Copy link
Collaborator

Karsten1987 commented Jul 21, 2020

the remove_all functionality is not yet released into rolling. It is present on the current master branches though, so when we trigger CI on ci.ros2.org it won't be failing.

@Karsten1987
Copy link
Collaborator

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

@Karsten1987
Copy link
Collaborator

@Marwan99 do you mind rebasing your branch on top of master?

Signed-off-by: Marwan Taher <marokhaled99@gmail.com>
Signed-off-by: Marwan Taher <marokhaled99@gmail.com>
Signed-off-by: Marwan Taher <marokhaled99@gmail.com>
…_compression_writer and refactored dir creation in sequential_writer

Signed-off-by: Marwan Taher <marokhaled99@gmail.com>
Signed-off-by: Marwan Taher <marokhaled99@gmail.com>
Signed-off-by: Marwan Taher <marokhaled99@gmail.com>
@Marwan99
Copy link
Contributor Author

Sure, just to confirm I will need to force push after rebasing. Is that okay?

@Karsten1987
Copy link
Collaborator

Sure, just to confirm I will need to force push after rebasing. Is that okay?

yes!

@emersonknapp
Copy link
Collaborator

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

@Karsten1987 Karsten1987 merged commit d460c1f into ros2:master Jul 21, 2020
@Marwan99 Marwan99 deleted the db-dir-creation branch July 21, 2020 22:30
emersonknapp pushed a commit that referenced this pull request Feb 2, 2021
* added db directory creation to storage factory

Signed-off-by: Marwan Taher <marokhaled99@gmail.com>

* moved db directory creation to rosbag2_cpp

Signed-off-by: Marwan Taher <marokhaled99@gmail.com>

* rasing exception if dir already exists

Signed-off-by: Marwan Taher <marokhaled99@gmail.com>

* 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 <marokhaled99@gmail.com>

* fixed failing tests

Signed-off-by: Marwan Taher <marokhaled99@gmail.com>

* fixing review comments

Signed-off-by: Marwan Taher <marokhaled99@gmail.com>

* Apply suggestions from code review

Co-authored-by: Karsten Knese <Karsten1987@users.noreply.github.com>
emersonknapp pushed a commit that referenced this pull request Feb 17, 2021
* added db directory creation to storage factory

Signed-off-by: Marwan Taher <marokhaled99@gmail.com>

* moved db directory creation to rosbag2_cpp

Signed-off-by: Marwan Taher <marokhaled99@gmail.com>

* rasing exception if dir already exists

Signed-off-by: Marwan Taher <marokhaled99@gmail.com>

* 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 <marokhaled99@gmail.com>

* fixed failing tests

Signed-off-by: Marwan Taher <marokhaled99@gmail.com>

* fixing review comments

Signed-off-by: Marwan Taher <marokhaled99@gmail.com>

* Apply suggestions from code review

Co-authored-by: Karsten Knese <Karsten1987@users.noreply.github.com>
Signed-off-by: Emerson Knapp <eknapp@amazon.com>
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