Skip to content

Commit

Permalink
Revert "enable QUEST kwarg handling (#452)"
Browse files Browse the repository at this point in the history
This reverts commit b5f58d5.
  • Loading branch information
JessicaS11 authored Jan 5, 2024
1 parent 8d57ec9 commit 6d9acf6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 102 deletions.
1 change: 0 additions & 1 deletion doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ ICESat-2 datasets to enable scientific discovery.
contributing/contribution_guidelines
contributing/how_to_contribute
contributing/icepyx_internals
contributing/quest-available-datasets
contributing/attribution_link
contributing/development_plan
contributing/release_guide
Expand Down
99 changes: 25 additions & 74 deletions icepyx/quest/quest.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(
date_range=None,
start_time=None,
end_time=None,
proj="default",
proj="Default",
):
"""
Tells QUEST to initialize data given the user input spatiotemporal data.
Expand Down Expand Up @@ -94,23 +94,9 @@ def add_icesat2(
tracks=None,
files=None,
**kwargs,
) -> None:
):
"""
Adds ICESat-2 datasets to QUEST structure.
Parameters
----------
For details on inputs, see the Query documentation.
Returns
-------
None
See Also
--------
icepyx.core.GenQuery
icepyx.core.Query
"""

query = Query(
Expand All @@ -136,76 +122,41 @@ def add_icesat2(
# ----------------------------------------------------------------------
# Methods (on all datasets)

# error handling? what happens when the user tries to re-query?
def search_all(self, **kwargs):
# error handling? what happens when one of i fails...
def search_all(self):
"""
Searches for requred dataset within platform (i.e. ICESat-2, Argo) of interest.
Parameters
----------
**kwargs : default None
Optional passing of keyword arguments to supply additional search constraints per datasets.
Each key must match the dataset name (e.g. "icesat2", "argo") as in quest.datasets.keys(),
and the value is a dictionary of acceptable keyword arguments
and values allowable for the `search_data()` function for that dataset.
For instance: `icesat2 = {"IDs":True}, argo = {"presRange":"10,500"}`.
"""
print("\nSearching all datasets...")

for k, v in self.datasets.items():
for i in self.datasets.values():
print()
try:
if isinstance(v, Query):
# querying ICESat-2 data
if isinstance(i, Query):
print("---ICESat-2---")
try:
msg = v.avail_granules(kwargs[k])
except KeyError:
msg = v.avail_granules()
msg = i.avail_granules()
print(msg)
else:
print(k)
try:
v.search_data(kwargs[k])
except KeyError:
v.search_data()
else: # querying all other data sets
print(i)
i.search_data()
except:
dataset_name = type(v).__name__
dataset_name = type(i).__name__
print("Error querying data from {0}".format(dataset_name))

# error handling? what happens if the user tries to re-download?
def download_all(self, path="", **kwargs):
"""
Downloads requested dataset(s).
Parameters
----------
**kwargs : default None
Optional passing of keyword arguments to supply additional search constraints per datasets.
Each key must match the dataset name (e.g. "icesat2", "argo") as in quest.datasets.keys(),
and the value is a dictionary of acceptable keyword arguments
and values allowable for the `search_data()` function for that dataset.
For instance: `icesat2 = {"verbose":True}, argo = {"keep_existing":True}`.
"""
# error handling? what happens when one of i fails...
def download_all(self, path=""):
' ' 'Downloads requested dataset(s).' ' '
print("\nDownloading all datasets...")

for k, v in self.datasets.items():
for i in self.datasets.values():
print()
try:

if isinstance(v, Query):
print("---ICESat-2---")
try:
msg = v.download_granules(path, kwargs[k])
except KeyError:
msg = v.download_granules(path)
print(msg)
else:
print(k)
try:
msg = v.download(kwargs[k])
except KeyError:
msg = v.download()
print(msg)
except:
dataset_name = type(v).__name__
print("Error downloading data from {0}".format(dataset_name))
if isinstance(i, Query):
print("---ICESat-2---")
msg = i.download_granules(path)
print(msg)
else:
i.download()
print(i)

# DEVNOTE: see colocated data branch and phyto team files for code that expands quest functionality
31 changes: 4 additions & 27 deletions icepyx/tests/test_quest.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,36 +68,13 @@ def test_add_is2(quest_instance):

########## ALL DATASET METHODS TESTS ##########

# is successful execution enough here?
# each of the query functions should be tested in their respective modules
def test_search_all(quest_instance):
# Search and test all datasets
quest_instance.search_all()


@pytest.mark.parametrize(
"kwargs",
[
{"icesat2": {"IDs": True}},
# {"argo":{"presRange":"10,500"}},
# {"icesat2":{"IDs":True}, "argo":{"presRange":"10,500"}}
],
)
def test_search_all_kwargs(quest_instance, kwargs):
quest_instance.search_all(**kwargs)


# TESTS NOT IMPLEMENTED
# def test_download_all():
# # this will require auth in some cases...
# pass

# @pytest.mark.parametrize(
# "kwargs",
# [
# {"icesat2": {"verbose":True}},
# # {"argo":{"keep_existing":True},
# # {"icesat2":{"verbose":True}, "argo":{"keep_existing":True}
# ],
# )
# def test_download_all_kwargs(quest_instance, kwargs):
# pass
def test_download_all():
# this will require auth in some cases...
pass

0 comments on commit 6d9acf6

Please sign in to comment.