Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[external-assets] Eliminate redundant iteration over assets_defs in A…
…ssetGraph construction (#20567) ## Summary & Motivation Eliminate multiple iterations over assets defs in AssetGraph.from_assets. This greatly speeds up AssetGraph construction for large asset graphs. ## How I Tested These Changes Timed `AssetGraph.from_assets` for the below set of defs. Time went from ~6.5s on my machine to <1ms. ``` from dagster import multi_asset, Definitions, AssetCheckSpec, AssetSpec, AssetKey import random import string alphabet = string.ascii_lowercase def asset_key(): return AssetKey("".join(random.choice(alphabet) for _ in range(10))) asset_keys = [asset_key() for _ in range(5000)] def asset_check_spec(): name = "".join(random.choice(alphabet) for _ in range(10)) return AssetCheckSpec(name= name, asset=random.choice(asset_keys)) asset_check_specs = [asset_check_spec() for _ in range(5000)] @multi_asset(specs=[AssetSpec(k) for k in asset_keys], check_specs=asset_check_specs) def hoorah(): ... defs = Definitions(assets=[hoorah]) ```
- Loading branch information