Skip to content

Remove rcpputils::fs dependencies in rosbag2 packages#1740

Merged
ahcorde merged 3 commits intorollingfrom
morlov/get-rid-from-rcpputils-fs-dependencies
Jul 22, 2024
Merged

Remove rcpputils::fs dependencies in rosbag2 packages#1740
ahcorde merged 3 commits intorollingfrom
morlov/get-rid-from-rcpputils-fs-dependencies

Conversation

@MichaelOrlov
Copy link
Copy Markdown
Contributor

  • This PR removes residual dependencies from the rcpputils::fs in all rosbag2 packages.
  • Rationale: The rcpputils::fs will be deprecated soon, and it is advised that std::filesystem be used instead.

Added own rosbag2_test_common::create_temp_directory(..) function in replacement of the analog from the rcpputils::fs since such functionality doesn't exists in the std::filesystem.

@MichaelOrlov MichaelOrlov force-pushed the morlov/get-rid-from-rcpputils-fs-dependencies branch 2 times, most recently from 6f39829 to 8116b85 Compare July 9, 2024 23:42
@MichaelOrlov MichaelOrlov marked this pull request as ready for review July 9, 2024 23:48
@MichaelOrlov MichaelOrlov requested a review from a team as a code owner July 9, 2024 23:48
@MichaelOrlov MichaelOrlov requested review from gbiggs and hidmic and removed request for a team July 9, 2024 23:48
@MichaelOrlov MichaelOrlov changed the title Remove rcpputils::fs dependencies from rosbag2 packages Remove rcpputils::fs dependencies in rosbag2 packages Jul 9, 2024
@MichaelOrlov MichaelOrlov requested a review from clalancette July 9, 2024 23:49
@r7vme
Copy link
Copy Markdown
Contributor

r7vme commented Jul 10, 2024

@MichaelOrlov I looked thru the code and it looks ok from my side. I remember there were some Windows related problems back, when we tried to do similar change.

Copy link
Copy Markdown
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

Just a question

