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

Revert auto_mkdir default in open() and special case local #1365

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Changes from all commits
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
9 changes: 9 additions & 0 deletions fsspec/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def open_files(
num=1,
protocol=None,
newline=None,
auto_mkdir=True,
expand=True,
**kwargs,
):
Expand Down Expand Up @@ -248,6 +249,9 @@ def open_files(
newline: bytes or None
Used for line terminator in text mode. If None, uses system default;
if blank, uses no translation.
auto_mkdir: bool (True)
If in write mode, this will ensure the target directory exists before
writing, by calling ``fs.mkdirs(exist_ok=True)``.
expand: bool
**kwargs: dict
Extra options that make sense to a particular storage connection, e.g.
Expand Down Expand Up @@ -284,6 +288,11 @@ def open_files(
protocol=protocol,
expand=expand,
)
if fs.protocol == "file":
fs.auto_mkdir = auto_mkdir
Copy link
Member Author

Choose a reason for hiding this comment

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

I do not see an easier way to do this than this fragile line, because the creation of the fs is hidden within the unchaining logic inside the call above.

elif "r" not in mode and auto_mkdir:
parents = {fs._parent(path) for path in paths}
[fs.makedirs(parent, exist_ok=True) for parent in parents]
return OpenFiles(
[
OpenFile(
Expand Down