From 5de13bf9b7d2a8dbe47e4527bf28cfabc60bf779 Mon Sep 17 00:00:00 2001 From: Ian Carroll Date: Tue, 1 Oct 2024 13:24:40 -0400 Subject: [PATCH 1/4] restore AbstractBaseClass inheritance --- earthaccess/store.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/earthaccess/store.py b/earthaccess/store.py index 61437542..84d61c4b 100644 --- a/earthaccess/store.py +++ b/earthaccess/store.py @@ -26,7 +26,7 @@ logger = logging.getLogger(__name__) -class EarthAccessFile: +class EarthAccessFile(fsspec.spec.AbstractBaseFile): """Handle for a file-like object pointing to an on-prem or Earthdata Cloud granule.""" def __init__( @@ -64,7 +64,7 @@ def _open_files( url_mapping: Mapping[str, Union[DataGranule, None]], fs: fsspec.AbstractFileSystem, threads: Optional[int] = 8, -) -> List[EarthAccessFile]: +) -> List[fsspec.spec.AbstractBaseFile]: def multi_thread_open(data: tuple) -> EarthAccessFile: urls, granule = data return EarthAccessFile(fs.open(urls), granule) @@ -336,7 +336,7 @@ def open( self, granules: Union[List[str], List[DataGranule]], provider: Optional[str] = None, - ) -> List[EarthAccessFile]: + ) -> List[fsspec.spec.AbstractBaseFile]: """Returns a list of file-like objects that can be used to access files hosted on S3 or HTTPS by third party libraries like xarray. From b070f1710029b0135b820167c227c736814b63d5 Mon Sep 17 00:00:00 2001 From: Ian Carroll Date: Tue, 1 Oct 2024 13:33:22 -0400 Subject: [PATCH 2/4] restore type and docs --- docs/user-reference/store/earthaccessfile.md | 7 ------- earthaccess/api.py | 2 +- mkdocs.yml | 1 - 3 files changed, 1 insertion(+), 9 deletions(-) delete mode 100644 docs/user-reference/store/earthaccessfile.md diff --git a/docs/user-reference/store/earthaccessfile.md b/docs/user-reference/store/earthaccessfile.md deleted file mode 100644 index 31b19c93..00000000 --- a/docs/user-reference/store/earthaccessfile.md +++ /dev/null @@ -1,7 +0,0 @@ -# Documentation for `EarthAccessFile` - -::: earthaccess.store.EarthAccessFile - options: - inherited_members: true - show_root_heading: true - show_source: false diff --git a/earthaccess/api.py b/earthaccess/api.py index 4b4b1698..a5f1257b 100644 --- a/earthaccess/api.py +++ b/earthaccess/api.py @@ -242,7 +242,7 @@ def download( def open( granules: Union[List[str], List[DataGranule]], provider: Optional[str] = None, -) -> List[EarthAccessFile]: +) -> List[AbstractFileSystem]: """Returns a list of file-like objects that can be used to access files hosted on S3 or HTTPS by third party libraries like xarray. diff --git a/mkdocs.yml b/mkdocs.yml index c8ab1a70..c7655fff 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -101,7 +101,6 @@ nav: - "Granule Queries": "user-reference/granules/granules-query.md" - "Granule Results": "user-reference/granules/granules.md" - Store: - - "EarthAccessFile": "user-reference/store/earthaccessfile.md" - "Store": "user-reference/store/store.md" - Auth: - "Auth": "user-reference/auth/auth.md" From 770263983e76467ef60741d9ce7afc50d4a7365f Mon Sep 17 00:00:00 2001 From: Matt Fisher Date: Tue, 1 Oct 2024 11:43:31 -0600 Subject: [PATCH 3/4] Mark re-broken unit test as expected fail --- tests/unit/test_store.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/unit/test_store.py b/tests/unit/test_store.py index 9b12c267..83ec05d6 100644 --- a/tests/unit/test_store.py +++ b/tests/unit/test_store.py @@ -129,6 +129,9 @@ def test_store_can_create_s3_fsspec_session(self): return None +@pytest.mark.xfail( + reason="This test reproduces a bug (#610) which has not yet been fixed." +) def test_earthaccess_file_getattr(): fs = fsspec.filesystem("memory") with fs.open("/foo", "wb") as f: From fb7880623d4a8bd79d2ac60e25284da10ab26e9d Mon Sep 17 00:00:00 2001 From: Matt Fisher Date: Tue, 1 Oct 2024 11:43:44 -0600 Subject: [PATCH 4/4] Fix misspelled class name --- earthaccess/store.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/earthaccess/store.py b/earthaccess/store.py index 84d61c4b..31f09a44 100644 --- a/earthaccess/store.py +++ b/earthaccess/store.py @@ -26,7 +26,7 @@ logger = logging.getLogger(__name__) -class EarthAccessFile(fsspec.spec.AbstractBaseFile): +class EarthAccessFile(fsspec.spec.AbstractBufferedFile): """Handle for a file-like object pointing to an on-prem or Earthdata Cloud granule.""" def __init__( @@ -64,7 +64,7 @@ def _open_files( url_mapping: Mapping[str, Union[DataGranule, None]], fs: fsspec.AbstractFileSystem, threads: Optional[int] = 8, -) -> List[fsspec.spec.AbstractBaseFile]: +) -> List[fsspec.spec.AbstractBufferedFile]: def multi_thread_open(data: tuple) -> EarthAccessFile: urls, granule = data return EarthAccessFile(fs.open(urls), granule) @@ -336,7 +336,7 @@ def open( self, granules: Union[List[str], List[DataGranule]], provider: Optional[str] = None, - ) -> List[fsspec.spec.AbstractBaseFile]: + ) -> List[fsspec.spec.AbstractBufferedFile]: """Returns a list of file-like objects that can be used to access files hosted on S3 or HTTPS by third party libraries like xarray.