Skip to content

Commit ebb15a1

Browse files
further docstring cleanup, grammar
1 parent 9aea057 commit ebb15a1

File tree

4 files changed

+43
-41
lines changed

4 files changed

+43
-41
lines changed

earthaccess/api.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def search_datasets(
4040
kwargs (Dict):
4141
arguments to CMR:
4242
43-
* **keyword**: case-insensitive and support wildcards ? and *,
43+
* **keyword**: case-insensitive and supports wildcards ? and *
4444
* **short_name**: e.g. ATL08
4545
* **doi**: DOI for a dataset
4646
* **daac**: e.g. NSIDC or PODAAC
@@ -51,7 +51,7 @@ def search_datasets(
5151
`(lower_left_lon, lower_left_lat, upper_right_lon, upper_right_lat)`
5252
5353
Returns:
54-
a list of DataCollection results that can be used to get information about a
54+
A list of DataCollection results that can be used to get information about a
5555
dataset, e.g. concept_id, doi, etc.
5656
5757
Examples:
@@ -90,7 +90,7 @@ def search_data(
9090
kwargs (Dict):
9191
arguments to CMR:
9292
93-
* **short_name**: dataset short name e.g. ATL08
93+
* **short_name**: dataset short name, e.g. ATL08
9494
* **version**: dataset version
9595
* **doi**: DOI for a dataset
9696
* **daac**: e.g. NSIDC or PODAAC
@@ -173,7 +173,7 @@ def download(
173173
Parameters:
174174
granules: a granule, list of granules, a granule link (HTTP), or a list of granule links (HTTP)
175175
local_path: local directory to store the remote data granules
176-
provider: if we download a list of URLs we need to specify the provider.
176+
provider: if we download a list of URLs, we need to specify the provider.
177177
threads: parallel number of threads to use to download the files, adjust as necessary, default = 8
178178
179179
Returns:
@@ -269,7 +269,7 @@ def get_fsspec_https_session() -> AbstractFileSystem:
269269
"""Returns a fsspec session that can be used to access datafiles across many different DAACs.
270270
271271
Returns:
272-
an fsspec instance able to access data across DAACs
272+
An fsspec instance able to access data across DAACs.
273273
274274
Examples:
275275
```python
@@ -280,19 +280,18 @@ def get_fsspec_https_session() -> AbstractFileSystem:
280280
with fs.open(DAAC_GRANULE) as f:
281281
f.read(10)
282282
```
283-
284283
"""
285284
session = earthaccess.__store__.get_fsspec_session()
286285
return session
287286

288287

289288
def get_requests_https_session() -> requests.Session:
290289
"""Returns a requests Session instance with an authorized bearer token.
291-
This is useful to make requests to restricted URLs like data granules or services that
290+
This is useful for making requests to restricted URLs, such as data granules or services that
292291
require authentication with NASA EDL.
293292
294293
Returns:
295-
an authenticated requests Session instance.
294+
An authenticated requests Session instance.
296295
297296
Examples:
298297
```python
@@ -324,7 +323,7 @@ def get_s3fs_session(
324323
`earthaccess` will use the metadata from CMR to obtain the S3 Endpoint.
325324
326325
Returns:
327-
an authenticated s3fs session valid for 1 hour
326+
An authenticated s3fs session valid for 1 hour.
328327
"""
329328
daac = _normalize_location(daac)
330329
provider = _normalize_location(provider)

earthaccess/results.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,12 @@ def data_links(
310310
# we have the s3 links so we return those
311311
return s3_links
312312
else:
313-
# Even though we are in us-west-2, the user wants the HTTPS links
314-
# used in region they are S3 signed links from TEA
315-
# https://github.com/asfadmin/thin-egress-app
313+
# Even though we are in us-west-2, the user wants the HTTPS links used in-region.
314+
# They are S3 signed links from TEA.
315+
# <https://github.com/asfadmin/thin-egress-app>
316316
return https_links
317317
else:
318-
# we are not in region
318+
# we are not in-region
319319
if access == "direct":
320320
# maybe the user wants to collect S3 links and use them later
321321
# from the cloud

earthaccess/search.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -428,15 +428,16 @@ def orbit_number(self, orbit1: int, orbit2: int) -> Type[GranuleQuery]:
428428
return self
429429

430430
def cloud_hosted(self, cloud_hosted: bool = True) -> Type[CollectionQuery]:
431-
"""Only match granules that are hosted in the cloud. This is valid for public
432-
collections and if we are using the short_name parameter. Concept-Id is unambiguous.
431+
"""Only match granules that are hosted in the cloud.
432+
This is valid for public collections and when using the short_name parameter.
433+
Concept-Id is unambiguous.
433434
434435
???+ Tip
435-
Cloud hosted collections can be public or restricted.
436-
Restricted collections will not be matched using this parameter
436+
Cloud-hosted collections can be public or restricted.
437+
Restricted collections will not be matched using this parameter.
437438
438439
Parameters:
439-
cloud_hosted (Boolean): True to require granules only be online
440+
cloud_hosted: True to require granules only be online
440441
"""
441442
if not isinstance(cloud_hosted, bool):
442443
raise TypeError("cloud_hosted must be of type bool")
@@ -455,7 +456,7 @@ def granule_name(self, granule_name: str) -> Type[CollectionQuery]:
455456
456457
???+ Tip
457458
We can use wildcards on a granule name to further refine our search,
458-
e.g. MODGRNLD.*.daily.*
459+
e.g. `MODGRNLD.*.daily.*`.
459460
460461
Parameters:
461462
granule_name: granule name (accepts wildcards)

earthaccess/store.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -155,21 +155,22 @@ def _running_in_us_west_2(self) -> bool:
155155
return False
156156

157157
if resp.status_code == 200 and b"us-west-2" == resp.content:
158-
# On AWS in region us-west-2
158+
# On AWS, in region us-west-2
159159
return True
160160
return False
161161

162162
def set_requests_session(
163163
self, url: str, method: str = "get", bearer_token: bool = False
164164
) -> None:
165165
"""Sets up a `requests` session with bearer tokens that are used by CMR.
166-
Mainly used to get the authentication cookies from different DAACs and URS
167-
This HTTPS session can be used to download granules if we want to use a direct, lower level API
166+
Mainly used to get the authentication cookies from different DAACs and URS.
167+
This HTTPS session can be used to download granules if we want to use a direct,
168+
lower level API.
168169
169170
Parameters:
170171
url: used to test the credentials and populate the class auth cookies
171-
method: HTTP method to test. default: "GET"
172-
bearer_token: if true will be used for authenticated queries on CMR
172+
method: HTTP method to test, default: "GET"
173+
bearer_token: if true, will be used for authenticated queries on CMR
173174
174175
Returns:
175176
fsspec HTTPFileSystem (aiohttp client session)
@@ -203,7 +204,7 @@ def get_s3fs_session(
203204
"""Returns a s3fs instance for a given cloud provider / DAAC.
204205
205206
Parameters:
206-
daac: any of the DAACs e.g. NSIDC, PODAAC
207+
daac: any of the DAACs, e.g. NSIDC, PODAAC
207208
provider: a data provider if we know them, e.g. PODAAC -> POCLOUD
208209
endpoint: pass the URL for the credentials directly
209210
@@ -262,7 +263,8 @@ def get_s3fs_session(
262263
@lru_cache
263264
def get_fsspec_session(self) -> fsspec.AbstractFileSystem:
264265
"""Returns a fsspec HTTPS session with bearer tokens that are used by CMR.
265-
This HTTPS session can be used to download granules if we want to use a direct, lower level API
266+
This HTTPS session can be used to download granules if we want to use a direct,
267+
lower level API.
266268
267269
Returns:
268270
fsspec HTTPFileSystem (aiohttp client session)
@@ -279,7 +281,8 @@ def get_fsspec_session(self) -> fsspec.AbstractFileSystem:
279281

280282
def get_requests_session(self, bearer_token: bool = True) -> requests.Session:
281283
"""Returns a requests HTTPS session with bearer tokens that are used by CMR.
282-
This HTTPS session can be used to download granules if we want to use a direct, lower level API
284+
This HTTPS session can be used to download granules if we want to use a direct,
285+
lower level API.
283286
284287
Parameters:
285288
bearer_token: if true, will be used for authenticated queries on CMR
@@ -303,7 +306,7 @@ def open(
303306
provider: an option
304307
305308
Returns:
306-
a list of s3fs "file pointers" to s3 files.
309+
A list of s3fs "file pointers" to s3 files.
307310
"""
308311
if len(granules):
309312
return self._open(granules, provider)
@@ -324,7 +327,7 @@ def _open(
324327
provider: an option
325328
326329
Returns:
327-
a list of s3fs "file pointers" to s3 files.
330+
A list of s3fs "file pointers" to s3 files.
328331
"""
329332
raise NotImplementedError("granules should be a list of DataGranule or URLs")
330333

@@ -454,11 +457,10 @@ def get(
454457
the data will be effectively downloaded to a local directory.
455458
456459
Parameters:
457-
granules: a list of granules(DataGranule) instances or a list of granule links (HTTP)
458-
local_path: local directory to store the remote data granules
459-
access: direct or on_prem, if set it will use it for the access method.
460-
threads: parallel number of threads to use to download the files;
461-
adjust as necessary, default = 8
460+
granules: A list of granules(DataGranule) instances or a list of granule links (HTTP).
461+
local_path: Local directory to store the remote data granules.
462+
threads: Parallel number of threads to use to download the files;
463+
adjust as necessary, default = 8.
462464
463465
Returns:
464466
List of downloaded files
@@ -493,10 +495,10 @@ def _get(
493495
the data will be effectively downloaded to a local directory.
494496
495497
Parameters:
496-
granules: a list of granules(DataGranule) instances or a list of granule links (HTTP)
497-
local_path: local directory to store the remote data granules
498-
access: direct or on_prem, if set it will use it for the access method.
499-
threads: parallel number of threads to use to download the files, adjust as necessary, default = 8
498+
granules: A list of granules (DataGranule) instances or a list of granule links (HTTP).
499+
local_path: Local directory to store the remote data granules
500+
threads: Parallel number of threads to use to download the files;
501+
adjust as necessary, default = 8.
500502
501503
Returns:
502504
None
@@ -548,7 +550,7 @@ def _get_granules(
548550
cloud_hosted = granules[0].cloud_hosted
549551
access = "direct" if (cloud_hosted and self.in_region) else "external"
550552
data_links = list(
551-
# we are not in region
553+
# we are not in-region
552554
chain.from_iterable(
553555
granule.data_links(access=access, in_region=self.in_region)
554556
for granule in granules
@@ -587,7 +589,7 @@ def _download_file(self, url: str, directory: str) -> str:
587589
directory: local directory
588590
589591
Returns:
590-
a local filepath or an exception
592+
A local filepath or an exception.
591593
"""
592594
# If the get data link is an Opendap location
593595
if "opendap" in url and url.endswith(".html"):
@@ -628,7 +630,7 @@ def _download_onprem_granules(
628630
adjust as necessary, default = 8
629631
630632
Returns:
631-
a list of local filepaths to which the files were downloaded
633+
A list of local filepaths to which the files were downloaded.
632634
"""
633635
if urls is None:
634636
raise ValueError("The granules didn't provide a valid GET DATA link")

0 commit comments

Comments
 (0)