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

[module-loaders] Make key iterator property on all asset objects #26534

Closed

Conversation

dpeng817
Copy link
Contributor

@dpeng817 dpeng817 commented Dec 17, 2024

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 a key 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.

Copy link
Contributor Author

dpeng817 commented Dec 17, 2024

@dpeng817 dpeng817 force-pushed the dpeng817/split_load_file branch from 5e70be8 to 37ba786 Compare December 18, 2024 02:52
@dpeng817 dpeng817 force-pushed the dpeng817/key_iterator_removal branch from 8831b0b to db2f79a Compare December 18, 2024 02:52
@dpeng817 dpeng817 force-pushed the dpeng817/split_load_file branch from 37ba786 to c2b5a86 Compare December 18, 2024 03:35
@dpeng817 dpeng817 force-pushed the dpeng817/key_iterator_removal branch from db2f79a to 091517b Compare December 18, 2024 03:35
@dpeng817 dpeng817 marked this pull request as ready for review December 18, 2024 15:22
@dpeng817 dpeng817 changed the title Make key iterator property on all asset objects [module-loaders] Make key iterator property on all asset objects Dec 18, 2024
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.

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(
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

@dpeng817 dpeng817 Dec 18, 2024

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?

@dpeng817 dpeng817 force-pushed the dpeng817/split_load_file branch from c2b5a86 to 859fe49 Compare December 18, 2024 18:02
@dpeng817 dpeng817 force-pushed the dpeng817/key_iterator_removal branch from 091517b to 49c6d6b Compare December 18, 2024 18:02
@dpeng817 dpeng817 force-pushed the dpeng817/split_load_file branch from 859fe49 to ea424e1 Compare December 18, 2024 20:24
@dpeng817 dpeng817 force-pushed the dpeng817/key_iterator_removal branch from 49c6d6b to 51512e6 Compare December 18, 2024 20:24
@dpeng817 dpeng817 force-pushed the dpeng817/split_load_file branch from ea424e1 to fe234d6 Compare December 18, 2024 20:50
@dpeng817 dpeng817 force-pushed the dpeng817/key_iterator_removal branch from 51512e6 to 3553a63 Compare December 18, 2024 20:50
@dpeng817 dpeng817 force-pushed the dpeng817/split_load_file branch from fe234d6 to a6edd3c Compare December 18, 2024 20:55
@dpeng817 dpeng817 force-pushed the dpeng817/key_iterator_removal branch from 3553a63 to dbc2230 Compare December 18, 2024 20:55
@dpeng817 dpeng817 force-pushed the dpeng817/split_load_file branch from a6edd3c to c63c327 Compare December 18, 2024 21:27
@dpeng817 dpeng817 force-pushed the dpeng817/key_iterator_removal branch from dbc2230 to c8d9b78 Compare December 18, 2024 21:27
@dpeng817 dpeng817 force-pushed the dpeng817/split_load_file branch from c63c327 to 96a7aab Compare December 19, 2024 00:27
@dpeng817 dpeng817 force-pushed the dpeng817/key_iterator_removal branch from c8d9b78 to 09e6f69 Compare December 19, 2024 00:27
@dpeng817 dpeng817 closed this Dec 19, 2024
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.

2 participants