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

wip: add put_opts & put_multipart #14

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
21 changes: 20 additions & 1 deletion object-store/python/object_store/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# of static code checkers. Thus we avoid listing them with __all__ = ...
from ._internal import ClientOptions as ClientOptions
from ._internal import ListResult as ListResult
from ._internal import PutResult as PutResult
from ._internal import MultipartUpload as MultipartUpload
from ._internal import ObjectMeta as ObjectMeta
from ._internal import ObjectStore as _ObjectStore
from ._internal import Path as Path
Expand Down Expand Up @@ -80,7 +82,7 @@ def get_range(self, location: PathLike, start: int, length: int) -> bytes:
"""
return super().get_range(_as_path(location), start, length)

def put(self, location: PathLike, bytes: BytesLike) -> None:
def put(self, location: PathLike, bytes: BytesLike) -> PutResult:
"""Save the provided bytes to the specified location.

Args:
Expand All @@ -89,6 +91,23 @@ def put(self, location: PathLike, bytes: BytesLike) -> None:
"""
return super().put(_as_path(location), _as_bytes(bytes))

def put_opts(self, location: PathLike, bytes: BytesLike) -> PutResult:
"""Save the provided bytes to the specified location with the given options

Args:
location (PathLike): path / key to storage location
bytes (BytesLike): data to be written to location
"""
return super().put_opts(_as_path(location), _as_bytes(bytes))

def put_multipart(self, location: PathLike) -> MultipartUpload:
"""Perform a multipart upload

Args:
location (PathLike): path / key to storage location
"""
return super().put_multipart(_as_path(location))

def delete(self, location: PathLike) -> None:
"""Delete the object at the specified location.

Expand Down
28 changes: 27 additions & 1 deletion object-store/python/object_store/_internal.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,28 @@ class ListResult:
def objects(self) -> list[ObjectMeta]:
"""Object metadata for the listing"""

class PutResult:
"""TODO..."""

# @property
# def common_prefixes(self) -> list[Path]:
# """Prefixes that are common (like directories)"""
# @property
# def objects(self) -> list[ObjectMeta]:
# """Object metadata for the listing"""
pass

class MultipartUpload:
"""TODO..."""

# @property
# def common_prefixes(self) -> list[Path]:
# """Prefixes that are common (like directories)"""
# @property
# def objects(self) -> list[ObjectMeta]:
# """Object metadata for the listing"""
pass

class ClientOptions:
"""HTTP client configuration for remote object stores"""

Expand Down Expand Up @@ -133,8 +155,12 @@ class ObjectStore:
"""Return the bytes that are stored at the specified location."""
def get_range(self, location: Path, start: int, length: int) -> bytes:
"""Return the bytes that are stored at the specified location in the given byte range."""
def put(self, location: Path, bytes: bytes) -> None:
def put(self, location: Path, bytes: bytes) -> PutResult:
"""Save the provided bytes to the specified location."""
def put_opts(self, location: Path, bytes: bytes) -> PutResult:
"""Save the provided bytes to the specified location with the given options"""
def put_multipart(self, location: Path) -> MultipartUpload:
"""Perform a multipart upload"""
def list(self, prefix: Path | None) -> list[ObjectMeta]:
"""List all the objects with the given prefix.

Expand Down