Peter Lim
03/04/2024, 5:09 PMScout
03/04/2024, 5:09 PMdefine_asset_job
function and provide the necessary selection and config parameters. Here's how you can do it according to the documentation: 1. Define your asset with a config schema: First, you need to define an asset that supports configuration. You can do this by using the @asset
decorator and specifying a config_schema
. python from dagster import asset @asset(config_schema={"interest_rate": float}) def asset_with_config(context): # Your asset computation logic here, using the config value interest_rate = context.op_config["interest_rate"] # Perform some calculation with the interest rate return some_financial_calculation(rate=interest_rate)
2. Create a job with the selected asset and config: Next, you can define a job that materializes the asset with the specified configuration. You use the define_asset_job
function to create a job, providing the selection of assets to materialize and the config that should be used when the job is executed. python from dagster import define_asset_job # Define a job that materializes the asset_with_config with a specific interest rate asset_job = define_asset_job( name="asset_materialization_job", selection=["asset_with_config"], config={"ops": {"asset_with_config": {"config": {"interest_rate": 0.05}}}} )
In this example, the selection
parameter is used to specify which assets the job should materialize, and the config
parameter is used to provide the runtime configuration for the job. The config
parameter must conform to the standard config schema based on the assets and resources involved in the job. When you execute this job, it will materialize the asset_with_config
using the provided interest rate of 0.05
. Please note that the provided code examples are based on the documentation's guidance, and you should adjust the asset definitions and configurations according to your specific use case.Peter Lim
03/04/2024, 5:10 PMScout
03/04/2024, 5:10 PM