Skip to content

Commit

Permalink
Merge pull request #2568 from ASFHyP3/check-bounds-size
Browse files Browse the repository at this point in the history
Add validator for SRG jobs to check bounds size
  • Loading branch information
williamh890 authored Jan 23, 2025
2 parents 9ecc135 + 2e4d4f8 commit 7f2b59e
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 18 deletions.
32 changes: 20 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ 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).

## [9.3.0]

### Added
- Added validator to check that bounds provided are smaller than maximum size for SRG jobs

### Removed
- Removed default bounds option for SRG jobs

## [9.2.1]

### Added
Expand Down Expand Up @@ -350,7 +358,7 @@ HyP3's monthly quota system has been replaced by a credits system. Previously, H
### Changed
- Update `INSAR_ISCE` and `INSAR_ISCE_TEST` job spec for GUNW version 3+ standard and custom products
- `frame_id` is now a required parameter and has no default
- `compute_solid_earth_tide` and `estimate_ionosphere_delay` now default to `true`
- `compute_solid_earth_tide` and `estimate_ionosphere_delay` now default to `true`
- `INSAR_ISCE_TEST` exposes custom `goldstein_filter_power`, `output_resolution`, `dense_offsets`, and `unfiltered_coherence` parameters

## [4.4.1]
Expand Down Expand Up @@ -432,7 +440,7 @@ HyP3's monthly quota system has been replaced by a credits system. Previously, H
## [3.10.8]
### Changed
- HyP3 deployments at JPL now use On Demand instances instead of Spot instances to prevent `INSAR_ISCE` jobs from being interrupted.
This *should* be a temporary change.
This *should* be a temporary change.

## [3.10.7]
### Changed
Expand Down Expand Up @@ -576,7 +584,7 @@ HyP3's monthly quota system has been replaced by a credits system. Previously, H
## [3.2.0]
### Added
- [`job_spec`s](job_spec/) can now specify a required set of secrets and an AWS Secrets Manage Secret ARN to pull the
secret values from. Notably, secrets are now externally managed and not part of the HyP3 stack.
secret values from. Notably, secrets are now externally managed and not part of the HyP3 stack.

## [3.1.2]
### Added
Expand All @@ -601,13 +609,13 @@ HyP3's monthly quota system has been replaced by a credits system. Previously, H
- The `flood_depth_estimator` parameter for `WATER_MAP` jobs is now restricted to a set of possible values.
- Changed the default value for the `flood_depth_estimator` parameter for `WATER_MAP` jobs from `iterative` to `None`.
A value of `None` indicates that a flood map will not be included.
- Reduced `ITS_LIVE` product lifetime cycle from 180 days to 45 days.
- Reduced `ITS_LIVE` product lifetime cycle from 180 days to 45 days.
### Removed
- Removed the `include_flood_depth` parameter for `WATER_MAP` jobs.

## [2.25.0]
### Added
- `INSAR_ISCE` and `INSAR_ISCE_TEST` jobs now accept a `weather_model` parameter to specify which weather model to use
- `INSAR_ISCE` and `INSAR_ISCE_TEST` jobs now accept a `weather_model` parameter to specify which weather model to use
when estimating trophospheric delay data.
- Increases the memory available to `AUTORIFT` jobs for Landsat pairs

Expand Down Expand Up @@ -647,7 +655,7 @@ HyP3's monthly quota system has been replaced by a credits system. Previously, H

## [2.21.8]
### Changed
- AUTORIFT jobs for Sentinel-2 scenes can now only be submitted using ESA naming convention.
- AUTORIFT jobs for Sentinel-2 scenes can now only be submitted using ESA naming convention.

## [2.21.7]
### Changed
Expand Down Expand Up @@ -706,7 +714,7 @@ HyP3's monthly quota system has been replaced by a credits system. Previously, H

## [2.19.4]
### Changed
- `scale-cluster` now adjusts the compute environment size based on total month-to-date spending, rather than only EC2
- `scale-cluster` now adjusts the compute environment size based on total month-to-date spending, rather than only EC2
spending.

## [2.19.3]
Expand Down Expand Up @@ -870,7 +878,7 @@ HyP3's monthly quota system has been replaced by a credits system. Previously, H
- `ASF` (default) -- AWS accounts managed by the Alaska Satellite Facility
- `EDC` -- AWS accounts managed by the NASA Earthdata CLoud
- `JPL` -- AWS accounts managed by the NASA Jet Propulsion Laboratory
- A `security_environment` Make variable used by the `render` target (and any target that depends on `render`).
- A `security_environment` Make variable used by the `render` target (and any target that depends on `render`).
Use like `make security_environment=ASF build`

### Changed
Expand Down Expand Up @@ -941,10 +949,10 @@ HyP3's monthly quota system has been replaced by a credits system. Previously, H

