# ask-ai

Greg H

02/29/2024, 4:49 PM
How does an asset definition function look like that should run after two other assets where one asset is used as input?


02/29/2024, 4:49 PM
An asset definition that should run after two other assets, with one of those assets used as input, can be defined using the
decorator. The asset that is used as input will be specified as a parameter to the function, indicating a dependency on that asset. The other asset, which is not used as input, will not be specified as a parameter, but the dependency can be indicated through other means, such as asset groupings or job definitions that ensure the correct execution order. Here's an example of how such an asset definition might look:
Copy code
python from dagster import asset  @asset def first_asset():     # Logic for the first asset     ...  @asset def second_asset():     # Logic for the second asset     ...  @asset def dependent_asset(first_asset):     # Logic for the asset that depends on first_asset     # and implicitly on second_asset     ...
In this example,
explicitly depends on
because it is passed as an input to the function. The dependency on
is implicit; it's not used as an input, but you would ensure that
has been materialized before
runs when you define the execution order in your job or asset group. The documentation provides guidance on defining assets and their dependencies using the
decorator, and the example above is consistent with the patterns described in the documentation. Remember that the actual execution order and dependencies between assets that are not used as inputs will need to be managed through your job definitions or asset groupings to ensure that all dependencies are resolved before an asset is materialized.