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

Release v7.10.0 #2443

Merged
merged 129 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
fd5745f
support for multi burst insar
AndrewPlayer3 Aug 16, 2024
e7c8c91
change back to granules
AndrewPlayer3 Aug 16, 2024
fe0f185
updated changelog for multi_burst
AndrewPlayer3 Aug 16, 2024
eefe263
regex to match 1 or more bursts
AndrewPlayer3 Aug 16, 2024
4f19f38
cleaner regex
AndrewPlayer3 Aug 16, 2024
5ad1a2c
removed max length
AndrewPlayer3 Aug 16, 2024
73f26bb
updated regex
AndrewPlayer3 Aug 19, 2024
7408de1
Bump setuptools from 72.1.0 to 72.2.0
dependabot[bot] Aug 19, 2024
8087959
Bump cfn-lint from 1.9.7 to 1.10.3
dependabot[bot] Aug 19, 2024
5594006
Bump openapi-core from 0.19.2 to 0.19.3
dependabot[bot] Aug 19, 2024
f4d69ab
Bump boto3 from 1.34.159 to 1.35.0
dependabot[bot] Aug 19, 2024
bbf5aa3
changed insar_multi_burst to use reference and secondary
AndrewPlayer3 Aug 19, 2024
d5143e3
better examples
AndrewPlayer3 Aug 19, 2024
8e00156
changed from {} to set()
AndrewPlayer3 Aug 19, 2024
11c6a04
Update job_spec/INSAR_MULTI_BURST.yml
AndrewPlayer3 Aug 19, 2024
1607914
Update job_spec/INSAR_MULTI_BURST.yml
AndrewPlayer3 Aug 19, 2024
c8aeac0
Update job_spec/INSAR_MULTI_BURST.yml
AndrewPlayer3 Aug 19, 2024
92fa149
cast to set
AndrewPlayer3 Aug 19, 2024
d4621cc
Merge branch 'insar_multi_burst' of https://github.com/asfhyp3/hyp3 i…
AndrewPlayer3 Aug 19, 2024
c56db78
Update CHANGELOG.md
AndrewPlayer3 Aug 19, 2024
446ad75
granules =
AndrewPlayer3 Aug 19, 2024
2918f12
Merge branch 'insar_multi_burst' of https://github.com/asfhyp3/hyp3 i…
AndrewPlayer3 Aug 19, 2024
dafae41
added reference and secondary cases to test_get_granules
AndrewPlayer3 Aug 19, 2024
566279d
remove cast to set
AndrewPlayer3 Aug 19, 2024
19e3e8a
Update apps/api/src/hyp3_api/util.py
AndrewPlayer3 Aug 19, 2024
ab52deb
Merge pull request #2384 from ASFHyP3/dependabot/pip/boto3-1.35.0
jtherrmann Aug 19, 2024
28149ca
Merge branch 'develop' into dependabot/pip/openapi-core-0.19.3
jtherrmann Aug 19, 2024
214f5a0
Bump moto[dynamodb] from 5.0.12 to 5.0.13
dependabot[bot] Aug 19, 2024
1a104ee
Merge pull request #2383 from ASFHyP3/dependabot/pip/openapi-core-0.19.3
jtherrmann Aug 19, 2024
62a30e6
Merge pull request #2382 from ASFHyP3/dependabot/pip/moto-dynamodb--5…
jtherrmann Aug 19, 2024
4a47bb5
Merge pull request #2381 from ASFHyP3/dependabot/pip/cfn-lint-1.10.3
jtherrmann Aug 19, 2024
e32529b
Merge branch 'develop' into dependabot/pip/setuptools-72.2.0
jtherrmann Aug 19, 2024
62bb98b
Merge pull request #2379 from ASFHyP3/insar_multi_burst
AndrewPlayer3 Aug 19, 2024
1a3f99f
Merge pull request #2380 from ASFHyP3/dependabot/pip/setuptools-72.2.0
jtherrmann Aug 19, 2024
89b15cc
fix INSAR_MULTI_BURST example scene names
jtherrmann Aug 19, 2024
c228650
30 max bursts
jtherrmann Aug 20, 2024
5039ca0
Update job_spec/INSAR_MULTI_BURST.yml
jtherrmann Aug 20, 2024
e4dd8b4
Update job_spec/INSAR_MULTI_BURST.yml
jtherrmann Aug 20, 2024
61631a7
Merge pull request #2385 from ASFHyP3/multi-burst-scene-names
jtherrmann Aug 20, 2024
9511e33
support more than 2 granules for burst validation
AndrewPlayer3 Aug 20, 2024
ae04d2a
updated validation tests for multi burst
AndrewPlayer3 Aug 20, 2024
8d60963
INSAR_MULTI_BURST to INSAR_ISCE_BURST
AndrewPlayer3 Aug 20, 2024
518484c
updated examples
AndrewPlayer3 Aug 20, 2024
6a57ea1
Merge branch 'develop' of https://github.com/asfhyp3/hyp3 into insar_…
AndrewPlayer3 Aug 20, 2024
0734ba9
updated changelog
AndrewPlayer3 Aug 20, 2024
f521d68
single burst example and 30 max lim
AndrewPlayer3 Aug 20, 2024
0c183a3
line too long
AndrewPlayer3 Aug 20, 2024
988417b
unsupported polarization match
AndrewPlayer3 Aug 20, 2024
b8aecaa
better changelog
AndrewPlayer3 Aug 20, 2024
261f736
add hyp3-multi-burst-sandbox deployment
jtherrmann Aug 20, 2024
42d4b53
Update CHANGELOG.md
AndrewPlayer3 Aug 21, 2024
5049bd9
Update CHANGELOG.md
AndrewPlayer3 Aug 21, 2024
ee88d1f
Update job_spec/INSAR_ISCE_BURST.yml
AndrewPlayer3 Aug 21, 2024
42c9ac4
Update job_spec/INSAR_ISCE_BURST.yml
AndrewPlayer3 Aug 21, 2024
d467d5e
Update job_spec/INSAR_ISCE_BURST.yml
AndrewPlayer3 Aug 21, 2024
586765a
Update apps/api/src/hyp3_api/validation.py
AndrewPlayer3 Aug 21, 2024
5836b33
only 2 burst ids
AndrewPlayer3 Aug 21, 2024
f96cb5a
add 3 burst_id invalid case
AndrewPlayer3 Aug 21, 2024
26566f6
modify validation to pass job and granule_metadata for flexibility
AndrewPlayer3 Aug 21, 2024
49f0ab3
INSAR_ISCE_BURST cases in test_validate_jobs
AndrewPlayer3 Aug 21, 2024
8cc4e6f
flake8
AndrewPlayer3 Aug 21, 2024
fc5eeb7
refactors
AndrewPlayer3 Aug 22, 2024
ae32b23
Update job_spec/INSAR_ISCE_BURST.yml
AndrewPlayer3 Aug 22, 2024
cbd66f3
Update job_spec/INSAR_ISCE_BURST.yml
AndrewPlayer3 Aug 22, 2024
3ddc433
flake8
AndrewPlayer3 Aug 22, 2024
023b3d2
Merge branch 'insar_multi_burst' of https://github.com/asfhyp3/hyp3 i…
AndrewPlayer3 Aug 22, 2024
f150ff5
Update apps/api/src/hyp3_api/validation.py
AndrewPlayer3 Aug 22, 2024
045f250
better loop
AndrewPlayer3 Aug 22, 2024
bd25562
Merge branch 'insar_multi_burst' of https://github.com/asfhyp3/hyp3 i…
AndrewPlayer3 Aug 22, 2024
211004e
Update apps/api/src/hyp3_api/validation.py
AndrewPlayer3 Aug 22, 2024
fd8cb6a
Merge pull request #2386 from ASFHyP3/insar_multi_burst
AndrewPlayer3 Aug 22, 2024
b5a4156
Add burst job reformatting to Changelog
jtherrmann Aug 22, 2024
219cbcf
Merge pull request #2388 from ASFHyP3/burst-reformat-changelog
jtherrmann Aug 22, 2024
d8179b2
Merge branch 'develop' into multi-burst-sandbox
jtherrmann Aug 23, 2024
9737267
allow 30 burst pairs
jtherrmann Aug 30, 2024
0a892ec
better burst id validation
AndrewPlayer3 Sep 3, 2024
dc5195c
Update apps/api/src/hyp3_api/validation.py
AndrewPlayer3 Sep 3, 2024
6f60c8f
Merge pull request #2408 from ASFHyP3/burst-id-validation
jtherrmann Sep 3, 2024
58ea5f1
Merge branch 'develop' into multi-burst-sandbox
jtherrmann Sep 3, 2024
3d4168c
Merge branch 'develop' into multi-burst-sandbox
jtherrmann Sep 4, 2024
580b60b
increase insar burst memory
jtherrmann Sep 4, 2024
80ab87c
add override_memory lambda
jtherrmann Sep 5, 2024
313dc79
Merge pull request #2411 from ASFHyP3/memory-lambda
jtherrmann Sep 5, 2024
b44a607
test override_memory
jtherrmann Sep 5, 2024
9ae9235
import order
jtherrmann Sep 5, 2024
7077371
add job types to multi-burst-sandbox
jtherrmann Sep 5, 2024
0c12d18
memory as str
jtherrmann Sep 5, 2024
79e76fc
rename tests
jtherrmann Sep 5, 2024
b003f56
fix autorift memory checks
jtherrmann Sep 5, 2024
ed6b670
revert burst memory increase
jtherrmann Sep 5, 2024
727b158
rename lambda to set_container_overrides
jtherrmann Sep 6, 2024
d5039b7
burst memory intervals
jtherrmann Sep 6, 2024
a334f20
burst interval
jtherrmann Sep 6, 2024
5bb28a0
todo
jtherrmann Sep 6, 2024
265254d
split bursts list, catch error
jtherrmann Sep 6, 2024
2493f43
adjust memory intervals
jtherrmann Sep 9, 2024
0a227d0
increase insar burst timeout
jtherrmann Sep 9, 2024
a494332
disallow 25 bursts at 5x1 looks
jtherrmann Sep 10, 2024
e8796e1
rename set_container_overrides to set_batch_overrides
jtherrmann Sep 10, 2024
6045f7d
Merge branch 'develop' into multi-burst-sandbox
jtherrmann Sep 10, 2024
5fc1192
allow 5x1 burst insar up to 30 bursts
jtherrmann Sep 10, 2024
5ff382e
Merge branch 'multi-burst-sandbox' of github.com:ASFHyP3/hyp3 into mu…
jtherrmann Sep 10, 2024
daf6368
memory constants
jtherrmann Sep 11, 2024
7356070
add tests for insar burst memory
jtherrmann Sep 11, 2024
0af281f
set default insar burst memory to 0
jtherrmann Sep 11, 2024
898f624
set omp_num_threads for multi-burst insar
jtherrmann Sep 11, 2024
3630252
comment
jtherrmann Sep 11, 2024
b1b3bf6
flake8 import order
jtherrmann Sep 11, 2024
fef9152
rename function
jtherrmann Sep 11, 2024
b6f1509
set burst insar memory default to 4
jtherrmann Sep 11, 2024
e886271
json trailing comma
jtherrmann Sep 11, 2024
de08391
adjust memory interval for 10x2
jtherrmann Sep 12, 2024
d87abd0
Merge branch 'develop' into multi-burst-sandbox
jtherrmann Sep 14, 2024
bcd3ae8
Merge branch 'develop' into multi-burst-sandbox
jtherrmann Sep 30, 2024
4ad3805
Merge branch 'develop' into multi-burst-sandbox
jtherrmann Sep 30, 2024
a3c337e
split into two burst job specs
jtherrmann Oct 1, 2024
5ca97e7
Add issue link to TODO comments
jtherrmann Oct 1, 2024
797240c
add a TODO
jtherrmann Oct 1, 2024
dcda039
delete old changelog entry
jtherrmann Oct 1, 2024
9caca9b
delete blank line
jtherrmann Oct 1, 2024
7aba1cd
break long lines
jtherrmann Oct 1, 2024
7da5dda
changelog
jtherrmann Oct 1, 2024
d2d5f1f
reword
jtherrmann Oct 1, 2024
3b969e7
reword again
jtherrmann Oct 1, 2024
55cb993
de-indent
jtherrmann Oct 1, 2024
faedcbb
reword
jtherrmann Oct 1, 2024
da89511
add TODO
jtherrmann Oct 1, 2024
3e2789a
refactor ref, sec unpacking
jtherrmann Oct 1, 2024
cbf6106
Merge pull request #2389 from ASFHyP3/multi-burst-sandbox
jtherrmann Oct 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .github/workflows/deploy-multi-burst-sandbox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Deploy Multi-Burst Sandbox Stack to AWS

