Replace boost::filesystem with std::filesystem (#27522)

This redos #27319

Signed-off-by: Jiajun Yao <jeromeyjj@gmail.com>
This commit is contained in:
Jiajun Yao 2022-08-04 21:33:51 -07:00 committed by GitHub
parent 1714d0266b
commit d7dcb1f938
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 32 additions and 37 deletions

View file

@ -676,7 +676,6 @@ cc_library(
":stats_lib",
"//src/ray/protobuf:common_cc_proto",
"@boost//:asio",
"@boost//:filesystem",
"@boost//:system",
"@com_github_jupp0r_prometheus_cpp//pull",
"@com_google_absl//absl/base:core_headers",
@ -738,7 +737,6 @@ cc_library(
":worker_rpc",
"//src/ray/protobuf:common_cc_proto",
"@boost//:asio",
"@boost//:filesystem",
"@boost//:system",
"@com_github_jupp0r_prometheus_cpp//pull",
"@com_google_absl//absl/base:core_headers",
@ -1275,7 +1273,6 @@ cc_test(
tags = ["team:core"],
deps = [
":plasma_store_server_lib",
"@boost//:filesystem",
"@com_google_absl//absl/strings:str_format",
"@com_google_googletest//:gtest_main",
],
@ -1449,7 +1446,6 @@ cc_test(
tags = ["team:core"],
deps = [
":ray_util",
"@boost//:filesystem",
"@boost//:range",
"@com_google_googletest//:gtest_main",
],
@ -2230,7 +2226,6 @@ cc_library(
":sha256",
"//src/ray/protobuf:event_cc_proto",
"@boost//:asio",
"@boost//:filesystem",
"@com_github_spdlog//:spdlog",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/debugging:failure_signal_handler",

View file

@ -177,7 +177,6 @@ cc_test(
tags = ["team:core"],
deps = [
"ray_api",
"@boost//:filesystem",
"@com_google_googletest//:gtest_main",
],
)

View file

@ -16,6 +16,7 @@
#include <boost/dll/runtime_symbol_info.hpp>
#include <charconv>
#include <filesystem>
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
@ -195,7 +196,7 @@ void ConfigInternal::Init(RayConfig &config, int argc, char **argv) {
// driver.
std::vector<std::string> absolute_path;
for (const auto &path : code_search_path) {
absolute_path.emplace_back(boost::filesystem::absolute(path).string());
absolute_path.emplace_back(std::filesystem::absolute(path).string());
}
code_search_path = absolute_path;
}

View file

@ -15,11 +15,12 @@
#include <gtest/gtest.h>
#include <ray/api.h>
#include <filesystem>
#include <fstream>
#include <future>
#include <thread>
#include "../config_internal.h"
#include "boost/filesystem.hpp"
#include "ray/util/logging.h"
// using namespace ray;
@ -109,7 +110,7 @@ RAY_REMOTE(Counter::FactoryCreate,
&Counter::GetList);
TEST(RayApiTest, LogTest) {
auto log_path = boost::filesystem::current_path().string() + "/tmp/";
auto log_path = std::filesystem::current_path().string() + "/tmp/";
ray::RayLog::StartRayLog("cpp_worker", ray::RayLogLevel::DEBUG, log_path);
std::array<std::string, 3> str_arr{"debug test", "info test", "warning test"};
RAYLOG(DEBUG) << str_arr[0];
@ -117,8 +118,8 @@ TEST(RayApiTest, LogTest) {
RAYLOG(WARNING) << str_arr[2];
RAY_CHECK(true);
for (auto &it : boost::filesystem::directory_iterator(log_path)) {
if (!boost::filesystem::is_directory(it)) {
for (auto &it : std::filesystem::directory_iterator(log_path)) {
if (!std::filesystem::is_directory(it)) {
std::ifstream in(it.path().string(), std::ios::binary);
std::string line;
for (int i = 0; i < 3; i++) {
@ -128,7 +129,7 @@ TEST(RayApiTest, LogTest) {
}
}
boost::filesystem::remove_all(log_path);
std::filesystem::remove_all(log_path);
}
TEST(RayApiTest, TaskOptionsCheckTest) {

View file

@ -14,7 +14,6 @@
#include "function_helper.h"
#include <boost/filesystem.hpp>
#include <boost/range/iterator_range.hpp>
#include <memory>
@ -23,7 +22,7 @@
namespace ray {
namespace internal {
void FunctionHelper::LoadDll(const boost::filesystem::path &lib_path) {
void FunctionHelper::LoadDll(const std::filesystem::path &lib_path) {
RAY_LOG(INFO) << "Start loading the library " << lib_path << ".";
auto it = libraries_.find(lib_path.string());
@ -31,7 +30,7 @@ void FunctionHelper::LoadDll(const boost::filesystem::path &lib_path) {
return;
}
RAY_CHECK(boost::filesystem::exists(lib_path))
RAY_CHECK(std::filesystem::exists(lib_path))
<< lib_path << " dynamic library not found.";
std::shared_ptr<boost::dll::shared_library> lib = nullptr;
@ -119,8 +118,8 @@ std::string FunctionHelper::LoadAllRemoteFunctions(const std::string lib_path,
return names_str;
}
void FindDynamicLibrary(boost::filesystem::path path,
std::list<boost::filesystem::path> &dynamic_libraries) {
void FindDynamicLibrary(std::filesystem::path path,
std::list<std::filesystem::path> &dynamic_libraries) {
#if defined(_WIN32)
static const std::unordered_set<std::string> dynamic_library_extension = {".dll"};
#elif __APPLE__
@ -129,22 +128,23 @@ void FindDynamicLibrary(boost::filesystem::path path,
#else
static const std::unordered_set<std::string> dynamic_library_extension = {".so"};
#endif
auto extension = boost::filesystem::extension(path);
if (dynamic_library_extension.find(extension) != dynamic_library_extension.end()) {
auto extension = path.extension();
if (dynamic_library_extension.find(extension.string()) !=
dynamic_library_extension.end()) {
dynamic_libraries.emplace_back(path);
}
}
void FunctionHelper::LoadFunctionsFromPaths(const std::vector<std::string> &paths) {
std::list<boost::filesystem::path> dynamic_libraries;
std::list<std::filesystem::path> dynamic_libraries;
// Lookup dynamic libraries from paths.
for (auto path : paths) {
if (boost::filesystem::is_directory(path)) {
if (std::filesystem::is_directory(path)) {
for (auto &entry :
boost::make_iterator_range(boost::filesystem::directory_iterator(path), {})) {
boost::make_iterator_range(std::filesystem::directory_iterator(path), {})) {
FindDynamicLibrary(entry, dynamic_libraries);
}
} else if (boost::filesystem::exists(path)) {
} else if (std::filesystem::exists(path)) {
FindDynamicLibrary(path, dynamic_libraries);
} else {
RAY_LOG(FATAL) << path << " dynamic library not found.";

View file

@ -18,6 +18,7 @@
#include <ray/api/ray_runtime_holder.h>
#include <boost/dll.hpp>
#include <filesystem>
#include <memory>
#include <msgpack.hpp>
#include <string>
@ -41,7 +42,7 @@ class FunctionHelper {
return *instance;
}
void LoadDll(const boost::filesystem::path &lib_path);
void LoadDll(const std::filesystem::path &lib_path);
void LoadFunctionsFromPaths(const std::vector<std::string> &paths);
const EntryFuntion &GetExecutableFunctions(const std::string &function_name);
const EntryFuntion &GetExecutableMemberFunctions(const std::string &function_name);

View file

@ -16,8 +16,6 @@
#include <gtest/gtest_prod.h>
#include <boost/filesystem.hpp>
#include "ray/common/asio/instrumented_io_context.h"
#include "ray/common/asio/periodical_runner.h"

View file

@ -12,18 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <boost/filesystem.hpp>
#include <filesystem>
#include "gtest/gtest.h"
#include "ray/object_manager/plasma/plasma_allocator.h"
using namespace boost::filesystem;
using namespace std::filesystem;
namespace plasma {
namespace {
const int64_t kMB = 1024 * 1024;
std::string CreateTestDir() {
path directory = temp_directory_path() / unique_path();
path directory = std::filesystem::temp_directory_path() / GenerateUUIDV4();
create_directories(directory);
return directory.string();
}

View file

@ -16,11 +16,11 @@
#include <cctype>
#include <csignal>
#include <filesystem>
#include <fstream>
#include <memory>
#include "absl/time/clock.h"
#include "boost/filesystem.hpp"
#include "boost/system/error_code.hpp"
#include "ray/common/asio/asio_util.h"
#include "ray/common/asio/instrumented_io_context.h"

View file

@ -16,7 +16,7 @@
#include <algorithm>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/filesystem.hpp>
#include <fstream>
#include "ray/common/constants.h"
#include "ray/common/network_util.h"

View file

@ -14,7 +14,7 @@
#include "ray/util/event.h"
#include <boost/filesystem.hpp>
#include <filesystem>
#include "absl/base/call_once.h"
#include "absl/time/time.h"
@ -325,7 +325,7 @@ void RayEventInit(rpc::Event_SourceType source_type,
const std::string &event_level) {
absl::call_once(init_once_, [&source_type, &custom_fields, &log_dir, &event_level]() {
RayEventContext::Instance().SetEventContext(source_type, custom_fields);
auto event_dir = boost::filesystem::path(log_dir) / boost::filesystem::path("events");
auto event_dir = std::filesystem::path(log_dir) / std::filesystem::path("events");
ray::EventManager::Instance().AddReporter(
std::make_shared<ray::LogEventReporter>(source_type, event_dir.string()));
SetEventLevel(event_level);

View file

@ -14,9 +14,9 @@
#include "ray/util/event.h"
#include <boost/filesystem.hpp>
#include <boost/range.hpp>
#include <csignal>
#include <filesystem>
#include <fstream>
#include <set>
#include <thread>
@ -177,7 +177,7 @@ class EventTest : public ::testing::Test {
virtual void TearDown() {
TestEventReporter::event_list.clear();
boost::filesystem::remove_all(log_dir.c_str());
std::filesystem::remove_all(log_dir.c_str());
EventManager::Instance().ClearReporters();
ray::RayEventContext::Instance().ResetEventContext();
}
@ -424,7 +424,7 @@ TEST_F(EventTest, TestLogRotate) {
int cnt = 0;
for (auto &entry :
boost::make_iterator_range(boost::filesystem::directory_iterator(log_dir), {})) {
boost::make_iterator_range(std::filesystem::directory_iterator(log_dir), {})) {
if (entry.path().string().find("event_RAYLET") != std::string::npos) {
cnt++;
}
@ -607,7 +607,7 @@ TEST_F(EventTest, TestLogEvent) {
EXPECT_THAT(vc[1], testing::HasSubstr("Event"));
EXPECT_THAT(vc[1], testing::HasSubstr("test fatal"));
boost::filesystem::remove_all(log_dir.c_str());
std::filesystem::remove_all(log_dir.c_str());
// Set log level smaller than event level.
ray::RayLog::StartRayLog("event_test", ray::RayLogLevel::INFO, log_dir);