From dbcf38b394f3fd7407b887bd0d3ce22da019d190 Mon Sep 17 00:00:00 2001 From: Sherwin-14 Date: Tue, 11 Jun 2024 16:26:34 +0530 Subject: [PATCH] Did the necessary docstring cleanup as discussed in #590 --- earthaccess/auth.py | 7 ++++--- earthaccess/search.py | 7 +++++-- earthaccess/store.py | 3 +++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/earthaccess/auth.py b/earthaccess/auth.py index d8450c44..0efeca84 100644 --- a/earthaccess/auth.py +++ b/earthaccess/auth.py @@ -47,9 +47,8 @@ def __init__( if username and password: self.auth = (username, password) - # Overrides from the library to keep headers when redirected to or from - # the NASA auth host. def rebuild_auth(self, prepared_request: Any, response: Any) -> None: + """Overrides from the library to keep headers when redirected to or from the NASA auth host.""" headers = prepared_request.headers url = prepared_request.url @@ -93,7 +92,7 @@ def login( * **"environment"**: Retrieve a username and password from $EARTHDATA_USERNAME and $EARTHDATA_PASSWORD. persist: Will persist credentials in a `.netrc` file. - system (Env): the EDL endpoint to log in to Earthdata, defaults to PROD + system: the EDL endpoint to log in to Earthdata, defaults to PROD Returns: An instance of Auth. @@ -132,6 +131,7 @@ def _set_earthdata_system(self, system: System) -> None: def refresh_tokens(self) -> bool: """Refresh CMR tokens. + Tokens are used to do authenticated queries on CMR for restricted and early access datasets. This method renews the tokens to make sure we can query the collections allowed to our EDL user. """ @@ -188,6 +188,7 @@ def get_s3_credentials( endpoint: Optional[str] = None, ) -> Dict[str, str]: """Gets AWS S3 credentials for a given NASA cloud provider. + The easier way is to use the DAAC short name; provider is optional if we know it. Parameters: diff --git a/earthaccess/search.py b/earthaccess/search.py index 6dd7f004..db6d5bb8 100644 --- a/earthaccess/search.py +++ b/earthaccess/search.py @@ -114,8 +114,9 @@ def __init__(self, auth: Optional[Auth] = None, *args: Any, **kwargs: Any) -> No @override def hits(self) -> int: - """Returns the number of hits the current query will return. This is done by - making a lightweight query to CMR and inspecting the returned headers. + """Returns the number of hits the current query will return. + + This is done by making a lightweight query to CMR and inspecting the returned headers. Restricted datasets will always return zero results even if there are results. Returns: @@ -469,6 +470,7 @@ def __init__(self, auth: Optional[Auth] = None, *args: Any, **kwargs: Any) -> No @override def hits(self) -> int: """Returns the number of hits the current query will return. + This is done by making a lightweight query to CMR and inspecting the returned headers. @@ -561,6 +563,7 @@ def parameters(self, **kwargs: Any) -> Self: @override def provider(self, provider: str) -> Self: """Only match collections from a given provider. + A NASA datacenter or DAAC can have one or more providers. For example, PODAAC is a data center or DAAC, PODAAC is the default provider for on-prem data, and POCLOUD is diff --git a/earthaccess/store.py b/earthaccess/store.py index fa0e8a99..147e6ce8 100644 --- a/earthaccess/store.py +++ b/earthaccess/store.py @@ -165,6 +165,7 @@ def set_requests_session( self, url: str, method: str = "get", bearer_token: bool = False ) -> None: """Sets up a `requests` session with bearer tokens that are used by CMR. + Mainly used to get the authentication cookies from different DAACs and URS. This HTTPS session can be used to download granules if we want to use a direct, lower level API. @@ -265,6 +266,7 @@ def get_s3fs_session( @lru_cache def get_fsspec_session(self) -> fsspec.AbstractFileSystem: """Returns a fsspec HTTPS session with bearer tokens that are used by CMR. + This HTTPS session can be used to download granules if we want to use a direct, lower level API. @@ -283,6 +285,7 @@ def get_fsspec_session(self) -> fsspec.AbstractFileSystem: def get_requests_session(self, bearer_token: bool = True) -> requests.Session: """Returns a requests HTTPS session with bearer tokens that are used by CMR. + This HTTPS session can be used to download granules if we want to use a direct, lower level API.