on:
push:
branches:
- multi-burst-sandbox

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
deploy:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- environment: hyp3-multi-burst-sandbox
domain: hyp3-multi-burst-sandbox.asf.alaska.edu
template_bucket: cf-templates-1hz9ldhhl4ahu-us-west-2
image_tag: test
product_lifetime_in_days: 14
default_credits_per_user: 0
default_application_status: APPROVED
cost_profile: DEFAULT
deploy_ref: refs/heads/multi-burst-sandbox
job_files: >-
job_spec/INSAR_ISCE_BURST.yml
job_spec/INSAR_ISCE_MULTI_BURST.yml
job_spec/AUTORIFT.yml
job_spec/RTC_GAMMA.yml
job_spec/WATER_MAP.yml
job_spec/WATER_MAP_EQ.yml
instance_types: r6id.xlarge,r6id.2xlarge,r6id.4xlarge,r6id.8xlarge,r6idn.xlarge,r6idn.2xlarge,r6idn.4xlarge,r6idn.8xlarge
default_max_vcpus: 640
expanded_max_vcpus: 640
required_surplus: 0
security_environment: ASF
ami_id: /aws/service/ecs/optimized-ami/amazon-linux-2023/recommended/image_id
distribution_url: ''

environment:
name: ${{ matrix.environment }}
url: https://${{ matrix.domain }}

