Skip to content
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/refactor attach outputs dataset #2591

Merged
merged 11 commits into from Feb 15, 2018

Conversation

scottx611x
Copy link
Member

@scottx611x scottx611x commented Feb 14, 2018

I was in this area of the code today and figured it was high time for some refactoring
Fixes: #2415

@codecov
Copy link

codecov bot commented Feb 14, 2018

Codecov Report

Merging #2591 into develop will decrease coverage by 2.55%.
The diff coverage is 93.15%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2591      +/-   ##
===========================================
- Coverage    55.58%   53.03%   -2.56%     
===========================================
  Files          408      406       -2     
  Lines        29474    26437    -3037     
  Branches      1240     1240              
===========================================
- Hits         16384    14021    -2363     
+ Misses       13090    12416     -674
Impacted Files Coverage Δ
refinery/analysis_manager/tasks.py 73.99% <0%> (ø) ⬆️
refinery/tool_manager/tests.py 99.81% <100%> (-0.1%) ⬇️
refinery/core/models.py 71.9% <93.33%> (-0.63%) ⬇️
refinery/analysis_manager/utils.py 55.1% <0%> (-9.98%) ⬇️
refinery/data_set_manager/tasks.py 36.99% <0%> (-5.52%) ⬇️
refinery/data_set_manager/views.py 45.49% <0%> (-5.01%) ⬇️
refinery/file_store/models.py 62.45% <0%> (-4.3%) ⬇️
refinery/analysis_manager/views.py 46.78% <0%> (-3.55%) ⬇️
refinery/core/views.py 26.57% <0%> (-3.15%) ⬇️
...ery/tool_manager/management/commands/load_tools.py 85.03% <0%> (-1.21%) ⬇️
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 697634a...91ecd5b. Read the comment docs.

@scottx611x scottx611x added this to the Release 1.6.3 milestone Feb 15, 2018
@@ -1161,6 +1161,12 @@ class Meta:
)
ordering = ['-time_end', '-time_start']

@property
Copy link
Member

Choose a reason for hiding this comment

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

What's the benefit of making this a property?

Copy link
Member Author

Choose a reason for hiding this comment

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

No benefit, changing it now

ast.literal_eval(self.workflow_copy)
def attach_derived_nodes_to_dataset(self):
graph_with_data_transformation_nodes = (
self._create_data_transformation_nodes(self.workflow_graph)
Copy link
Member

Choose a reason for hiding this comment

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

We just talked about this... probably more clear just to call?

node_name = "{}_{}".format(
data_transformation_node['tool_id'],
data_transformation_node['name']
)
Copy link
Member

Choose a reason for hiding this comment

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

maybe:

"{tool_id}_{name}".format(**data_transformation_node)

and then it's almost short enough to just put in the create below.


if graph[edge[0]][edge[1]]['output_id'] == input_id:
input_node_id = edge[1]
data_transformation_node = (
Copy link
Member

Choose a reason for hiding this comment

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

I would tend to just back-slash in a case like this... maybe to avoid the closing paren, or the risk of a stray comma turning it into a tuple, but this could be the wrong call.

@@ -1161,6 +1161,11 @@ class Meta:
)
ordering = ['-time_end', '-time_start']

def get_workflow_graph(self):
Copy link
Member

Choose a reason for hiding this comment

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

get_expanded_workflow_graph()?

output_connection_to_analysis_result_mapping = (
self._get_output_connection_to_analysis_result_mapping()
)
output_mappings = output_connection_to_analysis_result_mapping
Copy link
Member

Choose a reason for hiding this comment

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

just use this name in the first place?

"Results for '%s' and %s.%s: %s",
self.uuid,
output_connection,
output_connection.filetype,
Copy link
Member

Choose a reason for hiding this comment

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

Below, we debug with just output_connection... maybe that's enough?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think the repr() of output_connection has the filetype information

Copy link
Member

Choose a reason for hiding this comment

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

Update the repr?

a. attach output node to source data transformation node
b. attach output node to target data transformation node
(if exists)"""
if len(graph.edges([output_connection.step])) > 0:
Copy link
Member

Choose a reason for hiding this comment

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

but if it were zero, then the loop below would just exit quickly?


if graph[edge[0]][edge[1]]['output_id'] == output_id:
input_node_id = edge[0]
output_node_id = edge[1]
Copy link
Member

Choose a reason for hiding this comment

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

a lot like line 1681? maybe define the variables first?

# any children
if (not output_connection.is_refinery_file and
derived_data_file_node.children.count() == 0):
output_connection.node.delete()
Copy link
Member

Choose a reason for hiding this comment

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

maybe:

if derived_data_file_node.children.count() == 0:
  if output_connection.is_refinery_file:
    ...
  else:
    ...

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought we could make the split here too, but looking at theses two ifs one is worried about derived_data_file_node.parents and the other derived_data_file_node.children

Copy link
Member

@mccalluc mccalluc left a comment

Choose a reason for hiding this comment

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

Style tweaks, but looks fine.

@scottx611x scottx611x merged commit ff11672 into develop Feb 15, 2018
@scottx611x scottx611x deleted the scottx611x/refactor_attach_outputs_dataset branch February 15, 2018 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants