8000 [2/N] Use std::filesystem by cyyever · Pull Request #152586 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[2/N] Use std::filesystem #152586

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve fs::create_directories check
  • Loading branch information
cyyever committed May 7, 2025
commit 15352ccbe3cce7e3b1878def81d06167d6acfe9e
4 changes: 2 additions & 2 deletions torch/csrc/distributed/c10d/UCCTracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ void ProcessGroupUCCLogger::flushComms(int rank, int world_size) {
std::filesystem::path trace_filename =
fullpath / fmt::format("rank{}.json", rank);
std::error_code ec{};
std::filesystem::create_directories(fullpath, ec);
if (!std::filesystem::is_directory(fullpath)) {
if (!std::filesystem::create_directories(fullpath, ec) &&
!std::filesystem::is_directory(fullpath)) {
LOG(INFO) << getLogPrefix() << "[INFO] failed to mkdir " << fullpath
<< " with error " << ec.message();
return;
Expand Down
4 changes: 2 additions & 2 deletions torch/csrc/inductor/aoti_torch/shim_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1094,8 +1094,8 @@ void aoti_torch_save_tensor_handle(
<< tmp_folder << '\n';

std::error_code ec{};
std::filesystem::create_directories(tmp_folder, ec);
if (!std::filesystem::is_directory(tmp_folder)) {
if (std::filesystem::create_directories(tmp_folder, ec) &&
!std::filesystem::is_directory(tmp_folder)) {
std::cout << "aoti_torch_save_tensor_handle: Error creating directory: "
<< tmp_folder << " error:" << ec.message() << '\n';
return;
Expand Down
0