aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-12-22 09:22:49 +0300
committerFrederick Muriuki Muriithi2021-12-24 14:36:14 +0300
commitc813dd68230a027b1b5acdbe9d3dba46f6bd1ad0 (patch)
treef3a93746879fa8dc194b650dd9c4239fefa5cc3e /gn3
parent4304e7298af6769110a251b21fca2f105bee4c06 (diff)
downloadgenenetwork3-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')
-rw-r--r--gn3/api/correlation.py10
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