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
Scottx611x/td api #1646
Scottx611x/td api #1646
Conversation
…into scottx611x/acceptance_testing
Codecov Report
@@ Coverage Diff @@
## develop #1646 +/- ##
==========================================
+ Coverage 37.03% 37.64% +0.6%
==========================================
Files 369 369
Lines 24093 24317 +224
Branches 1260 1260
==========================================
+ Hits 8924 9153 +229
+ Misses 15169 15164 -5
Continue to review full report at Codecov.
|
refinery/tool_manager/models.py
Outdated
|
||
|
||
@receiver(pre_delete, sender=ToolDefinition) | ||
def _tooldefinition_pre_delete(sender, instance, *args, **kwargs): |
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.
unsure of convention, _tool_definition_pre_delete?
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.
Also, it's probably not a good idea to add the signal name to the handler name because signal name might change. It is better to describe what the function actually does (example)
refinery/tool_manager/serializers.py
Outdated
@@ -13,10 +13,30 @@ class Meta: | |||
|
|||
|
|||
class ParameterSerializer(serializers.ModelSerializer): | |||
galaxy_workflow_step = serializers.SerializerMethodField( | |||
method_name="_get_galaxy_workflow_step", required=False, |
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.
For readability, suggestion:
galaxy_workflow_step = serializers.SerializerMethodField(
method_name="_get_galaxy_workflow_step",
required=False,
allow_null=False
)
@@ -48,6 +50,7 @@ def handle(self, **options): | |||
|
|||
# Validate workflow annotation data, and try to create a | |||
# ToolDefinition if validation passes. | |||
|
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.
It might make more sense to get the list of all the workflows from all the engines first to avoid an extra indentation level. It might also be helpful to factor out this functionality into a separate re-useable utility function.
for step_index in workflow_data["steps"]: | ||
step = workflow_data["steps"][step_index] | ||
# Check if any annotation provided, and try to convert | ||
# to python dict if so |
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 is redundant: comments should be explaining "why", not "what".
# `parameters` we can pass here without | ||
# raising an exception | ||
pass | ||
else: |
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.
Not needed. Removing will help reduce indentation levels.
# `tool_inputs` | ||
if (not parameter["name"] in | ||
step["tool_inputs"]): | ||
raise RuntimeError( |
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 this be CommandError?
# annotation data against the available | ||
# parameters of the Workflow step's | ||
# `tool_inputs` | ||
if (not parameter["name"] in |
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 should probably be a membership test instead of a boolean
).galaxy_workflow_step | ||
except (GalaxyParameter.DoesNotExist, | ||
GalaxyParameter.MultipleObjectsReturned): | ||
return None |
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.
Usually, return values should be of the same type and errors should be indicated by exceptions. Is returning None helpful here?
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.
Yes, this just allows the Parameter Serializer to include the GalaxyParameter models fields when need be, and disclude them from the response if we are dealing with parent Parameter objects
refinery/tool_manager/models.py
Outdated
|
||
|
||
@receiver(pre_delete, sender=ToolDefinition) | ||
def _tooldefinition_pre_delete(sender, instance, *args, **kwargs): |
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.
Also, it's probably not a good idea to add the signal name to the handler name because signal name might change. It is better to describe what the function actually does (example)
refinery/tool_manager/models.py
Outdated
|
||
|
||
@receiver(post_delete, sender=ToolDefinition) | ||
def _tooldefinition_post_delete(sender, instance, *args, **kwargs): |
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 as above
refinery/tool_manager/models.py
Outdated
|
||
|
||
@receiver(pre_delete, sender=FileRelationship) | ||
def _filerelationship_pre_delete(sender, instance, *args, **kwargs): |
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 as above
|
||
logger = logging.getLogger(__name__) | ||
ANNOTATION_ERROR_MESSAGE = ( |
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 probably should be no new line characters here.
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.
What would be the alternative?
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 it's best to avoid "one log statement != one written log"
This reverts commit 69d5c65.
refinery/tool_manager/utils.py
Outdated
workflow_list = [] | ||
workflow_engines = WorkflowEngine.objects.all() | ||
|
||
sys.stdout.write( |
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.
We should probably make this utility function re-useable in other parts of the application besides management commands. If so, it should not be writing anything to stdout.
"Generating ToolDefinitions from workflow engine {}\n" | ||
.format(engine.name) | ||
) | ||
workflow_list = get_workflow_list() |
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.
get_workflow_list()
can raise RuntimeError exceptions that should be handled
refinery/tool_manager/tests.py
Outdated
@@ -111,40 +114,44 @@ def test_for_proper_parameters_response(self): | |||
|
|||
class ToolDefinitionGenerationTests(TestCase): | |||
def test_workflow_improperly_annotated(self): | |||
with open("tool_manager/test-data/workflow_annotation_invalid.json", | |||
"r") as f: | |||
with open("tool_manager/test-data/workflow_annotation_invalid" |
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 this be test_data
instead of test-data
?
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.
@hackdna I can rename the directory?
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.
It's probably a good idea for consistency. All other folder and file names appear to have underscores.
Closes #1613