https://dagster.io/ logo
#ask-ai
Title
# ask-ai
a

Abhishek Tripathi

02/24/2024, 10:00 AM
how to add config for downstream asset in current asset?
s

Scout

02/24/2024, 10:00 AM
To add configuration for a downstream asset within the current asset, you can define a config schema for the downstream asset and then provide the configuration values at runtime. The documentation provides an example of how to define an asset with a config schema:
Copy code
python
from dagster import asset, materialize

@asset(config_schema={"interest_rate": float})
def asset_with_config(context):
    return some_financial_calculation(rate=context.op_config["interest_rate"])

materialize(
    [asset_with_config],
    run_config={"ops": {"asset_with_config": {"config": {"interest_rate": 0.05}}}}
)
In this example,
asset_with_config
is an asset that takes a configuration parameter
interest_rate
. When materializing the asset, you provide the runtime configuration for
interest_rate
within the
run_config
dictionary. If you have a downstream asset that depends on this asset, you would similarly define a config schema for the downstream asset and provide the necessary configuration when materializing it. The configuration is accessed in the asset’s compute function under
context.op_config
. For more complex scenarios involving multiple assets, you might define a graph-backed asset or a multi-asset, where each asset can have its own config schema. You would then provide the configuration for each asset when you materialize the graph or multi-asset. Remember that the configuration for each asset is provided at the time of materialization, and you can specify different configurations for different runs as needed. How to specify config for graph-backed a... button Dagster 0.15.0: Cool for the Summer | Da... button enable per-source-asset configuration on... button Allow providing config to @graph_asset d... button Thank you for your feedback!
5 Views