-
Notifications
You must be signed in to change notification settings - Fork 20
Conversation
…ource format, and tested on my machine and found that behaviour is as expected both with and without supplied format for BIOMV100Format biom input
I used sample files from the tutorials to test with. With V100 However, you now have the ability to supply the source format, allowing non V210 And V210 Adding a V210 And then adding one without supplying the source format, thus demonstrating that it is optional: |
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.
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)) { |
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.
Good enough hack for now 👍
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.
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!
q2studio/api/workspace.py
Outdated
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 |
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.
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).
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.
Makes sense, will do!
q2studio/api/workspace.py
Outdated
@@ -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'] |
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.
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.
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.
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.
q2studio/api/workspace.py
Outdated
return jsonify({'uuid': metadata.uuid, 'type': metadata.type}) | ||
return jsonify({'uuid': metadata.uuid, | ||
'type': metadata.type, | ||
'source_format': metadata.source_format}) |
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.
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.
q2studio/api/workspace.py
Outdated
return jsonify({'uuid': metadata.uuid, 'type': metadata.type}) | ||
return jsonify({'uuid': metadata.uuid, | ||
'type': metadata.type, | ||
'source_format': metadata.source_format}) |
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.
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 |
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.
👍
Thanks! |
In regard to issue 75: added optional source format selection.
No change in behavior for
BIOMV210Format
.biom
files, but nowBIOMV100Format
.biom
files are allowed if you specify the format asBIOMV100Format
.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.