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

Provide more informative error messages for obs.put_async with incorrect "mode" #281

Open
maxrjones opened this issue Feb 26, 2025 · 4 comments
Milestone

Comments

@maxrjones
Copy link
Member

We noticed in the Obstore <-> Zarr-Python integration that using obs.put_async(self.store, key, buf, mode="create") raises a NotImplementedError. A different error type would make it more clear to the user that "create" needs to be "Create" (notice capitalization) (e.g., kylebarron/zarr-python#16).

@kylebarron
Copy link
Member

Hmm I'm not sure what you're seeing. Any capitalization should work:

let s = s.to_ascii_lowercase();
match s.as_str() {
"create" => Ok(Self(PutMode::Create)),
"overwrite" => Ok(Self(PutMode::Overwrite)),

@kylebarron
Copy link
Member

The underlying object_store::error::NotImplemented error gets returned as a Python builtin NotImplementedError:

object_store::Error::NotImplemented => {
PyNotImplementedError::new_err(format!("{err:#?}"))
}

So what you're probably seeing is an error thrown by object_store

@kylebarron
Copy link
Member

Your error is coming from here: https://github.com/apache/arrow-rs/blob/b666e424e8f395e9a9bb9950ffab1f968312e103/object_store/src/aws/mod.rs#L172

This is because S3 just added conditional puts recently, and it's not yet the default behavior.
It will be in the next release apache/arrow-rs#7181, which will also remove this NotImplemented case: https://github.com/apache/arrow-rs/pull/7181/files#diff-463799e28d6cd175bcf4dd2b296385646ebed96271da65b05a02ab133d31c82cR172

For now, I think you have to explicitly opt-in when you create the S3Store
https://developmentseed.org/obstore/latest/api/store/aws/#obstore.store.S3ConfigInput.conditional_put

You need to set conditional_put="etag" I believe.

@maxrjones
Copy link
Member Author

https://github.com/maxrjones/zarr-obstore-performance/blob/main/notebooks/zarr-obstore-write.ipynb shows the error. I wasn't able to quickly make a simpler example with just Zarr (rather than xarray + zarr), I guess Zarr's arr[:] = set syntax must use set rather than set_if_not_exists.

I won't have time for more debugging until Friday, but I could rerun the test notebook with any changes to see if it works.

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

No branches or pull requests

2 participants