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

Create directory specified by prefix for LocalStore if it does not exist #158

Closed
maxrjones opened this issue Jan 17, 2025 · 2 comments · Fixed by #177
Closed

Create directory specified by prefix for LocalStore if it does not exist #158

maxrjones opened this issue Jan 17, 2025 · 2 comments · Fixed by #177
Milestone

Comments

@maxrjones
Copy link
Member

It would be useful to provide a LocalStore __init__ parameter that creates the prefix directory if it does not exist. This is particularly important for using obstore with Zarr, since users will often want to create a new store. The current behavior returns a generic error, e.g.,

import os
from obstore.store import LocalStore
cwd = os.getcwd()
m = LocalStore(prefix=f"{cwd}/data/example.zarr")
GenericError: Generic {
    store: "LocalFileSystem",
    source: UnableToCanonicalize {
        path: "/Users/max/Documents/Code/maxrjones/zarr-obstore-performance/data/example.zarr",
        source: Os {
            code: 2,
            kind: NotFound,
            message: "No such file or directory",
        },
    },
}
@kylebarron
Copy link
Member

I'm curious whether a put operation will automatically create intermediate directories? I.e.

store = LocalStore("/root/dir")
obs.put(store, path="/dir1/dir2/item.txt")

Hopefully that will automatically create /root/dir/dir1/dir2/.

It would be nice to create the directory specified by prefix, but we need to ensure that we're able to parse the path input in exactly the same way by Python and Rust. Perhaps that means we should coerce to a pathlib.Path, canonicalize it, call Path.mkdir(exist_ok=True, parents=True), and then pass that pre-canonicalized path to object_store::LocalStore.

@kylebarron kylebarron added this to the 0.4.0 milestone Jan 28, 2025
@kylebarron
Copy link
Member

kylebarron commented Jan 29, 2025

I'm curious whether a put operation will automatically create intermediate directories?

From apache/arrow-rs#7030

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 a pull request may close this issue.

2 participants