-
Notifications
You must be signed in to change notification settings - Fork 81
Fix #3149 #3152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #3149 #3152
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good but I think that
json_decode(self.request.body)
buffer.seek(0) | ||
|
||
# validate on load | ||
data = qiita_db.metadata_template.util.load_template_to_dataframe(rawdata) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should have been clearer, sorry. This needs to be imported, add at the top:
from qiita_db.metadata_template.util import load_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), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the load_template_to_dataframe accepts string so perhaps worth not converting to dataframe and then back and just do:
data = load_template_to_dataframe(json_decode(self.request.body))
but I'm not sure if json_decode returns a string or a byte.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks like it opens a filehandle, so I don't think a regular string would work. The spec for the REST endpoint as well is not a str representation of a TSV, but a JSON representation derived from DataFrame.to_json
. I may be missing something, but I think this transform is necessary
add qiita_db/studies/ endpoint
...route load through Qiita's template loading mechanisms