From c813dd68230a027b1b5acdbe9d3dba46f6bd1ad0 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 22 Dec 2021 09:22:49 +0300 Subject: 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: --- gn3/api/correlation.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'gn3/api') 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 -- cgit v1.2.3