Skip to content

Conversation

@DerekFurstPitt
Copy link
Contributor

Modified datasets/prov-info and samples/prov-info to check the size of the
returned json before returning. If it is at (or near) the max for AWS,
return a 400 prompting the user to apply some optional parameters to reduce
the size. Changed the date values in datasets/prov-info and
datasets//prov-info by converting them to strings from datetime
objects. While they were datetime objects, they weren't valid json, so
dumping to json would result in a 500.

…f the

returned json before returning. If it is at (or near) the max for AWS,
return a 400 prompting the user to apply some optional parameters to reduce
the size. Changed the date values in datasets/prov-info and
datasets/<id>/prov-info by converting them to strings from datetime
objects. While they were datetime objects, they weren't valid json, so
dumping to json would result in a 500.
src/app.py Outdated
# is greater than 9MB Return a 400 and prompt the user to reduce the size of the output by applying optional
# argument filters.
dataset_prov_json_encode = json.dumps(dataset_prov_list).encode('utf-8')
if len(dataset_prov_json_encode) > 9000000:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it consistent by using 9*(2**20) (9437184) rather than 9000000 https://github.com/hubmapconsortium/uuid-api/blob/main/src/instance/app.cfg.example#L35 which is closer to 10MB. Also update the comment.

src/app.py Outdated
# is greater than 9MB Return a 400 and prompt the user to reduce the size of the output by applying optional
# argument filters.
sample_prov_json_encode = json.dumps(sample_prov_list).encode('utf-8')
if len(sample_prov_json_encode) > 9000000:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@yuanzhou yuanzhou merged commit d0c4da0 into main Jan 31, 2023
@yuanzhou yuanzhou deleted the Derek-Furst/prov-info-return-size branch February 1, 2023 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants