Configuring assets in the UI
The Dagster UI is commonly used to manually materialize assets, backfill historical data, debug a production issue, or some other one-off task.
You'll often want to be able to adjust parameters when materializing assets, which can be accomplished with Dagster's asset configuration system.
Making assets configurable
For an asset to be configurable, first define a schema that inherits from the Dagster Config
class.
For example, you want to allow your team to change the lookback time window for the computation that materializes an asset:
import dagster as dg
# Define the config schema
class ForecastModelConfig(dg.Config):
# lookback_window_days defaults to 30, but can be
# overridden by the user. If you do not provide a
# default, the user will need to provide a value.
lookback_window_days: int = 30
# Access the config with the `config` parameter
@dg.asset
def forecast_model(config: ForecastModelConfig):
print("Forecasting over time window:", config.lookback_window_days)
# ...more code here
defs = dg.Definitions(assets=[forecast_model])
Specifying config using the Dagster UI
Run configurations reference an op
which is the underlying compute associated with an asset.
When launching a run using the Launchpad in the UI, you can provide a run config file as YAML or JSON that overrides the default configuration for your asset.
On any page with a Materialize button, click the options menu > Open launchpad to access the Launchpad:
This will open the Launchpad, where you can scaffold the config, customize its values, and manually materialize the asset: