Skip to content

Commit e2ef096

Browse files
Merge pull request #231 from ASFHyP3/develop
Release v0.5.1
2 parents 3fcc15f + 7f855d5 commit e2ef096

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.5.1]
8+
### Fixed
9+
- Resolved HTTP 500 error when submitting jobs with a resolution with decimal precision (e.g. `30.0`)
10+
711
## [0.5.0]
812
### Changed
913
- The `dem_matching`, `speckle_filter`, `include_dem`, and `include_inc_map` api parameters are now booleans instead of strings.

api/src/hyp3_api/handlers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
from flask_cors import CORS
1212

1313
from hyp3_api import DYNAMODB_RESOURCE, connexion_app
14-
from hyp3_api.util import format_time, get_remaining_jobs_for_user, get_request_time_expression
14+
from hyp3_api.util import convert_floats_to_decimals, format_time, get_remaining_jobs_for_user, \
15+
get_request_time_expression
1516
from hyp3_api.validation import GranuleValidationError, validate_granules
1617

1718

@@ -62,6 +63,7 @@ def post_jobs(body, user):
6263
job['status_code'] = 'PENDING'
6364
job['request_time'] = request_time
6465
if not body.get('validate_only'):
66+
job = convert_floats_to_decimals(job)
6567
table.put_item(Item=job)
6668

6769
return body

api/src/hyp3_api/util.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from datetime import datetime, timezone
2+
from decimal import Decimal
23
from os import environ
34

45
from boto3.dynamodb.conditions import Key
@@ -39,3 +40,13 @@ def get_request_time_expression(start, end):
3940
return key.gte(formatted_start)
4041
if formatted_end:
4142
return key.lte(formatted_end)
43+
44+
45+
def convert_floats_to_decimals(element):
46+
if type(element) is float:
47+
return Decimal(element)
48+
if type(element) is list:
49+
return [convert_floats_to_decimals(item) for item in element]
50+
if type(element) is dict:
51+
return {key: convert_floats_to_decimals(value) for key, value in element.items()}
52+
return element

api/tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ def make_job(granule='S1B_IW_SLC__1SDV_20200604T082207_20200604T082234_021881_02
5151
job = {
5252
'job_type': job_type,
5353
'job_parameters': {
54-
'granule': granule
54+
'granule': granule,
55+
'resolution': 30.0,
5556
}
5657
}
5758
if name is not None:

0 commit comments

Comments
 (0)