Fabio
03/02/2024, 9:06 PMScout
03/02/2024, 9:06 PMpython from dagster import asset, Config, 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, the asset_with_config
asset has a config schema defined with a single parameter interest_rate
of type float
. When materializing the asset, you can provide the configuration value for interest_rate
in the run_config
. For graph-backed assets, you can apply the same principle. Define the config schema on the ops that make up the graph, and then when you materialize the graph-backed asset, provide the configuration values for those ops within the run_config
. If you have a graph that outputs multiple assets and you want to define a config schema for the entire graph, you can use the @graph_asset
decorator and provide the config schema as part of the decorator's arguments. However, as of my last update, there are some limitations and ongoing discussions about enhancing the support for config schemas at the graph level for graph-backed assets. For the most current information on this topic, please refer to the latest Dagster documentation and GitHub discussions.