steps:
- uses: actions/[email protected]

- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.V2_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.V2_AWS_SECRET_ACCESS_KEY }}
aws-session-token: ${{ secrets.V2_AWS_SESSION_TOKEN }}
aws-region: ${{ secrets.AWS_REGION }}

- uses: actions/setup-python@v5
with:
python-version: 3.9

- uses: ./.github/actions/deploy-hyp3
with:
TEMPLATE_BUCKET: ${{ matrix.template_bucket }}
STACK_NAME: ${{ matrix.environment }}
DOMAIN_NAME: ${{ matrix.domain }}
API_NAME: ${{ matrix.environment }}
CERTIFICATE_ARN: ${{ secrets.CERTIFICATE_ARN }}
IMAGE_TAG: ${{ matrix.image_tag }}
PRODUCT_LIFETIME: ${{ matrix.product_lifetime_in_days }}
VPC_ID: ${{ secrets.VPC_ID }}
SUBNET_IDS: ${{ secrets.SUBNET_IDS }}
SECRET_ARN: ${{ secrets.SECRET_ARN }}
CLOUDFORMATION_ROLE_ARN: ${{ secrets.CLOUDFORMATION_ROLE_ARN }}
DEFAULT_CREDITS_PER_USER: ${{ matrix.default_credits_per_user }}
DEFAULT_APPLICATION_STATUS: ${{ matrix.default_application_status }}
COST_PROFILE: ${{ matrix.cost_profile }}
JOB_FILES: ${{ matrix.job_files }}
DEFAULT_MAX_VCPUS: ${{ matrix.default_max_vcpus }}
EXPANDED_MAX_VCPUS: ${{ matrix.expanded_max_vcpus }}
MONTHLY_BUDGET: ${{ secrets.MONTHLY_BUDGET }}
REQUIRED_SURPLUS: ${{ matrix.required_surplus }}
ORIGIN_ACCESS_IDENTITY_ID: ${{ secrets.ORIGIN_ACCESS_IDENTITY_ID }}
SECURITY_ENVIRONMENT: ${{ matrix.security_environment }}
AMI_ID: ${{ matrix.ami_id }}
INSTANCE_TYPES: ${{ matrix.instance_types }}
DISTRIBUTION_URL: ${{ matrix.distribution_url }}
AUTH_PUBLIC_KEY: ${{ secrets.AUTH_PUBLIC_KEY }}
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [7.10.0]

