From bbc132bc09addb6d7d63a2879010e7282f1244f3 Mon Sep 17 00:00:00 2001 From: colton Date: Thu, 20 Jun 2024 14:59:38 -0400 Subject: [PATCH] [daggy-u] fix indentation of indented code snippets (#22571) ## Summary & Motivation - Fixes indentation of code snippets for indented code blocks ## How I Tested These Changes - Previewed rendered markdown image --- ...connecting-dbt-models-to-dagster-assets.md | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/dagster-university/pages/dagster-dbt/lesson-5/2-connecting-dbt-models-to-dagster-assets.md b/docs/dagster-university/pages/dagster-dbt/lesson-5/2-connecting-dbt-models-to-dagster-assets.md index c988298fb4a43..2139852b2c13d 100644 --- a/docs/dagster-university/pages/dagster-dbt/lesson-5/2-connecting-dbt-models-to-dagster-assets.md +++ b/docs/dagster-university/pages/dagster-dbt/lesson-5/2-connecting-dbt-models-to-dagster-assets.md @@ -52,9 +52,9 @@ Open the `assets/dbt.py` file and do the following: 1. There are two properties that we’ll want from `dbt_resource_props`: the `type` (ex., model, source, seed, snapshot) and the `name`, such as `trips` or `stg_trips`. Access both of those properties from the `dbt_resource_props` argument and store them in their own respective variables (`type` and `name`): ```python - def get_asset_key(self, dbt_resource_props): - type = dbt_resource_props["resource_type"] - name = dbt_resource_props["name"] + def get_asset_key(self, dbt_resource_props): + type = dbt_resource_props["resource_type"] + name = dbt_resource_props["name"] ``` 2. As mentioned above, the asset keys of our existing Dagster assets used by our dbt project are named `taxi_trips` and `taxi_zones`. If you were to print out the `name`, you’d see that the dbt sources are named `trips` and `zones`. Therefore, to match our asset keys up, we can prefix our keys with the string `taxi_` . @@ -62,11 +62,11 @@ Open the `assets/dbt.py` file and do the following: Copy and paste the following code to return an `AssetKey` of `AssetKey(f"taxi_{name}")`: ```python - def get_asset_key(self, dbt_resource_props): - type = dbt_resource_props["resource_type"] - name = dbt_resource_props["name"] + def get_asset_key(self, dbt_resource_props): + type = dbt_resource_props["resource_type"] + name = dbt_resource_props["name"] - return AssetKey(f"taxi_{name}") + return AssetKey(f"taxi_{name}") ``` 3. You have full control over how each asset can be named, as you can define how asset keys are created. In our case we only want to rename the dbt sources, but we can keep the asset keys of the models the same. @@ -74,13 +74,13 @@ Open the `assets/dbt.py` file and do the following: The object-oriented pattern of the `DagsterDbtTranslator` means that we can leverage the existing implementations of the parent class by using the `super` method. We’ll use this pattern to customize how the sources are defined but default to the original logic for deciding the model asset keys. Copy and paste the code below to complete the `get_asset_key` function: ```python - def get_asset_key(self, dbt_resource_props): - resource_type = dbt_resource_props["resource_type"] - name = dbt_resource_props["name"] - if resource_type == "source": - return AssetKey(f"taxi_{name}") - else: - return super().get_asset_key(dbt_resource_props) + def get_asset_key(self, dbt_resource_props): + resource_type = dbt_resource_props["resource_type"] + name = dbt_resource_props["name"] + if resource_type == "source": + return AssetKey(f"taxi_{name}") + else: + return super().get_asset_key(dbt_resource_props) ``` You’ve successfully written your first translator! @@ -140,4 +140,4 @@ else: ) def dbt_analytics(context: AssetExecutionContext, dbt: DbtCliResource): yield from dbt.cli(["build"], context=context).stream() -``` \ No newline at end of file +```