Skip to content

Instantly share code, notes, and snippets.

@slopp
Created April 19, 2023 18:29
Show Gist options
  • Save slopp/cebf04bb47fe606a6561e023cc8a976f to your computer and use it in GitHub Desktop.
Save slopp/cebf04bb47fe606a6561e023cc8a976f to your computer and use it in GitHub Desktop.
Asset Factory Example
from dagster import asset, Definitions, AssetIn
assets_to_make = ["a", "b", "c"]
def make_assets(asset_to_make):
@asset(
name=asset_to_make
)
def asset_template():
print(asset_to_make)
return
return asset_template
factory_assets = [make_assets(key) for key in assets_to_make]
factory_assets_ins = dict(zip(assets_to_make, [AssetIn(i) for i in assets_to_make]))
@asset
def downstream_of_factory_one(a):
pass
@asset(
ins=factory_assets_ins
)
def downstream_of_factory_all(**kwargs):
pass
defs = Definitions(
assets=[*factory_assets, downstream_of_factory_one, downstream_of_factory_all]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment