Skip to content
This repository has been archived by the owner on Dec 29, 2023. It is now read-only.

Source format selection #111

Merged
merged 7 commits into from
May 17, 2017
Merged

Conversation

maxvonhippel
Copy link
Contributor

@maxvonhippel maxvonhippel commented May 16, 2017

In regard to issue 75: added optional source format selection.

No change in behavior for BIOMV210Format .biom files, but now BIOMV100Format .biom files are allowed if you specify the format as BIOMV100Format.

REST API updated to include the key-value pair in the relevant JSON objects. Note that if the value is null, I put in a null (None) value rather than skipping the pair altogether. If this is not the desired behavior I can easily change the code accordingly.

@maxvonhippel
Copy link
Contributor Author

I used sample files from the tutorials to test with. With V100 .biom files, Q2Studio still gives an error message if you do not supply a source format parameter, like this:
100 no param

However, you now have the ability to supply the source format, allowing non V210 .biom files to be processed, like this:

100 with param

... and the artifact is successfully added to the table:

success 100 with param

And V210 .biom files still work as they did before, with or without the optional source format parameter.

Adding a V210 .biom with the source format:
step_1
step_2

And then adding one without supplying the source format, thus demonstrating that it is optional:
step_3
step_4

@maxvonhippel
Copy link
Contributor Author

maxvonhippel commented May 17, 2017

Also, the plugins appear to work with the V100 demo file. I just tried rarefying it, with an arbitrary depth value, as follows:
screenshot 2017-05-16 17 46 08
And it looks like it worked:
screenshot 2017-05-16 17 46 24

I don't think anything is broken with the existing V210 support functionality, and this demo suggests that other source formats should now be equally supported. I'm happy to perform additional testing if there are any specific features/plugins/demo files/etc. you would like checked 👍 .

Copy link
Member

@ebolyen ebolyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionality works, but the API is exposing more than it really needs to and it doesn't exactly work. Just remove a couple things and this is good to go.

@@ -24,7 +24,7 @@ const mapDispatchToProps = dispatch => ({
const fd = new FormData(e.target);
const data = {};
for (const [key, value] of fd) {
if (value === '' || value === undefined) {
if (key !== 'source_format' && (value === '' || value === undefined)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good enough hack for now 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it was important that the other values besides source_format be passed as '' if they are not entered in order to trigger @fail_elegantly in the backend python code, so I ended up modifying this part of the code to first check if the key is source_format and the value is '', in which case we set the value to null, and then to check if that is not the case if value is undefined etc, and then finally to set the value as was done before. This should make the code more readable here (and maybe a bit less hack-y looking) and also fix the problem you pointed out in workspace.py with source_format not being null by default.

Let me know if you don't like this style and I am happy to change it. Thanks!

return {
'name': name,
'uuid': metadata.uuid,
'type': metadata.type,
'uri': url_for(route, uuid=metadata.uuid)
'uri': url_for(route, uuid=metadata.uuid),
'source_format': source_format
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's nothing to connect this to on the UI, so I would drop source_format (also it should be metadata.format anyhow because the metadata already has that info).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, will do!

@@ -75,8 +76,12 @@ def get_artifacts():
@fail_gracefully
def create_artifact():
request_body = request.get_json()
_format = None
if request_body['source_format']:
_format = request_body['source_format']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code makes the payload seem ambiguous. We should be able to rely on the source_format key to exist as null (and thus will be converted to None) so you shouldn't really need this block.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I'm not completely sure that we are able to rely on it to be null, but I agree that we should be able to. I'll check if it works as it should already and if it doesn't I'll follow the code back and figure out what's happening.

return jsonify({'uuid': metadata.uuid, 'type': metadata.type})
return jsonify({'uuid': metadata.uuid,
'type': metadata.type,
'source_format': metadata.source_format})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be metadata.format, but again there's nothing on the client-side to draw this information, so it doesn't matter much. I would remove.

return jsonify({'uuid': metadata.uuid, 'type': metadata.type})
return jsonify({'uuid': metadata.uuid,
'type': metadata.type,
'source_format': metadata.source_format})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@@ -9,7 +9,7 @@
import os
import glob

from flask import Blueprint, jsonify, request, abort, url_for\
from flask import Blueprint, jsonify, request, abort, url_for
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ebolyen ebolyen merged commit 945d2fb into qiime2:master May 17, 2017
@maxvonhippel maxvonhippel deleted the source-format-selection branch May 17, 2017 20:55
@maxvonhippel
Copy link
Contributor Author

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants