Skip to content

Commit 922b58f

Browse files
authored
repo cleanup (developmentseed#12)
1 parent 3920627 commit 922b58f

File tree

6 files changed

+105
-8
lines changed

6 files changed

+105
-8
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
*.so
12
*.whl
23

34
# Generated by Cargo

Cargo.toml

+4-6
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ members = ["object-store-rs", "pyo3-object_store"]
33
resolver = "2"
44

55
[workspace.package]
6-
# Package version for arro3-*, not for pyo3-arrow
7-
version = "0.4.2"
8-
authors = ["Kyle Barron <[email protected]>"]
6+
authors = ["Kyle Barron <[email protected]>"]
97
edition = "2021"
10-
homepage = "https://kylebarron.dev/arro3"
11-
repository = "https://github.com/kylebarron/arro3"
8+
homepage = "https://developmentseed.org/object-store-rs"
9+
repository = "https://github.com/developmentseed/object-store-rs"
1210
license = "MIT OR Apache-2.0"
13-
keywords = ["python", "arrow"]
11+
keywords = ["python"]
1412
categories = []
1513
rust-version = "1.75"
1614

README.md

+99-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,100 @@
11
# object-store-rs
2-
A Python interface and pyo3 integration to the object-store crate
2+
3+
A Python interface and pyo3 integration to the Rust [`object_store`](https://docs.rs/object_store/latest/object_store/) crate. This crate provides a uniform API for interacting with object storage services and local files. Using this library, the same code can run in multiple clouds and local test environments, via a simple runtime configuration change.
4+
5+
<!-- For Rust developers looking to add object_store support to their Python packages, refer to pyo3-object_store. -->
6+
7+
- Easy to install with no Python dependencies.
8+
- Full static type hinting
9+
- Full sync and async API
10+
- Helpers for constructing from environment variables and `boto3.Session` objects
11+
12+
Among the included backend are:
13+
14+
- Amazon S3 and S3-compliant APIs like Cloudflare R2
15+
- Google Cloud Storage
16+
- Azure Blob Gen1 and Gen2 accounts (including ADLS Gen2)
17+
- Local filesystem
18+
- In-memory storage
19+
20+
21+
22+
## Installation
23+
24+
```sh
25+
pip install object-store-rs
26+
```
27+
28+
## Comparison to object-store-python
29+
30+
- More maintainable API than object-store-python.
31+
- Fewer classes. Use native Python (typed) dicts and objects where possible.
32+
33+
## Usage
34+
35+
### Constructing a store
36+
37+
For ease of use and accurate validation, there are separate classes for each backend.
38+
39+
TODO: finish doc here
40+
41+
#### Configuration
42+
43+
- Each store concept has their own configuration. This is covered in the docs, and string literals are in the type hints.
44+
45+
### Interacting with a store
46+
47+
All methods for interacting with a store are exported as top-level functions,
48+
such as `get`, `put`, `list`, and `delete`.
49+
50+
```py
51+
import object_store_rs as obs
52+
53+
store = obs.store.MemoryStore()
54+
55+
obs.put_file(store, "file.txt", b"hello world!")
56+
response = obs.get(store, "file.txt")
57+
response.meta
58+
# {'size': 12,
59+
# 'last_modified': datetime.datetime(2024, 10, 18, 4, 8, 12, 57046, tzinfo=datetime.timezone.utc),
60+
# 'version': None,
61+
# 'e_tag': '0',
62+
# 'location': 'file.txt'}
63+
64+
assert response.bytes() == b"hello world!"
65+
66+
byte_range = obs.get_range(store, "file.txt", offset=0, length=5)
67+
assert byte_range == b"hello"
68+
69+
obs.copy(store, "file.txt", "other.txt")
70+
assert obs.get(store, "other.txt").bytes() == b"hello world!"
71+
```
72+
73+
All of these methods also have `async` counterparts, suffixed with `_async`.
74+
75+
```py
76+
import object_store_rs as obs
77+
78+
store = obs.store.MemoryStore()
79+
80+
await obs.put_file_async(store, "file.txt", b"hello world!")
81+
response = await obs.get_async(store, "file.txt")
82+
response.meta
83+
# {
84+
# "last_modified": datetime.datetime(
85+
# 2024, 10, 18, 4, 14, 39, 630310, tzinfo=datetime.timezone.utc
86+
# ),
87+
# "size": 12,
88+
# "location": "file.txt",
89+
# "version": None,
90+
# "e_tag": "0",
91+
# }
92+
assert await response.bytes_async() == b"hello world!"
93+
94+
byte_range = await obs.get_range_async(store, "file.txt", offset=0, length=5)
95+
assert byte_range == b"hello"
96+
97+
await obs.copy_async(store, "file.txt", "other.txt")
98+
resp = await obs.get_async(store, "other.txt")
99+
assert await resp.bytes_async() == b"hello world!"
100+
```

object-store-rs/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "object-store-rs"
3-
version = { workspace = true }
3+
version = "0.1.0-beta.1"
44
authors = { workspace = true }
55
edition = { workspace = true }
66
description = "Core library for representing Arrow data in Python."
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)