Skip to content

Commit

Permalink
Merge pull request #231 from ASFHyP3/develop
Browse files Browse the repository at this point in the history
Release v0.5.1
  • Loading branch information
asjohnston-asf authored Aug 28, 2020
2 parents 3fcc15f + 7f855d5 commit e2ef096
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ 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).

## [0.5.1]
### Fixed
- Resolved HTTP 500 error when submitting jobs with a resolution with decimal precision (e.g. `30.0`)

## [0.5.0]
### Changed
- The `dem_matching`, `speckle_filter`, `include_dem`, and `include_inc_map` api parameters are now booleans instead of strings.
Expand Down
4 changes: 3 additions & 1 deletion api/src/hyp3_api/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from flask_cors import CORS

from hyp3_api import DYNAMODB_RESOURCE, connexion_app
from hyp3_api.util import format_time, get_remaining_jobs_for_user, get_request_time_expression
from hyp3_api.util import convert_floats_to_decimals, format_time, get_remaining_jobs_for_user, \
get_request_time_expression
from hyp3_api.validation import GranuleValidationError, validate_granules


Expand Down Expand Up @@ -62,6 +63,7 @@ def post_jobs(body, user):
job['status_code'] = 'PENDING'
job['request_time'] = request_time
if not body.get('validate_only'):
job = convert_floats_to_decimals(job)
table.put_item(Item=job)

return body
Expand Down
11 changes: 11 additions & 0 deletions api/src/hyp3_api/util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from datetime import datetime, timezone
from decimal import Decimal
from os import environ

from boto3.dynamodb.conditions import Key
Expand Down Expand Up @@ -39,3 +40,13 @@ def get_request_time_expression(start, end):
return key.gte(formatted_start)
if formatted_end:
return key.lte(formatted_end)


def convert_floats_to_decimals(element):
if type(element) is float:
return Decimal(element)
if type(element) is list:
return [convert_floats_to_decimals(item) for item in element]
if type(element) is dict:
return {key: convert_floats_to_decimals(value) for key, value in element.items()}
return element
3 changes: 2 additions & 1 deletion api/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def make_job(granule='S1B_IW_SLC__1SDV_20200604T082207_20200604T082234_021881_02
job = {
'job_type': job_type,
'job_parameters': {
'granule': granule
'granule': granule,
'resolution': 30.0,
}
}
if name is not None:
Expand Down

0 comments on commit e2ef096

Please sign in to comment.