Remove rcpputils::fs dependencies in rosbag2 packages#1740
Conversation
6f39829 to
8116b85
Compare
|
@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. |
| /// \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( |
There was a problem hiding this comment.
why you don't use rcpputils::fs::create_temp_directory ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@ahcorde @clalancette The reasons why I wrote my own implementation of the create_temp_directory is the following:
- Because last time when we tried to use
rcpputils::fs::create_temp_directoryalongside with cleanup viastd::filesystem::remove_all, thestd::filesystem::remove_allwas 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 fromrcpputils::fs::create_temp_directory. For some reason, likely becausercpputils::fs::create_temp_directoryinside using platform-dependent function calls, i.e.,_mktemp_s(..)and own implementation forcreate_directories(const path & p)thestd::filesystem::remove_allfails when trying to delete such folder structures. However, if create a temp folder manually or use the temp folder returned by thestd::filesystem::temp_directory_path()without creating a subfolder in it withrcpputils::fs::create_temp_directory, thestd::filesystem::remove_allis not failing. - As far as I understand, it was a motion to deprecate functions from the
rcpputils::fsand use alternatives from thestd::filesystem. - I don't like the idea of usage
std::filesystem::pathwith thercpputils::fs::path. It would be more consistent and more robust to use onlystd::filesystem::path. If we decided to get rid from thercpputils::fslet's do it! We are usingrcpputils::fs::create_temp_directoryonly in two places in the core packages in therosbag2and 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.
There was a problem hiding this comment.
- I don't like the idea of usage
std::filesystem::pathwith thercpputils::fs::path. It would be more consistent and more robust to use onlystd::filesystem::path. If we decided to get rid from thercpputils::fslet's do it! We are usingrcpputils::fs::create_temp_directoryonly in two places in the core packages in therosbag2and 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.
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
@clalancette If CI will pass green I would like to move my implementation of the
create_temp_directoryto thercpputils::fsas is but with the new namecreate_temporary_directoryand deprecate the originalrcpputils::fs::create_temp_directoryeventually.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
@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.
|
Pulls: #1740 |
|
The CI failed on |
|
Update: On the latest ROS 2 issues triage meeting we decided:
|
- 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>
7795660 to
0e7e581
Compare
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
rosbag2_test_common/include/rosbag2_test_common/temporary_directory_fixture.hpp
Outdated
Show resolved
Hide resolved
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
|
Included #1740 and ros2/rcl_logging#117 |
|
https://github.com/Mergifyio backport jazzy |
✅ Backports have been createdDetails
|
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)
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)
rcpputils::fsin all rosbag2 packages.rcpputils::fswill be deprecated soon, and it is advised thatstd::filesystembe used instead.Added own
rosbag2_test_common::create_temp_directory(..)function in replacement of the analog from thercpputils::fssince such functionality doesn't exists in thestd::filesystem.