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

repo cleanup #12

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.so
*.whl

# Generated by Cargo
Expand Down
10 changes: 4 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ members = ["object-store-rs", "pyo3-object_store"]
resolver = "2"

[workspace.package]
# Package version for arro3-*, not for pyo3-arrow
version = "0.4.2"
authors = ["Kyle Barron <[email protected]>"]
authors = ["Kyle Barron <[email protected]>"]
edition = "2021"
homepage = "https://kylebarron.dev/arro3"
repository = "https://github.com/kylebarron/arro3"
homepage = "https://developmentseed.org/object-store-rs"
repository = "https://github.com/developmentseed/object-store-rs"
license = "MIT OR Apache-2.0"
keywords = ["python", "arrow"]
keywords = ["python"]
categories = []
rust-version = "1.75"

Expand Down
100 changes: 99 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,100 @@
# object-store-rs
A Python interface and pyo3 integration to the object-store crate

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.

<!-- For Rust developers looking to add object_store support to their Python packages, refer to pyo3-object_store. -->

- Easy to install with no Python dependencies.
- Full static type hinting
- Full sync and async API
- Helpers for constructing from environment variables and `boto3.Session` objects

Among the included backend are:

- Amazon S3 and S3-compliant APIs like Cloudflare R2
- Google Cloud Storage
- Azure Blob Gen1 and Gen2 accounts (including ADLS Gen2)
- Local filesystem
- In-memory storage



## Installation

```sh
pip install object-store-rs
```

## Comparison to object-store-python

- More maintainable API than object-store-python.
- Fewer classes. Use native Python (typed) dicts and objects where possible.

## Usage

### Constructing a store

For ease of use and accurate validation, there are separate classes for each backend.

TODO: finish doc here

#### Configuration

- Each store concept has their own configuration. This is covered in the docs, and string literals are in the type hints.

### Interacting with a store

All methods for interacting with a store are exported as top-level functions,
such as `get`, `put`, `list`, and `delete`.

```py
import object_store_rs as obs

store = obs.store.MemoryStore()

obs.put_file(store, "file.txt", b"hello world!")
response = obs.get(store, "file.txt")
response.meta
# {'size': 12,
# 'last_modified': datetime.datetime(2024, 10, 18, 4, 8, 12, 57046, tzinfo=datetime.timezone.utc),
# 'version': None,
# 'e_tag': '0',
# 'location': 'file.txt'}

assert response.bytes() == b"hello world!"

byte_range = obs.get_range(store, "file.txt", offset=0, length=5)
assert byte_range == b"hello"

obs.copy(store, "file.txt", "other.txt")
assert obs.get(store, "other.txt").bytes() == b"hello world!"
```

All of these methods also have `async` counterparts, suffixed with `_async`.

```py
import object_store_rs as obs

store = obs.store.MemoryStore()

await obs.put_file_async(store, "file.txt", b"hello world!")
response = await obs.get_async(store, "file.txt")
response.meta
# {
# "last_modified": datetime.datetime(
# 2024, 10, 18, 4, 14, 39, 630310, tzinfo=datetime.timezone.utc
# ),
# "size": 12,
# "location": "file.txt",
# "version": None,
# "e_tag": "0",
# }
assert await response.bytes_async() == b"hello world!"

byte_range = await obs.get_range_async(store, "file.txt", offset=0, length=5)
assert byte_range == b"hello"

await obs.copy_async(store, "file.txt", "other.txt")
resp = await obs.get_async(store, "other.txt")
assert await resp.bytes_async() == b"hello world!"
```
2 changes: 1 addition & 1 deletion object-store-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "object-store-rs"
version = { workspace = true }
version = "0.1.0-beta.1"
authors = { workspace = true }
edition = { workspace = true }
description = "Core library for representing Arrow data in Python."
Expand Down
Binary file not shown.
Binary file not shown.