### Added
- Added a new `INSAR_ISCE_MULTI_BURST` job type for running multi-burst InSAR. Currently, this job type is restricted to a special `hyp3-multi-burst-sandbox` deployment for HyP3 operators. However, this is an important step toward eventually making multi-burst InSAR available for general users.

### Changed
- Job validator functions now accept two parameters: the job dictionary and the granule metadata.
- Granule metadata validation now supports `reference` and `secondary` job parameters in addition to the existing `granules` parameter.
- Burst InSAR validators now support multi-burst jobs.
- Replaced the step function's `INSPECT_MEMORY_REQUIREMENTS` step with a new `SET_BATCH_OVERRIDES` step, which calls a Lambda function to dynamically calculate [Batch container overrides](https://docs.aws.amazon.com/batch/latest/APIReference/API_ContainerOverrides.html) based on job type and parameters.

## [7.9.3]
### Fixed
- Added missing cloudformation:DeleteStack permission to cloudformation deployment role in ASF-deployment-ci-cf.yml .
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ API = ${PWD}/apps/api/src
CHECK_PROCESSING_TIME = ${PWD}/apps/check-processing-time/src
GET_FILES = ${PWD}/apps/get-files/src
HANDLE_BATCH_EVENT = ${PWD}/apps/handle-batch-event/src
SET_BATCH_OVERRIDES = ${PWD}/apps/set-batch-overrides/src
SCALE_CLUSTER = ${PWD}/apps/scale-cluster/src
START_EXECUTION_MANAGER = ${PWD}/apps/start-execution-manager/src
START_EXECUTION_WORKER = ${PWD}/apps/start-execution-worker/src
DISABLE_PRIVATE_DNS = ${PWD}/apps/disable-private-dns/src
UPDATE_DB = ${PWD}/apps/update-db/src
UPLOAD_LOG = ${PWD}/apps/upload-log/src
DYNAMO = ${PWD}/lib/dynamo
export PYTHONPATH = ${API}:${CHECK_PROCESSING_TIME}:${GET_FILES}:${HANDLE_BATCH_EVENT}:${SCALE_CLUSTER}:${START_EXECUTION_MANAGER}:${START_EXECUTION_WORKER}:${DISABLE_PRIVATE_DNS}:${UPDATE_DB}:${UPLOAD_LOG}:${DYNAMO}
export PYTHONPATH = ${API}:${CHECK_PROCESSING_TIME}:${GET_FILES}:${HANDLE_BATCH_EVENT}:${SET_BATCH_OVERRIDES}:${SCALE_CLUSTER}:${START_EXECUTION_MANAGER}:${START_EXECUTION_WORKER}:${DISABLE_PRIVATE_DNS}:${UPDATE_DB}:${UPLOAD_LOG}:${DYNAMO}


