-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[module-loaders] Make key iterator property on all asset objects #26534
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
5e70be8
to
37ba786
Compare
8831b0b
to
db2f79a
Compare
37ba786
to
c2b5a86
Compare
db2f79a
to
091517b
Compare
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 the PR that gave me cold feet about the downstack with_attributes PR
@@ -37,25 +37,6 @@ def find_subclasses_in_module( | |||
yield value | |||
|
|||
|
|||
def key_iterator( |
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.
Given there's currently just a single place where we need to do this, and most of this ugliness gets cleaned up by removing the include(d)_targeted_keys
param, I think it makes more sense to consolidate this logic here 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.
This isn't actually the only place where we need to do this, is my take. I needed to do the same thing in Airlift, and anything that operates on an unresolved Definitions
object will need to do the same thing.
I think the reality is that in each of the places where we likely encounter it there's a ternary that I didn't break by doing this.
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.
seems like this only gets you half of the way there on the annoyance removal though, right? because you still have to itertools.chain() all of your various iterators together into a single iterator or do the dastardly double list comprehension that we currently have
if we already have a lovely map_asset_specs()
method that handles the iteration and sub-iteration for you on these heterogenous lists, maybe we just supply an iterate_asset_specs()
method to do the same, just without the mapping bit?
that seems a bit more general-purpose to me, and it'd let you do:
all_asset_keys = {
spec.key
for spec in iterate_asset_specs(self.assets_defs_specs_and_checks_defs)
}
which is a lot easier to comprehend.
we can keep it as an internal utility for now so that airlift can make use of it
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 guess the only confounding factor there is source assets (since we don't support this pattern on cacheables right now anyway). and I guess checks defs would just never get any specs iterated upon, which maybe is fine?
c2b5a86
to
859fe49
Compare
091517b
to
49c6d6b
Compare
859fe49
to
ea424e1
Compare
49c6d6b
to
51512e6
Compare
ea424e1
to
fe234d6
Compare
51512e6
to
3553a63
Compare
fe234d6
to
a6edd3c
Compare
3553a63
to
dbc2230
Compare
a6edd3c
to
c63c327
Compare
dbc2230
to
c8d9b78
Compare
c63c327
to
96a7aab
Compare
c8d9b78
to
09e6f69
Compare
Summary & Motivation
This follows on the theme of needing to special case each different type of asset when dealing with the union list; in the case of iterating on keys, some assets have a
keys
parameter, some only have akey
parameter. Instead, just have each asset able to return an iterable of their keys. Then, we can just call a single property and contain this complexity to the class itself.