## [2.6.2](https://github.com/ASFHyP3/hyp3/compare/v2.6.1...v2.6.2)
### Added
- New `AmiId` stack parameter to specify a specific AMI for the AWS Batch compute environment
- New `AmiId` stack parameter to specify a specific AMI for the AWS Batch compute environment

### Changed
- `job_spec/*.yml` files are now explicitly selected allowing per-deployment job customization
- `job_spec/*.yml` files are now explicitly selected allowing per-deployment job customization

### Removed
- `AutoriftImage`, `AutoriftNamingScheme`, and `AutoriftParameterFile` CloudFormation stack parameters
Expand Down Expand Up @@ -999,7 +1007,7 @@ to the database but still validate it.
- `name` gets only subscriptions with the given name
- `job_type` gets only subscriptions with the given job type
- `enabled` gets only subscriptions where `enabled` matches
- subscriptions now include `creation_date` which indicates date and time of subscription creation, responses from
- subscriptions now include `creation_date` which indicates date and time of subscription creation, responses from
`GET /subscriptions` are sorted by `creation_date` decending


Expand Down Expand Up @@ -1038,7 +1046,7 @@ to the database but still validate it.
- `lib/dynamo` library to allow sharing common code among different apps.

## Changed
- `POST /jobs` responses no longer include the `job_id`, `request_time`, `status_code`, or `user_id` fields when `validate_only=true`
- `POST /jobs` responses no longer include the `job_id`, `request_time`, `status_code`, or `user_id` fields when `validate_only=true`
- moved dynamodb functionality from `hyp3_api/dynamo` to `lib/dynamo`
- moved job creation buisness logic from `hyp3_api/handlers` to `lib/dynamo`

Expand Down
11 changes: 11 additions & 0 deletions apps/api/src/hyp3_api/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,17 @@ def convert_single_burst_jobs(jobs: list[dict]) -> list[dict]:
return jobs


def check_bounding_box_size(job: dict, max_bounds_area: float = 4.5):
bounds = job['job_parameters']['bounds']

bounds_area = (bounds[3] - bounds[1]) * (bounds[2] - bounds[0])

if bounds_area > max_bounds_area:
raise BoundsValidationError(
f'Bounds must be smaller than {max_bounds_area} degrees squared. Box provided was {bounds_area:.2f}'
)


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

Expand Down
7 changes: 4 additions & 3 deletions job_spec/SRG_GSLC.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
SRG_GSLC:
required_parameters:
- granules
- bounds
parameters:
granules:
api_schema:
Expand All @@ -20,8 +21,7 @@ SRG_GSLC:
bounds:
api_schema:
type: array
description: Bounds for extent of processing, formatted like [min lon, min lat, max lon, max lat] in EPSG:4326. Setting to [0, 0, 0, 0] will use the extent of the first granule.
default: [0.0, 0.0, 0.0, 0.0]
description: Bounds for extent of processing, formatted like [min lon, min lat, max lon, max lat] in EPSG:4326.
minItems: 4
maxItems: 4
example:
Expand All @@ -35,7 +35,8 @@ SRG_GSLC:
validators: [
check_bounds_formatting,
check_granules_intersecting_bounds,
check_same_relative_orbits
check_same_relative_orbits,
check_bounding_box_size
]
cost_profiles:
DEFAULT:
Expand Down
7 changes: 4 additions & 3 deletions job_spec/SRG_TIME_SERIES.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
SRG_TIME_SERIES:
required_parameters:
- granules
- bounds
parameters:
granules:
api_schema:
Expand All @@ -21,8 +22,7 @@ SRG_TIME_SERIES:
bounds:
api_schema:
type: array
description: Bounds for extent of processing, formatted like [min lon, min lat, max lon, max lat] in EPSG:4326. Setting to [0, 0, 0, 0] will use the extent of the first granule.
default: [0.0, 0.0, 0.0, 0.0]
description: Bounds for extent of processing, formatted like [min lon, min lat, max lon, max lat] in EPSG:4326.
minItems: 4
maxItems: 4
example:
Expand All @@ -36,7 +36,8 @@ SRG_TIME_SERIES:
validators: [
check_bounds_formatting,
check_granules_intersecting_bounds,
check_same_relative_orbits
check_same_relative_orbits,
check_bounding_box_size
]
cost_profiles:
DEFAULT:
Expand Down
10 changes: 10 additions & 0 deletions tests/test_api/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,3 +536,13 @@ def test_check_same_relative_orbits():
error_pattern = r'.*69 is not 87.*'
with raises(validation.GranuleValidationError, match=error_pattern):
validation.check_same_relative_orbits({}, invalid_granule_metadata)


def test_check_bounding_box_size():
job = {'job_parameters': {'bounds': [0, 0, 10, 10]}}

validation.check_bounding_box_size(job, max_bounds_area=100)

error_pattern = r'.*Bounds must be smaller.*'
with raises(validation.BoundsValidationError, match=error_pattern):
validation.check_bounding_box_size(job, max_bounds_area=99.9)

0 comments on commit 7f2b59e

Please sign in to comment.