From 380882c742dcea3cba49c358afe56d1bcf199fcd Mon Sep 17 00:00:00 2001 From: Giang Bui Date: Fri, 23 Mar 2018 02:39:36 -0500 Subject: [PATCH] fix(bug): fix bug --- peregrine/resources/submission/__init__.py | 4 ++-- peregrine/utils/pybdbag.py | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/peregrine/resources/submission/__init__.py b/peregrine/resources/submission/__init__.py index ec70ac04..bfe1748b 100644 --- a/peregrine/resources/submission/__init__.py +++ b/peregrine/resources/submission/__init__.py @@ -101,8 +101,8 @@ def root_graphql_query(): # if peregrine.utils.contain_node_with_category(data.json,'data_file') == False: # return flask.jsonify({ 'errors': 'No data_file node'}), 400 print("========dir(data)===========") - print(dir(data)) - res = peregrine.utils.json2tbl(data.json,'', "_" ) + print(data.data) + res = peregrine.utils.json2tbl(json.loads(data.data),'', "_" ) bag_info = {'organization': 'CDIS', 'data_type': 'TOPMed', 'date_created': datetime.date.today().isoformat()} diff --git a/peregrine/utils/pybdbag.py b/peregrine/utils/pybdbag.py index 7f709cee..c85b297c 100644 --- a/peregrine/utils/pybdbag.py +++ b/peregrine/utils/pybdbag.py @@ -26,11 +26,14 @@ def create_bdbag(bag_path, bag_info, payload, max_row=10000): header = copy.deepcopy(row) writer.writerow(row) nrow = 1 + print('==============header==========') + print(header) for row_dict in payload: row=[] + print(row_dict) for h in header: - if row_dict['_data_'+h]: - row.append(row_dict['_data_'+h]) + if row_dict.get('_data_'+h): + row.append(row_dict.get('_data_'+h)) else: row.append('None') writer.writerow(row)