Skip to content
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ and this project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html)

### Added

- Added `FutureWarning` to `DataCollections` and `DataGranules` methods
in preparation for merge of #1187 in version 1.0.
([#1267](https://github.com/earthaccess-dev/earthaccess/pull/1267))
(@andypbarrett)
- Added `force` kwarg to `download()` to force redownloads. ([@WeatherGod](https://github.com/WeatherGod))

### Removed
Expand Down
3,244 changes: 1,622 additions & 1,622 deletions docs/user/howto/fsspec.ipynb

Large diffs are not rendered by default.

114 changes: 104 additions & 10 deletions earthaccess/results.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import uuid
import warnings
from functools import cache
from typing import Any, Dict, List, Optional, Union

Expand Down Expand Up @@ -97,16 +98,29 @@ def summary(self) -> Dict[str, Any]:
"""
# we can print only the concept-id

summary_dict: Dict[str, Any]
summary_dict = {
"short-name": self.get_umm("ShortName"),
"concept-id": self.concept_id(),
"version": self.version(),
"file-type": self.data_type(),
"get-data": self.get_data(),
}
if "Region" in self.s3_bucket():
summary_dict["cloud-info"] = self.s3_bucket()
warnings.warn(
"As of version 1.0, `DataCollection.summary` will be accessed as an "
"attribute; e.g. use `DataCollection.summary` **not** "
"`DataCollection.summary()`",
category=FutureWarning,
stacklevel=2,
)

# Only issue a single FutureWarning
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=FutureWarning)

summary_dict: Dict[str, Any]
summary_dict = {
"short-name": self.get_umm("ShortName"),
"concept-id": self.concept_id(),
"version": self.version(),
"file-type": self.data_type(),
"get-data": self.get_data(),
}
if "Region" in self.s3_bucket():
summary_dict["cloud-info"] = self.s3_bucket()

return summary_dict

def get_umm(self, umm_field: str) -> Union[str, Dict[str, Any]]:
Expand All @@ -126,6 +140,14 @@ def doi(self) -> str | None:
Returns:
This collection's DOI information, or `None`, if it has none.
"""
warnings.warn(
"As of version 1.0, `DataCollection.doi` will be accessed as an "
"attribute; e.g. use `DataCollection.doi` **not** "
"`DataCollection.doi()`",
category=FutureWarning,
stacklevel=2,
)

doi = self["umm"].get("DOI", {})
if isinstance(doi, dict):
return doi.get("DOI", None)
Expand Down Expand Up @@ -158,6 +180,14 @@ def concept_id(self) -> str:
Returns:
A collection's `concept_id`.This id is the most relevant search field on granule queries.
"""
warnings.warn(
"As of version 1.0, `DataCollection.concept_id` will be accessed as an "
"attribute; e.g. use `DataCollection.concept_id` **not** "
"`DataCollection.concept_id()`",
category=FutureWarning,
stacklevel=2,
)

return self["meta"]["concept-id"]

def data_type(self) -> str:
Expand All @@ -166,6 +196,14 @@ def data_type(self) -> str:
Returns:
The collection data type, i.e. HDF5, CSV etc., if available.
"""
warnings.warn(
"As of version 1.0, `DataCollection.data_type` will be accessed as an "
"attribute; e.g. use `DataCollection.data_type` **not** "
"`DataCollection.data_type()`",
category=FutureWarning,
stacklevel=2,
)

return str(
self["umm"]
.get("ArchiveAndDistributionInformation", {})
Expand All @@ -178,6 +216,14 @@ def version(self) -> str:
Returns:
The collection's version.
"""
warnings.warn(
"As of version 1.0, `DataCollection.version` will be accessed as an "
"attribute; e.g. use `DataCollection.version` **not** "
"`DataCollection.version()`",
category=FutureWarning,
stacklevel=2,
)

return self["umm"].get("Version", "")

def abstract(self) -> str:
Expand All @@ -186,6 +232,14 @@ def abstract(self) -> str:
Returns:
The abstract of a collection.
"""
warnings.warn(
"As of version 1.0, `DataCollection.abstract` will be accessed as an "
"attribute; e.g. use `DataCollection.abstract` **not** "
"`DataCollection.abstract()`",
category=FutureWarning,
stacklevel=2,
)

return self["umm"].get("Abstract", "")

def landing_page(self) -> str:
Expand All @@ -194,6 +248,14 @@ def landing_page(self) -> str:
Returns:
The first landing page for the collection (can be many), if available.
"""
warnings.warn(
"As of version 1.0, `DataCollection.landing_page` will be accessed as an "
"attribute; e.g. use `DataCollection.landing_page` **not** "
"`DataCollection.landing_page()`",
category=FutureWarning,
stacklevel=2,
)

links = self._filter_related_links("LANDING PAGE")
return links[0] if len(links) > 0 else ""

Expand All @@ -203,6 +265,14 @@ def get_data(self) -> List[str]:
Returns:
The GET DATA links (usually a landing page link, a DAAC portal, or an FTP location).
"""
warnings.warn(
"As of version 1.0, `DataCollection.get_data` will be accessed as an "
"attribute; e.g. use `DataCollection.get_data` **not** "
"`DataCollection.get_data()`",
category=FutureWarning,
stacklevel=2,
)

return self._filter_related_links("GET DATA")

def s3_bucket(self) -> Dict[str, Any]:
Expand All @@ -211,10 +281,26 @@ def s3_bucket(self) -> Dict[str, Any]:
Returns:
The S3 bucket information if the collection has it (**cloud hosted collections only**).
"""
warnings.warn(
"As of version 1.0, `DataCollection.s3_bucket` will be accessed as an "
"attribute; e.g. use `DataCollection.s3_bucket` **not** "
"`DataCollection.s3_bucket()`",
category=FutureWarning,
stacklevel=2,
)

return self["umm"].get("DirectDistributionInformation", {})

def services(self) -> Dict[Any, List[Dict[str, Any]]]:
"""Return list of services available for this collection."""
warnings.warn(
"As of version 1.0, `DataCollection.services` will be accessed as an "
"attribute; e.g. use `DataCollection.services` **not** "
"`DataCollection.services()`",
category=FutureWarning,
stacklevel=2,
)

services = self.get("meta", {}).get("associations", {}).get("services", [])
queries = (
DataServices(auth=earthaccess.__auth__).parameters(concept_id=service)
Expand Down Expand Up @@ -304,6 +390,14 @@ def size(self) -> float:
Returns:
The total size for the granule in MB.
"""
warnings.warn(
"As of version 1.0, `DataGranule.size` will be accessed as an "
"attribute; e.g. use `DataCollection.size` **not** "
"`DataCollection.size()`",
category=FutureWarning,
stacklevel=2,
)

try:
data_granule = self["umm"]["DataGranule"]
total_size = sum(
Expand Down
4 changes: 2 additions & 2 deletions earthaccess/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ def _get_urls(
def _download(file: str) -> Union[Path, None]:
return self.download_cloud_file(s3_fs, file, local_path, force=force)

results = pqdm(data_links, _download, **pqdm_kwargs)
results = pqdm(data_links, _download, **(pqdm_kwargs or {}))
return [r for r in results if r is not None]

else:
Expand Down Expand Up @@ -848,7 +848,7 @@ def _get_granules(
def _download(file: str) -> Union[Path, None]:
return self.download_cloud_file(s3_fs, file, local_path, force=force)

results = pqdm(data_links, _download, **pqdm_kwargs)
results = pqdm(data_links, _download, **(pqdm_kwargs or {}))
return [r for r in results if r is not None]

else:
Expand Down
Loading