build: render
Expand Down Expand Up @@ -44,7 +45,7 @@ render:
static: flake8 openapi-validate cfn-lint

flake8:
flake8 --ignore=E731 --max-line-length=120 --import-order-style=pycharm --statistics --application-import-names hyp3_api,get_files,handle_batch_event,check_processing_time,start_execution_manager,start_execution_worker,disable_private_dns,update_db,upload_log,dynamo,lambda_logging,scale_cluster apps tests lib
flake8 --ignore=E731 --max-line-length=120 --import-order-style=pycharm --statistics --application-import-names hyp3_api,get_files,handle_batch_event,set_batch_overrides,check_processing_time,start_execution_manager,start_execution_worker,disable_private_dns,update_db,upload_log,dynamo,lambda_logging,scale_cluster apps tests lib

openapi-validate: render
openapi-spec-validator apps/api/src/hyp3_api/api-spec/openapi-spec.yml
Expand Down
7 changes: 6 additions & 1 deletion apps/api/src/hyp3_api/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ class TokenDeserializeError(Exception):


def get_granules(jobs: list[dict]) -> set[str]:
return {granule for job in jobs for granule in job['job_parameters'].get('granules', [])}
return {
granule
for key in ['granules', 'reference', 'secondary']
for job in jobs
for granule in job['job_parameters'].get(key, [])
}


