Skip to content

Commit d9528ba

Browse files
Merge pull request #60 from asfadmin/dev
feat: aria stacking derived from asf-search v10.0.0
2 parents fc0ac51 + 6d41697 commit d9528ba

6 files changed

Lines changed: 21 additions & 49 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
2828
------
2929
## [1.0.8](https://github.com/asfadmin/Discovery-SearchAPI-v3/compare/v1.0.7...v1.0.8)
3030
### Changed
31-
- bump asf-search to v9.0.9 for NISAR `GUNW` and `GSLC` `processingLevel` search keyword collection aliases
31+
- bump asf-search to v10.0.0 for NISAR `GUNW` and `GSLC` `processingLevel` search keyword collection aliases, and ARIA-S1 GUNW Stacking support
3232

3333
------
3434
## [1.0.7](https://github.com/asfadmin/Discovery-SearchAPI-v3/compare/v1.0.6...v1.0.7)

requirements.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ python-multipart>=0.0.7
1717
PyYAML==6.0.2
1818
rfc3986==1.5.0
1919
sniffio==1.3.0
20-
typing_extensions==4.10.0
20+
typing_extensions>=4.10.0
2121
ujson==5.7.0
2222
uvicorn==0.21.1
2323
watchfiles==0.19.0
2424

25-
asf_search==9.0.9
25+
asf-search[asf-enumeration]==10.0.0
2626
python-json-logger==2.0.7
27-
asf_enumeration
2827

2928
pyshp==2.1.3
3029
geopandas

src/SearchAPI/application/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
from .output import *
33
from .logger import *
44
from .log_router import *
5-
from .search import *
65
from .SearchAPISession import *
76
from .application import *

src/SearchAPI/application/application.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@
1515
from .asf_opts import process_baseline_request, process_search_request, process_wkt_request
1616
from .health import get_cmr_health
1717
from .models import BaselineSearchOptsModel, SearchOptsModel
18-
from .output import as_output, get_asf_search_script, make_filename
18+
from .output import as_output, get_asf_search_script
1919
from .files_to_wkt import FilesToWKT
2020
from . import constants
2121
from .SearchAPISession import SearchAPISession
22-
from .search import get_aria_groups_for_frame, stack_aria_gunw
23-
import time
2422
from asf_search.ASFSearchOptions.config import config as asf_config
2523

2624
asf_config['session'] = SearchAPISession()
@@ -98,19 +96,8 @@ async def query_baseline(searchOptions: BaselineSearchOptsModel = Depends(proces
9896
reference = searchOptions.reference
9997
request_method = searchOptions.request_method
10098

101-
if searchOptions.opts.dataset is not None:
102-
if searchOptions.opts.dataset[0] == asf.DATASET.ARIA_S1_GUNW:
103-
if output.lower() == 'count':
104-
return Response(
105-
content=str(len(get_aria_groups_for_frame(reference)[1])),
106-
status_code=200,
107-
media_type='text/html; charset=utf-8',
108-
headers=constants.DEFAULT_HEADERS
109-
)
110-
111-
stack = stack_aria_gunw(reference)
112-
response_info = as_output(stack, output=output)
113-
return Response(**response_info)
99+
is_frame_based = searchOptions.opts.dataset is not None
100+
114101
# Load the reference scene:
115102

116103
if output.lower() == 'python':
@@ -125,15 +112,24 @@ async def query_baseline(searchOptions: BaselineSearchOptsModel = Depends(proces
125112
'Content-Disposition': f"attachment; filename={file_name}",
126113
}
127114
)
128-
try:
129-
reference_product = asf.granule_search(granule_list=[reference], opts=opts)[0]
130-
except (KeyError, IndexError, ValueError) as exc:
131-
raise HTTPException(detail=f"Reference scene not found: {reference}", status_code=400) from exc
115+
116+
# reference_product = None
117+
if is_frame_based and opts.dataset[0] == asf.DATASET.ARIA_S1_GUNW:
118+
try:
119+
reference_product = asf.search(frame=int(reference), opts=opts, maxResults=1)[0]
120+
except (KeyError, IndexError, ValueError) as exc:
121+
raise HTTPException(detail=f"Reference scene not found with frame: {reference}", status_code=400) from exc
122+
123+
else:
124+
try:
125+
reference_product = asf.granule_search(granule_list=[reference], opts=opts)[0]
126+
except (KeyError, IndexError, ValueError) as exc:
127+
raise HTTPException(detail=f"Reference scene not found: {reference}", status_code=400) from exc
132128

133129
try:
134130
if reference_product.get_stack_opts() is None:
135131
reference_product = asf.ASFStackableProduct(args={'umm': reference_product.umm, 'meta': reference_product.meta}, session=reference_product.session)
136-
if not reference_product.has_baseline() or not reference_product.is_valid_reference():
132+
if (not reference_product.has_baseline() or not reference_product.is_valid_reference() or not reference_product.has_baseline()) and not is_frame_based:
137133
raise asf.exceptions.ASFBaselineError(f"Requested reference scene has no baseline")
138134
except (asf.exceptions.ASFBaselineError, ValueError) as exc:
139135
raise HTTPException(detail=f"Search failed to find results: {exc}", status_code=400)

src/SearchAPI/application/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class SearchOptsModel(BaseModel):
1414
"""
1515
opts: InstanceOf[ASFSearchOptions]
1616
request_method: str # ["GET", "POST", "HEAD"]
17-
output: Optional[str] = 'metalink'
17+
output: str = 'metalink'
1818
merged_args: dict = {}
1919

2020
output_types: ClassVar[list[str]] = ['metalink', 'csv', 'geojson', 'json', 'jsonlite', 'jsonlite2', 'kml', 'count', 'download', 'python']

src/SearchAPI/application/search.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)