From 684b03893923e4064d89a6ba269110a4a0b159bc Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Wed, 21 May 2025 18:34:03 -0400 Subject: [PATCH] Remove references to obstore --- pyproject.toml | 10 +++--- src/obspec/_exceptions.py | 64 --------------------------------------- src/obspec/_list.py | 24 +++++++-------- src/obspec/_put.py | 19 ++++++++---- 4 files changed, 30 insertions(+), 87 deletions(-) delete mode 100644 src/obspec/_exceptions.py diff --git a/pyproject.toml b/pyproject.toml index dd607b7..38a398d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,11 +17,11 @@ classifiers = [ ] [project.urls] -homepage = "https://developmentseed.org/obstore/latest/" -documentation = "https://developmentseed.org/obstore/latest/" -repository = "https://github.com/developmentseed/obstore" -issues = "https://github.com/developmentseed/obstore/issues" -changelog = "https://github.com/developmentseed/obstore/blob/main/obspec/CHANGELOG.md" +homepage = "https://developmentseed.org/obspec/latest/" +documentation = "https://developmentseed.org/obspec/latest/" +repository = "https://github.com/developmentseed/obspec" +issues = "https://github.com/developmentseed/obspec/issues" +changelog = "https://github.com/developmentseed/obspec/blob/main/obspec/CHANGELOG.md" [build-system] requires = ["hatchling"] diff --git a/src/obspec/_exceptions.py b/src/obspec/_exceptions.py deleted file mode 100644 index 78875f6..0000000 --- a/src/obspec/_exceptions.py +++ /dev/null @@ -1,64 +0,0 @@ -"""Common exceptions. - -These may be restored in the future, but are not currently in the public interface -because exceptions only support nominal subtyping (subclassing) and not structural -subtyping (protocols). This means that obstore wouldn't be able to use these same -exceptions without relying on obspec which gets us into circular dependencies. -""" - -import builtins - - -class BaseError(Exception): - """The base Python-facing exception from which all other errors subclass.""" - - -class GenericError(BaseError): - """A fallback error type when no variant matches.""" - - -class NotFoundError(FileNotFoundError, BaseError): - """Error when the object is not found at given location.""" - - -class InvalidPathError(BaseError): - """Error for invalid path.""" - - -class JoinError(BaseError): - """Error when tokio::spawn failed.""" - - -class NotSupportedError(BaseError): - """Error when the attempted operation is not supported.""" - - -class AlreadyExistsError(BaseError): - """Error when the object already exists.""" - - -class PreconditionError(BaseError): - """Error when the required conditions failed for the operation.""" - - -class NotModifiedError(BaseError): - """Error when the object at the location isn't modified.""" - - -class NotImplementedError(BaseError, builtins.NotImplementedError): # noqa: A001 - """Error when an operation is not implemented. - - Subclasses from the built-in [NotImplementedError][]. - """ - - -class PermissionDeniedError(BaseError): - """Error when the used credentials don't have enough permission to perform the requested operation.""" # noqa: E501 - - -class UnauthenticatedError(BaseError): - """Error when the used credentials lack valid authentication.""" - - -class UnknownConfigurationKeyError(BaseError): - """Error when a configuration key is invalid for the store used.""" diff --git a/src/obspec/_list.py b/src/obspec/_list.py index dc53c31..75332b8 100644 --- a/src/obspec/_list.py +++ b/src/obspec/_list.py @@ -85,18 +85,18 @@ def list( Synchronously iterate through list results: ```py - import obstore as obs - from obstore.store import MemoryStore - - store = MemoryStore() - for i in range(100): - obs.put(store, f"file{i}.txt", b"foo") - - stream = obs.list(store, chunk_size=10) - for list_result in stream: - print(list_result[0]) - # {'path': 'file0.txt', 'last_modified': datetime.datetime(2024, 10, 23, 19, 19, 28, 781723, tzinfo=datetime.timezone.utc), 'size': 3, 'e_tag': '0', 'version': None} - break + import obspec + + def upload_files(client: obspec.Put): + for i in range(100): + client.put(f"file{i}.txt", b"foo") + + def list_files(client: obspec.List): + stream = client.list(chunk_size=10) + for list_result in stream: + print(list_result[0]) + # {'path': 'file0.txt', 'last_modified': datetime.datetime(2024, 10, 23, 19, 19, 28, 781723, tzinfo=datetime.timezone.utc), 'size': 3, 'e_tag': '0', 'version': None} + break ``` !!! note diff --git a/src/obspec/_put.py b/src/obspec/_put.py index c16a9db..1dcf3c1 100644 --- a/src/obspec/_put.py +++ b/src/obspec/_put.py @@ -175,12 +175,19 @@ async def put_async( # noqa: PLR0913 operation: ```py - import obstore as obs - - # This only constructs the stream, it doesn't materialize the data in memory - resp = await obs.get_async(store1, path1) - # A streaming upload is created to copy the file to path2 - await obs.put_async(store2, path2) + from obspec import GetAsync, PutAsync + + + async def streaming_copy( + fetch_client: GetAsync, + put_client: PutAsync, + path1: str, + path2: str, + ): + # This only constructs the stream, it doesn't materialize the data in memory + resp = await fetch_client.get_async(path1) + # A streaming upload is created to copy the file to path2 + await put_client.put_async(path2, resp) ``` """ ...