Skip to content

Conversation

@gibsondan
Copy link
Member

Summary:
This is a bit of a micro-optimization, but I noticed that we were spending a bunch of time in the or operation here, and most of the time we should not need to or.

Test Plan: BK (which includes the multi-asset case)

Summary & Motivation

How I Tested These Changes

Changelog

Insert changelog entry or delete this section.

Copy link
Contributor

@OwenKephart OwenKephart left a comment

Choose a reason for hiding this comment

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

I think it'd be a bit more elegant to update the __or__ method to take Union[Self, Sequence[Self]] and fork the behavior in there rather than to introduce a new name

Copy link
Member Author

I thought or was like a python built in

Summary:
Test Plan: BK (which includes the multi-asset case)
Comment on lines +64 to +70
other_subset = asset_graph_subset.get_partitions_subset(asset_key)
if other_subset is not None:
partition_subsets_by_asset_key[asset_key].append(other_subset)

partition_subsets_by_asset_key[asset_key].append(
asset_graph_subset.get_partitions_subset(asset_key)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

There appears to be a duplication issue in this code. The same partition subset is being added twice:

other_subset = asset_graph_subset.get_partitions_subset(asset_key)
if other_subset is not None:
    partition_subsets_by_asset_key[asset_key].append(other_subset)

partition_subsets_by_asset_key[asset_key].append(
    asset_graph_subset.get_partitions_subset(asset_key)
)

The second append is redundant since it's adding the same other_subset that was just conditionally added. This will cause duplicates in the list. The code should keep only the conditional append and remove the unconditional one.

Suggested change
other_subset = asset_graph_subset.get_partitions_subset(asset_key)
if other_subset is not None:
partition_subsets_by_asset_key[asset_key].append(other_subset)
partition_subsets_by_asset_key[asset_key].append(
asset_graph_subset.get_partitions_subset(asset_key)
)
other_subset = asset_graph_subset.get_partitions_subset(asset_key)
if other_subset is not None:
partition_subsets_by_asset_key[asset_key].append(other_subset)

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

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.

3 participants