Skip to content

Commit

Permalink
Fix pickle for local and http store (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron authored Feb 5, 2025
1 parent 12551fd commit da1a565
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion obstore/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "obstore"
version = "0.4.0-beta.3"
version = "0.4.0-beta.4"
authors = { workspace = true }
edition = { workspace = true }
description = "The simplest, highest-throughput interface to Amazon S3, Google Cloud Storage, Azure Blob Storage, and S3-compliant APIs like Cloudflare R2."
Expand Down
2 changes: 1 addition & 1 deletion pyo3-object_store/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl HTTPConfig {
}

/// A Python-facing wrapper around a [`HttpStore`].
#[pyclass(name = "HTTPStore", frozen)]
#[pyclass(name = "HTTPStore", module = "obstore.store", frozen)]
pub struct PyHttpStore {
// Note: we don't need to wrap this in a MaybePrefixedStore because the HttpStore manages its
// own prefix.
Expand Down
2 changes: 1 addition & 1 deletion pyo3-object_store/src/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl LocalConfig {
}

/// A Python-facing wrapper around a [`LocalFileSystem`].
#[pyclass(name = "LocalStore", frozen)]
#[pyclass(name = "LocalStore", module = "obstore.store", frozen)]
pub struct PyLocalStore {
store: Arc<LocalFileSystem>,
config: LocalConfig,
Expand Down
9 changes: 9 additions & 0 deletions tests/store/test_http.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pickle

from obstore.store import HTTPStore


def test_pickle():
store = HTTPStore.from_url("https://example.com")
new_store: HTTPStore = pickle.loads(pickle.dumps(store))
assert store.url == new_store.url
9 changes: 9 additions & 0 deletions tests/store/test_local.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pickle
import tempfile
from pathlib import Path

Expand Down Expand Up @@ -63,3 +64,11 @@ def test_prefix_property():
assert isinstance(store.prefix, Path)
# Can pass it back to the store init
LocalStore(store.prefix)


def test_pickle():
tmpdir = Path(tempfile.gettempdir())
store = LocalStore(tmpdir)
obs.put(store, "path.txt", b"foo")
new_store: LocalStore = pickle.loads(pickle.dumps(store))
assert obs.get(new_store, "path.txt").bytes() == b"foo"
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit da1a565

Please sign in to comment.