Skip to content

Commit

Permalink
Fix #3149
Browse files Browse the repository at this point in the history
...route load through Qiita's template loading mechanisms
  • Loading branch information
wasade authored Oct 6, 2021
1 parent 93f90ef commit 90f96a2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions qiita_pet/handlers/rest/study_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# The full license is in the file LICENSE, distributed with this software.
# -----------------------------------------------------------------------------
from collections import defaultdict
import io

from tornado.escape import json_encode, json_decode
import pandas as pd
Expand Down Expand Up @@ -150,8 +151,15 @@ def patch(self, study_id):
else:
sample_info = study.sample_template.to_dataframe()

data = pd.DataFrame.from_dict(json_decode(self.request.body),
orient='index')
# convert from json into a format that qiita can validate
rawdata = pd.DataFrame.from_dict(json_decode(self.request.body),
orient='index')
buffer = io.StringIO()
rawdata.to_csv(buffer, sep='\t', index=True, header=True)
buffer.seek(0)

# validate on load
data = qiita_db.metadata_template.util.load_template_to_dataframe(rawdata)

if len(data.index) == 0:
self.fail('No samples provided', 400)
Expand Down

0 comments on commit 90f96a2

Please sign in to comment.