def serialize(payload: dict):
Expand Down
58 changes: 44 additions & 14 deletions apps/api/src/hyp3_api/validation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
import sys
from copy import deepcopy
from pathlib import Path

import requests
Expand Down Expand Up @@ -70,31 +71,47 @@ def check_granules_exist(granules, granule_metadata):
raise GranuleValidationError(f'Some requested scenes could not be found: {", ".join(not_found_granules)}')


def check_dem_coverage(granule_metadata):
def check_dem_coverage(_, granule_metadata):
bad_granules = [g['name'] for g in granule_metadata if not has_sufficient_coverage(g['polygon'])]
if bad_granules:
raise GranuleValidationError(f'Some requested scenes do not have DEM coverage: {", ".join(bad_granules)}')


def check_same_burst_ids(granule_metadata):
ref_burst_id, sec_burst_id = [granule['name'].split('_')[1] for granule in granule_metadata]
if ref_burst_id != sec_burst_id:
def check_same_burst_ids(job, _):
refs = job['job_parameters']['reference']
secs = job['job_parameters']['secondary']
ref_ids = ['_'.join(ref.split('_')[1:3]) for ref in refs]
sec_ids = ['_'.join(sec.split('_')[1:3]) for sec in secs]
if len(ref_ids) != len(sec_ids):
raise GranuleValidationError(
f'The requested scenes do not have the same burst ID: {ref_burst_id} and {sec_burst_id}'
f'Number of reference and secondary scenes must match, got: '
f'{len(ref_ids)} references and {len(sec_ids)} secondaries'
)
for i in range(len(ref_ids)):
if ref_ids[i] != sec_ids[i]:
raise GranuleValidationError(
f'Burst IDs do not match for {refs[i]} and {secs[i]}.'
)
if len(set(ref_ids)) != len(ref_ids):
duplicate_pair_id = next(ref_id for ref_id in ref_ids if ref_ids.count(ref_id) > 1)
raise GranuleValidationError(
f'The requested scenes have more than 1 pair with the following burst ID: {duplicate_pair_id}.'
)


def check_valid_polarizations(granule_metadata):
ref_polarization, sec_polarization = [granule['name'].split('_')[4] for granule in granule_metadata]
if ref_polarization != sec_polarization:
def check_valid_polarizations(job, _):
polarizations = set(granule.split('_')[4] for granule in get_granules([job]))
if len(polarizations) > 1:
raise GranuleValidationError(
f'The requested scenes need to have the same polarization, got: {", ".join(polarizations)}'
)
if not polarizations.issubset({'VV', 'HH'}):
raise GranuleValidationError(
f'The requested scenes do not have the same polarization: {ref_polarization} and {sec_polarization}'
f'Only VV and HH polarizations are currently supported, got: {polarizations.pop()}'
)
if ref_polarization != 'VV' and ref_polarization != 'HH':
raise GranuleValidationError(f'Only VV and HH polarizations are currently supported, got: {ref_polarization}')


