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

Filtering the batch based on model type #3756

Merged
merged 1 commit into from Nov 16, 2018
Merged

Filtering the batch based on model type #3756

merged 1 commit into from Nov 16, 2018

Conversation

daviddavis
Copy link
Contributor

@daviddavis daviddavis commented Nov 15, 2018

I'm pretty sure this is probably not the right fix. @gmbnomis or @bmbouter, hoping you can suggest what to do.

fixes #4165
https://pulp.plan.io/issues/4165

@pep8speaks
Copy link

Hello @daviddavis! Thanks for submitting the PR.

@codecov
Copy link

codecov bot commented Nov 15, 2018

Codecov Report

Merging #3756 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3756   +/-   ##
=======================================
  Coverage   54.77%   54.77%           
=======================================
  Files          64       64           
  Lines        2806     2806           
=======================================
  Hits         1537     1537           
  Misses       1269     1269

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 2d3069e...b2c7e29. Read the comment docs.

@@ -52,7 +52,8 @@ class QueryExistingContentUnits(Stage):

for model_type in content_q_by_type.keys():
for result in model_type.objects.filter(content_q_by_type[model_type]):
for declarative_content in batch:
model_batch = filter(lambda dcont: type(dcont.content) == model_type, batch)
Copy link

@gmbnomis gmbnomis Nov 16, 2018

Choose a reason for hiding this comment

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

I only provided the batch iterator for this code, so I am not the expert here.

These nested loops look like they have the word "SLOW" imprinted on them (but let's wait for the outcome of the performance testing).

Given the current structure, it looks like the right thing to do. However, I would prefer staying imperative style here. There is already a continue in this loop, so I would prefer:

                    for declarative_content in batch:
                        if type(declarative_content.content) is not model_type:
                            continue
                        not_same_unit = False
...

An alternative would be to sort the batch into buckets by content type in the loop above (analogous to how the query is built) and iterate through the specific bucket here.

Copy link
Member

Choose a reason for hiding this comment

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

+1 to the code change suggestion for readability. In terms of performance we'll need to improve it over time along with functional and unit tests to ensure we don't regress along the way.

@bmbouter
Copy link
Member

@daviddavis thank you for working on this.

@daviddavis
Copy link
Contributor Author

@gmbnomis @bmbouter updated. 👍

Copy link
Member

@bmbouter bmbouter left a comment

Choose a reason for hiding this comment

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

Thank you @daviddavis !

@bmbouter bmbouter merged commit 8472d2d into pulp:master Nov 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
5 participants