/// \throws std::system_error If any OS APIs do not succeed.
/// \throws std::runtime_error If the number of the iterations exceeds the maximum tries and
/// a unique directory is not found.
std::filesystem::path create_temp_directory(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why you don't use rcpputils::fs::create_temp_directory ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, I think we should switch to using the rcpputils::fs::create_temp_directory here. If there are still problems with it, then we should fix them over in rcpputils.

Copy link
Copy Markdown
Contributor Author

@MichaelOrlov MichaelOrlov Jul 10, 2024

Choose a reason for hiding this comment

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

@ahcorde @clalancette The reasons why I wrote my own implementation of the create_temp_directory is the following:

  1. Because last time when we tried to use rcpputils::fs::create_temp_directory alongside with cleanup via std::filesystem::remove_all, the std::filesystem::remove_all was failing on Windows and also caused some test failures. See Use std::filesystem instead of rcpputils::fs #1576 (comment) and Use std::filesystem instead of rcpputils::fs #1576 (review) for details.
    I have tried to triage this problem on Windows. It turns out that in failing tests the rosbag2 creating subfolder with files in the temporary created folder from rcpputils::fs::create_temp_directory. For some reason, likely because rcpputils::fs::create_temp_directory inside using platform-dependent function calls, i.e., _mktemp_s(..) and own implementation for create_directories(const path & p) the std::filesystem::remove_all fails when trying to delete such folder structures. However, if create a temp folder manually or use the temp folder returned by the std::filesystem::temp_directory_path() without creating a subfolder in it with rcpputils::fs::create_temp_directory, the std::filesystem::remove_all is not failing.
  2. As far as I understand, it was a motion to deprecate functions from the rcpputils::fs and use alternatives from the std::filesystem.
  3. I don't like the idea of usage std::filesystem::path with the rcpputils::fs::path. It would be more consistent and more robust to use only std::filesystem::path. If we decided to get rid from the rcpputils::fs let's do it! We are using rcpputils::fs::create_temp_directory only in two places in the core packages in the rosbag2 and in tests for the rcl_logging_spdlog.

Let's see how Windows CI will pass. If it will pass without failures, I don't mind to move my rosbag2_test_common::create_temp_directory(..) to the rcpputils::fs namespace.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • I don't like the idea of usage std::filesystem::path with the rcpputils::fs::path. It would be more consistent and more robust to use only std::filesystem::path. If we decided to get rid from the rcpputils::fs let's do it! We are using rcpputils::fs::create_temp_directory only in two places in the core packages in the rosbag2 and in tests for the rcl_logging_spdlog.

Yes, we are actively doing this right now in ros2/rcpputils#197 and ros2/rcpputils#196 . That said, std::filesystem doesn't have any equivalent to rcpputils::fs::create_temp_directory, so we are going to have to carry around that function indefinitely.

Copy link
Copy Markdown
Contributor Author

@MichaelOrlov MichaelOrlov Jul 10, 2024

Choose a reason for hiding this comment

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

@clalancette If CI will pass green I would like to move my implementation of the create_temp_directory to the rcpputils::fs as is but with the new name create_temporary_directory and deprecate the original rcpputils::fs::create_temp_directory eventually.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@clalancette If CI will pass green I would like to move my implementation of the create_temp_directory to the rcpputils::fs as is but with the new name create_temporary_directory and deprecate the original rcpputils::fs::create_temp_directory eventually.

I don't think we should do that. We are currently in the process of breaking the API for create_temp_directory anyway, so I think we should do this all at the same time. Please take a look at ros2/rcpputils#197 and give feedback on what we think the API should be.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

BTW. The implementation in the https://github.com/ros2/rcpputils/pull/197/files has API-breaking changes and still uses platform-dependent code, which is not good.
Creating a new function with a different name and deprecating the old one would be better.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

BTW. The implementation in the https://github.com/ros2/rcpputils/pull/197/files has API-breaking changes and still uses platform-dependent code, which is not good.

Yes, it has API-breaking changes. See the discussion in ros2/rcpputils#196 (review) about why we decided to do that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@clalancette I see. However, I still don't like the idea of doing API-breaking changes, which is require to merge 3 PRs in synch.
Why not do it sequentially by creating a new function with create_temporary_directory name?
I've tried to look out, and it seems this name is not occupied in the ROS 2 core packages.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@clalancette FYI In Apex.AI, when we are doing synch with upstream ROS 2 by pulling PRs each time, such breaking changes, which require merging multiple PRs in different packages in synch, is a nightmare since it is breaking our CI.

We would be grateful if such breaking changes will be as minimum as possible.

@MichaelOrlov
Copy link
Copy Markdown
Contributor Author

Pulls: #1740
Gist: https://gist.githubusercontent.com/MichaelOrlov/57ea65444857fed55ac99b2bdb80c0a1/raw/c8524ce3ec5433097215036dbc53c6c6f6aaea97/ros2.repos
BUILD args: --packages-above-and-dependencies rosbag2_cpp rosbag2_storage rosbag2_transport rosbag2_test_common rosbag2_tests
TEST args: --packages-above rosbag2_cpp rosbag2_storage rosbag2_transport rosbag2_test_common rosbag2_tests
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/14211

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@MichaelOrlov
Copy link
Copy Markdown
Contributor Author

The CI failed on rosbag2_storage_sqlite3.test_sqlite_storage. It looks like a failure in the test's destructor. It could be related to the failure in the std::filesystem::remove_all. I will try to reproduce it locally and rerun Windows CI.

@MichaelOrlov
Copy link
Copy Markdown
Contributor Author

Re-run Windows CI

  • Windows Build Status

@MichaelOrlov
Copy link
Copy Markdown
Contributor Author

Re-run Windows CI after attempting to fix test failure.

  • Windows Build Status

@MichaelOrlov MichaelOrlov marked this pull request as draft July 12, 2024 02:35
@MichaelOrlov MichaelOrlov changed the title Remove rcpputils::fs dependencies in rosbag2 packages [WIP] Remove rcpputils::fs dependencies in rosbag2 packages Jul 12, 2024
@MichaelOrlov
Copy link
Copy Markdown
Contributor Author

MichaelOrlov commented Jul 12, 2024

Update: On the latest ROS 2 issues triage meeting we decided:

  1. Move implementation of the newly added rosbag2_test_common::create_temp_directory(..) function to the rcpputils::fs with the new name create_temporary_directory(..). Will be done in the Replace create_temp_directory with the new create_temporary_directory rcpputils#198
  2. Deprecate rcpputils::fs::create_temp_directory(..) and rcpputils::fs::temp_directory_path()
  3. Move fix for the failing throws_on_invalid_pragma_in_config_file test to the separate PR. Will be handled in the Fix for failing throws_on_invalid_pragma_in_config_file test on Windows #1742
  4. Get back to this PR when Fix for failing throws_on_invalid_pragma_in_config_file test on Windows #1742 and Replace create_temp_directory with the new create_temporary_directory rcpputils#198 will be merged.

- Added own rosbag2_test_common::create_temp_directory(..) function in
replacement of the analog from the rcpputils::fs.

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
@MichaelOrlov MichaelOrlov force-pushed the morlov/get-rid-from-rcpputils-fs-dependencies branch from 7795660 to 0e7e581 Compare July 16, 2024 15:31
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
@ahcorde
Copy link
Copy Markdown
Contributor

ahcorde commented Jul 22, 2024

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

Included #1740 and ros2/rcl_logging#117

@ahcorde ahcorde marked this pull request as ready for review July 22, 2024 08:31
@ahcorde ahcorde merged commit 7a01d78 into rolling Jul 22, 2024
@ahcorde ahcorde deleted the morlov/get-rid-from-rcpputils-fs-dependencies branch July 22, 2024 08:32
@MichaelOrlov MichaelOrlov changed the title [WIP] Remove rcpputils::fs dependencies in rosbag2 packages Remove rcpputils::fs dependencies in rosbag2 packages Jul 22, 2024
@MichaelOrlov
Copy link
Copy Markdown
Contributor Author

https://github.com/Mergifyio backport jazzy

@mergify
Copy link
Copy Markdown

mergify bot commented Aug 9, 2024

backport jazzy

✅ Backports have been created

Details

mergify bot pushed a commit that referenced this pull request Aug 9, 2024
Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
(cherry picked from commit 7a01d78)
MichaelOrlov pushed a commit that referenced this pull request Apr 26, 2025
Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
(cherry picked from commit 7a01d78)
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.

5 participants