Linton Ye
02/06/2024, 7:09 PMScout
02/06/2024, 7:09 PMconfig_schema
, you can access the runtime configuration provided for the asset in its compute function under context.op_config
. Here's an example from the documentation that illustrates how to define an asset with a configuration schema and access the configuration within the asset's compute function: 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, the asset_with_config
asset is defined with a configuration schema that expects an interest_rate
of type float
. When the asset is materialized, the run_config
is provided, specifying the interest_rate
value. Within the asset's compute function, the configuration is accessed via context.op_config
. This mechanism allows you to pass configuration values to assets at runtime, which can then be used by the assets or their dependencies during execution.