Skip to content

Commit

Permalink
Update aria jobs to use reference and secondary as params
Browse files Browse the repository at this point in the history
  • Loading branch information
williamh890 committed Feb 7, 2025
1 parent b8158ab commit dd39429
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
20 changes: 12 additions & 8 deletions src/hyp3_sdk/hyp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,14 @@ def prepare_insar_isce_burst_job(
job_dict['name'] = name
return job_dict

def submit_aria_s1_gunw_job(self, granule1: str, granule2: str, frame_id: int, name: str | None = None) -> Batch:
def submit_aria_s1_gunw_job(
self, reference: list[str], secondary: list[str], frame_id: int, name: str | None = None
) -> Batch:
"""Submit an ARIA S1 GUNW job.
Args:
granule1: The first granule (scene) to use
granule2: The second granule (scene) to use
reference: The name of the Sentinel-1 SLC granules to use as reference scenes for InSAR processing
secondary: The name of the Sentinel-1 SLC granules to use as secondary scenes for InSAR processing
frame_id: Subset GUNW products to this frame
name: A name for the job (optional)
Expand All @@ -519,24 +521,26 @@ def submit_aria_s1_gunw_job(self, granule1: str, granule2: str, frame_id: int, n
return self.submit_prepared_jobs(prepared_jobs=job_dict)

@classmethod
def prepare_aria_s1_gunw_job(cls, granule1: str, granule2: str, frame_id: int, name: str | None = None) -> dict:
def prepare_aria_s1_gunw_job(
cls, reference: list[str], secondary: list[str], frame_id: int, name: str | None = None
) -> dict:
"""Prepare an ARIA S1 GUNW job.
Args:
granule1: The first granule (scene) to use
granule2: The second granule (scene) to use
reference: The name of the Sentinel-1 SLC granules to use as reference scenes for InSAR processing
secondary: The name of the Sentinel-1 SLC granules to use as secondary scenes for InSAR processing
frame_id: Subset GUNW products to this frame
name: A name for the job
Returns:
A dictionary containing the prepared ARIA S1 GUNW job
"""
job_parameters = locals().copy()
for key in ['cls', 'granule1', 'granule2', 'frame_id', 'name']:
for key in ['cls', 'reference', 'secondary', 'frame_id', 'name']:
job_parameters.pop(key)

job_dict = {
'job_parameters': {'granules': [granule1, granule2], 'frame_id': frame_id, **job_parameters},
'job_parameters': {'reference': reference, 'secondary': secondary, 'frame_id': frame_id, **job_parameters},
'job_type': 'ARIA_S1_GUNW',
}
if name is not None:
Expand Down
21 changes: 15 additions & 6 deletions tests/test_hyp3.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,20 +322,27 @@ def test_prepare_insar_isce_burst_job():


def test_prepare_aria_s1_gunw_job():
assert HyP3.prepare_aria_s1_gunw_job(granule1='my_granule1', granule2='my_granule2', frame_id=100) == {
assert HyP3.prepare_aria_s1_gunw_job(
reference=['ref_granule1', 'ref_granule2'], secondary=['sec_granule1', 'sec_granule2'], frame_id=100
) == {
'job_type': 'ARIA_S1_GUNW',
'job_parameters': {
'granules': ['my_granule1', 'my_granule2'],
'reference': ['ref_granule1', 'ref_granule2'],
'secondary': ['sec_granule1', 'sec_granule2'],
'frame_id': 100,
},
}
assert HyP3.prepare_aria_s1_gunw_job(
granule1='my_granule1', granule2='my_granule2', frame_id=100, name='my_name'
reference=['ref_granule1', 'ref_granule2'],
secondary=['sec_granule1', 'sec_granule2'],
frame_id=100,
name='my_name',
) == {
'job_type': 'ARIA_S1_GUNW',
'name': 'my_name',
'job_parameters': {
'granules': ['my_granule1', 'my_granule2'],
'reference': ['ref_granule1', 'ref_granule2'],
'secondary': ['sec_granule1', 'sec_granule2'],
'frame_id': 100,
},
}
Expand Down Expand Up @@ -395,11 +402,13 @@ def test_submit_insar_isce_burst_job(get_mock_hyp3, get_mock_job):

@responses.activate
def test_submit_aria_s1_gunw_job(get_mock_hyp3, get_mock_job):
job = get_mock_job('ARIA_S1_GUNW', job_parameters={'granules': ['g1', 'g2'], 'frame_id': 100})
job = get_mock_job(
'ARIA_S1_GUNW', job_parameters={'reference': ['g1', 'g2'], 'secondary': ['g1', 'g2'], 'frame_id': 100}
)
api_response = {'jobs': [job.to_dict()]}
api = get_mock_hyp3()
responses.add(responses.POST, urljoin(api.url, '/jobs'), json=api_response)
batch = api.submit_aria_s1_gunw_job('g1', 'g2', 100)
batch = api.submit_aria_s1_gunw_job(['g1', 'g2'], ['g1', 'g2'], 100)
assert batch.jobs[0] == job


Expand Down

0 comments on commit dd39429

Please sign in to comment.