def check_not_antimeridian(granule_metadata):
def check_not_antimeridian(_, granule_metadata):
for granule in granule_metadata:
bbox = granule['polygon'].bounds
if abs(bbox[0] - bbox[2]) > 180.0 and bbox[0] * bbox[2] < 0.0:
Expand All @@ -119,7 +136,20 @@ def get_multipolygon_from_geojson(input_file):
return MultiPolygon(polygons)


def validate_jobs(jobs):
# TODO https://github.com/ASFHyP3/hyp3/issues/2442 remove this function after two burst types are merged
def convert_single_burst_jobs(jobs: list[dict]) -> list[dict]:
jobs = deepcopy(jobs)
for job in jobs:
if job['job_type'] == 'INSAR_ISCE_BURST':
job_parameters = job['job_parameters']
ref, sec = job_parameters.pop('granules')
job_parameters['reference'], job_parameters['secondary'] = [ref], [sec]
return jobs


def validate_jobs(jobs: list[dict]) -> None:
jobs = convert_single_burst_jobs(jobs)

granules = get_granules(jobs)
granule_metadata = get_cmr_metadata(granules)

Expand All @@ -129,4 +159,4 @@ def validate_jobs(jobs):
job_granule_metadata = [granule for granule in granule_metadata if granule['name'] in get_granules([job])]
module = sys.modules[__name__]
validator = getattr(module, validator_name)
validator(job_granule_metadata)
validator(job, job_granule_metadata)
76 changes: 76 additions & 0 deletions apps/set-batch-overrides/set-batch-overrides-cf.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
AWSTemplateFormatVersion: 2010-09-09

{% if security_environment == 'EDC' %}
Parameters:

SecurityGroupId:
Type: String

SubnetIds:
Type: CommaDelimitedList
{% endif %}

Outputs:

LambdaArn:
Value: !GetAtt Lambda.Arn

Resources:

LogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub "/aws/lambda/${Lambda}"
RetentionInDays: 90

Role:
Type: {{ 'Custom::JplRole' if security_environment in ('JPL', 'JPL-public') else 'AWS::IAM::Role' }}
Properties:
{% if security_environment in ('JPL', 'JPL-public') %}
ServiceToken: !ImportValue Custom::JplRole::ServiceToken
Path: /account-managed/hyp3/
{% endif %}
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
Action: sts:AssumeRole
Principal:
Service: lambda.amazonaws.com
Effect: Allow
ManagedPolicyArns:
- !Ref Policy
{% if security_environment == 'EDC' %}
- arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole
{% endif %}

Policy:
Type: {{ 'Custom::JplPolicy' if security_environment in ('JPL', 'JPL-public') else 'AWS::IAM::ManagedPolicy' }}
Properties:
{% if security_environment in ('JPL', 'JPL-public') %}
ServiceToken: !ImportValue Custom::JplPolicy::ServiceToken
Path: /account-managed/hyp3/
{% endif %}
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- logs:CreateLogStream
- logs:PutLogEvents
Resource: !Sub "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/*"

Lambda:
Type: AWS::Lambda::Function
Properties:
Code: src/
Handler: set_batch_overrides.lambda_handler
MemorySize: 128
Role: !GetAtt Role.Arn
Runtime: python3.9
Timeout: 30
{% if security_environment == 'EDC' %}
VpcConfig:
SecurityGroupIds:
- !Ref SecurityGroupId
SubnetIds: !Ref SubnetIds
{% endif %}
Loading
Loading