diff --git a/docs/docs-beta/docs/guides/data-modeling/configuring-assets.md b/docs/docs-beta/docs/guides/data-modeling/configuring-assets.md index 92ac1ab0473fe..1a0563ddb4b65 100644 --- a/docs/docs-beta/docs/guides/data-modeling/configuring-assets.md +++ b/docs/docs-beta/docs/guides/data-modeling/configuring-assets.md @@ -1,5 +1,43 @@ --- -title: Configuring assets and ops -sidebar_label: Configuring assets +title: Configuring assets via the UI +sidebar_label: Configuring assets via the UI sidebar_position: 50 ---- \ No newline at end of file +--- + +You will commonly want to manually materialize assets using the Dagster UI to backfill historical data, debug a production issue, or some other one-off task. + +Often, you will want to be able to tweak some parameters when materializing these assets. This can be accomplished through the asset configuration system. + +## What you'll learn + +- How to add configuration to your assets +- How to modify the configuration when launching a run +- When to use asset configuration vs. [resources](/docs/concepts/resources) + +--- + +
+ Prerequisites + +To follow the steps in this guide, you'll need: + +- A basic understanding of Dagster and assets. See the [Quick Start](/tutorial/quick-start) tutorial for an overview. +- Familiarity with [Pydantic](https://docs.pydantic.dev/latest/) +- An understanding of [Ops vs Assets](/concepts/ops-jobs/ops-vs-assets) +
+ +--- + +## Adding configuration to assets + +For an asset to be configurable, you must first define a schema that inherits from the Dagster `Config` class. For example, let's say we want to allow users to change the lookback time window for an asset: + + + +## Modifying the configuration when launching a run + +When launching a run using Dagster's Launchpad, you can provide a run config file as YAML or JSON that overrides the default configuration for your asset: + + + +Run configurations reference an `op` which is the underlying compute associated with an asset. See [the Ops vs Assets](/concepts/ops-jobs/ops-vs-assets) documentation for more information. diff --git a/docs/docs-beta/src/components/CodeExample.tsx b/docs/docs-beta/src/components/CodeExample.tsx index d3cd75fc95c4b..e6d46e1dde3d2 100644 --- a/docs/docs-beta/src/components/CodeExample.tsx +++ b/docs/docs-beta/src/components/CodeExample.tsx @@ -15,7 +15,9 @@ const CodeExample: React.FC = ({filePath, language, title}) => // Adjust the import path to start from the docs directory import(`!!raw-loader!/../../examples/docs_beta_snippets/docs_beta_snippets/${filePath}`) .then((module) => { - const lines = module.default.split('\n'); + const lines = module.default.split('\n').map(line => { + return line.replaceAll(/#.*?noqa.*?$/g, "").trim(); + }); const mainIndex = lines.findIndex((line) => line.trim().startsWith('if __name__ == ')); const strippedContent = mainIndex !== -1 ? lines.slice(0, mainIndex).join('\n') : module.default; diff --git a/docs/vale/styles/config/vocabularies/Dagster/accept.txt b/docs/vale/styles/config/vocabularies/Dagster/accept.txt index 58ed798d1784f..cd07400a1dd9e 100644 --- a/docs/vale/styles/config/vocabularies/Dagster/accept.txt +++ b/docs/vale/styles/config/vocabularies/Dagster/accept.txt @@ -38,3 +38,5 @@ Twilio We have we have +lookback +Pydantic diff --git a/examples/docs_beta_snippets/docs_beta_snippets/guides/data-modeling/configuring-assets/config-schema.py b/examples/docs_beta_snippets/docs_beta_snippets/guides/data-modeling/configuring-assets/config-schema.py new file mode 100644 index 0000000000000..a3276bdc60e12 --- /dev/null +++ b/examples/docs_beta_snippets/docs_beta_snippets/guides/data-modeling/configuring-assets/config-schema.py @@ -0,0 +1,29 @@ +import dagster as dg + + +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 + + +@dg.asset +def forecast_model(config: ForecastModelConfig): + print("Forecasting over time window:", config.lookback_window_days) # noqa: T201 + # ...more code here + + +defs = dg.Definitions(assets=[forecast_model]) + +if __name__ == "__main__": + from pathlib import Path + + import yaml + + dg.materialize( + [forecast_model], + run_config=yaml.safe_load( + (Path(__file__).absolute().parent / "run_config.yaml").open() + ), + ) diff --git a/examples/docs_beta_snippets/docs_beta_snippets/guides/data-modeling/configuring-assets/run_config.yaml b/examples/docs_beta_snippets/docs_beta_snippets/guides/data-modeling/configuring-assets/run_config.yaml new file mode 100644 index 0000000000000..334ce2c71be5e --- /dev/null +++ b/examples/docs_beta_snippets/docs_beta_snippets/guides/data-modeling/configuring-assets/run_config.yaml @@ -0,0 +1,4 @@ +ops: + forecast_model: + config: + lookback_window_days: 7