-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixing searching for restricted datasets and accessing ASF on demand data from Opera #443
Changes from 2 commits
e97e6f0
073e4ac
acade70
429324a
b320652
0ead9db
c692069
b94897e
11686dd
2b14609
72539dd
19b6be1
d20f713
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,7 +228,9 @@ def __repr__(self) -> str: | |
Temporal coverage: {self['umm']['TemporalExtent']} | ||
Size(MB): {self.size()} | ||
Data: {data_links}\n\n | ||
""".strip().replace(" ", "") | ||
""".strip().replace( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Black likes this, Ruff does not, which one is right? @mfisher87 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should pick one :) Ruff offers a formatter that re-implements Black, but I've never worked with it before. Personally, I'd turn Ruff formatting off and stick with Black due to my lack of experience, but if I had more time I'd try to learn more and switch to Ruff for everything. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like Ruff prefers the compact and black expands. I think Ruff is actually correct here (obvs. subjective). This doc is helpful for black vs ruff: I don't think it matters which, but I agree that we should pick one -- I'd prefer ruff overall. @MattF-NSIDC I'm pretty happy with ruff; and the transition from black to ruff is pretty straight forward as they mostly behave the same. |
||
" ", "" | ||
) | ||
return rep_str | ||
|
||
def _repr_html_(self) -> str: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,16 @@ def hits(self) -> int: | |
Returns: | ||
number of results reported by CMR | ||
""" | ||
return super().hits() | ||
url = self._build_url() | ||
|
||
response = self.session.get(url, headers=self.headers, params={"page_size": 0}) | ||
|
||
try: | ||
response.raise_for_status() | ||
except exceptions.HTTPError as ex: | ||
raise RuntimeError(ex.response.text) | ||
|
||
return int(response.headers["CMR-Hits"]) | ||
|
||
def concept_id(self, IDs: List[str]) -> Type[CollectionQuery]: | ||
"""Filter by concept ID (ex: C1299783579-LPDAAC_ECS or G1327299284-LPDAAC_ECS, S12345678-LPDAAC_ECS) | ||
|
@@ -106,6 +115,38 @@ def doi(self, doi: str) -> Type[CollectionQuery]: | |
self.params["doi"] = doi | ||
return self | ||
|
||
def instrument(self, instrument: str) -> Type[CollectionQuery]: | ||
"""Searh datasets by instrument | ||
|
||
???+ Tip | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
Not all datasets have an associated instrument. This works | ||
only at the dataset level but not the granule (data) level. | ||
|
||
Parameters: | ||
instrument (String): instrument of a datasets, e.g. instrument=GEDI | ||
""" | ||
if not isinstance(instrument, str): | ||
raise TypeError("instrument must be of type str") | ||
|
||
self.params["instrument"] = instrument | ||
return self | ||
|
||
def project(self, project: str) -> Type[CollectionQuery]: | ||
"""Searh datasets by associated project | ||
|
||
???+ Tip | ||
Not all datasets have an associated instrument. This works | ||
only at the dataset level but not the granule (data) level. | ||
|
||
Parameters: | ||
project (String): associated project of a datasets, e.g. project=EMIT | ||
""" | ||
if not isinstance(project, str): | ||
raise TypeError("project must be of type str") | ||
|
||
self.params["project"] = project | ||
return self | ||
|
||
def parameters(self, **kwargs: Any) -> Type[CollectionQuery]: | ||
"""Provide query parameters as keyword arguments. The keyword needs to match the name | ||
of the method, and the value should either be the value or a tuple of values. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is only for the local dev environment and actually not necessary as we can just pip install the project locally.... I use it to bootstrap the environment and install some conda libs to test notebooks with (cartopy)