Skip to content
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

v7.0.8 Release #287

Merged
merged 12 commits into from
Mar 26, 2024
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-

-->
------
## [v7.0.8](https://github.com/asfadmin/Discovery-asf_search/compare/v7.0.7...v7.0.8)
### Added
- `s3Urls` property added to `S1Product`, `OPERAS1Product`, and `NISARProduct` types, exposing direct access S3 links

------
## [v7.0.7](https://github.com/asfadmin/Discovery-asf_search/compare/v7.0.6...v7.0.7)
Expand Down
24 changes: 24 additions & 0 deletions asf_search/ASFProduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,30 @@ def get_stack_opts(self, opts: ASFSearchOptions = None) -> ASFSearchOptions:
"""
return None

def _get_access_urls(self, url_types: List[str] = ['GET DATA', 'EXTENDED METADATA']) -> List[str]:
accessUrls = []

for url_type in url_types:
if urls := self.umm_get(self.umm, 'RelatedUrls', ('Type', [(url_type, 'URL')]), 0):
accessUrls.extend(urls)

return sorted(list(set(accessUrls)))

def _get_additional_urls(self) -> List[str]:
accessUrls = self._get_access_urls(['GET DATA', 'EXTENDED METADATA'])
return [
url for url in accessUrls if not url.endswith('.md5')
and not url.startswith('s3://')
and 's3credentials' not in url
and not url.endswith('.png')
and url != self.properties['url']
]

def _get_s3_urls(self) -> List[str]:
s3_urls = self._get_access_urls(['GET DATA', 'EXTENDED METADATA', 'GET DATA VIA DIRECT ACCESS'])
return [url for url in s3_urls if url.startswith('s3://')]


def centroid(self) -> Point:
"""
Finds the centroid of a product
Expand Down
16 changes: 2 additions & 14 deletions asf_search/Products/NISARProduct.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,8 @@ class NISARProduct(ASFStackableProduct):
def __init__(self, args: Dict = {}, session: ASFSession = ASFSession()):
super().__init__(args, session)

accessUrls = []

if related_data_urls := self.umm_get(self.umm, 'RelatedUrls', ('Type', [('GET DATA', 'URL')]), 0):
accessUrls.extend(related_data_urls)
if related_metadata_urls := self.umm_get(self.umm, 'RelatedUrls', ('Type', [('EXTENDED METADATA', 'URL')]), 0):
accessUrls.extend(related_metadata_urls)

self.properties['additionalUrls'] = sorted([
url for url in list(set(accessUrls)) if not url.endswith('.md5')
and not url.startswith('s3://')
and 's3credentials' not in url
and not url.endswith('.png')
and url != self.properties['url']
])
self.properties['additionalUrls'] = self._get_additional_urls()
self.properties['s3Urls'] = self._get_s3_urls()

if self.properties.get('groupID') is None:
self.properties['groupID'] = self.properties['sceneName']
Expand Down
15 changes: 1 addition & 14 deletions asf_search/Products/OPERAS1Product.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,7 @@ def __init__(self, args: Dict = {}, session: ASFSession = ASFSession()):

self.properties['beamMode'] = self.umm_get(self.umm, 'AdditionalAttributes', ('Name', 'BEAM_MODE'), 'Values', 0)

accessUrls = []

if related_data_urls := self.umm_get(self.umm, 'RelatedUrls', ('Type', [('GET DATA', 'URL')]), 0):
accessUrls.extend(related_data_urls)
if related_metadata_urls := self.umm_get(self.umm, 'RelatedUrls', ('Type', [('EXTENDED METADATA', 'URL')]), 0):
accessUrls.extend(related_metadata_urls)

self.properties['additionalUrls'] = sorted([
url for url in list(set(accessUrls)) if not url.endswith('.md5')
and not url.startswith('s3://')
and 's3credentials' not in url
and not url.endswith('.png')
and url != self.properties['url']
])
self.properties['additionalUrls'] = self._get_additional_urls()

self.properties['operaBurstID'] = self.umm_get(self.umm, 'AdditionalAttributes', ('Name', 'OPERA_BURST_ID'), 'Values', 0)
self.properties['bytes'] = {entry['Name']: {'bytes': entry['SizeInBytes'], 'format': entry['Format']} for entry in self.properties['bytes']}
Expand Down
2 changes: 2 additions & 0 deletions asf_search/Products/S1Product.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class S1Product(ASFStackableProduct):
def __init__(self, args: Dict = {}, session: ASFSession = ASFSession()):
super().__init__(args, session)

self.properties['s3Urls'] = self._get_s3_urls()

if self._has_baseline():
self.baseline = self.get_baseline_calc_properties()

Expand Down
Loading