Skip to content

How to avoid specifying a function parameter for every upstream asset that an asset depends on? #10008

Answered by sryza
pedrovgp asked this question in Q&A
Discussion options

You must be logged in to vote

To build an asset that collects and returns the outputs of multiple other assets, which may vary in number given some parameters, but are all defined at build time, I would use kwargs with AssetIns:

upstream_assets = []

@asset(
    ins={
        "__".join(asset_def.key.path): AssetIn(key=asset_def.key)
        for asset_def in upstream_assets
    }
)
def handle_for_assets(**kwargs):
    result = []

    for input_name, asset_value in kwargs.items():
        result.append(asset_value)

    return result

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@pedrovgp
Comment options

Answer selected by pedrovgp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants