diff options
author | Frederick Muriuki Muriithi | 2021-12-22 09:22:49 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2021-12-24 14:36:14 +0300 |
commit | c813dd68230a027b1b5acdbe9d3dba46f6bd1ad0 (patch) | |
tree | f3a93746879fa8dc194b650dd9c4239fefa5cc3e /gn3/api | |
parent | 4304e7298af6769110a251b21fca2f105bee4c06 (diff) | |
download | genenetwork3-c813dd68230a027b1b5acdbe9d3dba46f6bd1ad0.tar.gz |
Encode the data to JSON and set the status code
Issue:
https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi
* Encode bytes objects to string
* Encode NaN values to "null"
* gn3/api/correlation.py:
Diffstat (limited to 'gn3/api')
-rw-r--r-- | gn3/api/correlation.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/gn3/api/correlation.py b/gn3/api/correlation.py index f84228a..c0b5806 100644 --- a/gn3/api/correlation.py +++ b/gn3/api/correlation.py @@ -1,9 +1,9 @@ """Endpoints for running correlations""" import json - from flask import jsonify from flask import Blueprint from flask import request +from flask import make_response from gn3.computations.correlations import compute_all_sample_correlation from gn3.computations.correlations import compute_all_lit_correlation @@ -109,6 +109,8 @@ def partial_correlation(): conn, trait_fullname(args["primary_trait"]), tuple(trait_fullname(trait) for trait in args["control_traits"]), args["method"], int(args["criteria"]), args["target_db"]) - return make_response( - jsonify(corr_results), - 400) + response = make_response( + json.dumps(corr_results, cls=OutputEncoder), + 400 if "error" in corr_results.keys() else 200) + response.headers["Content-Type"] = "application/json" + return response |