From 521bf24728ea0450ee29783807d711558a3ea85a Mon Sep 17 00:00:00 2001 From: Stian Thaulow <43840258+stianthaulow@users.noreply.github.com> Date: Thu, 6 Jun 2024 19:20:17 +0200 Subject: [PATCH] [du][dbt] fix indentation in dagster_dbt lession 5 (#22277) ## Summary & Motivation ![image](https://github.com/dagster-io/dagster/assets/43840258/a4507d0e-2aec-46e3-8764-ddea1022d85c) ## How I Tested These Changes --- ...eating-assets-that-depend-on-dbt-models.md | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/docs/dagster-university/pages/dagster-dbt/lesson-5/3-creating-assets-that-depend-on-dbt-models.md b/docs/dagster-university/pages/dagster-dbt/lesson-5/3-creating-assets-that-depend-on-dbt-models.md index 266da1ed0793a..185f3144a9233 100644 --- a/docs/dagster-university/pages/dagster-dbt/lesson-5/3-creating-assets-that-depend-on-dbt-models.md +++ b/docs/dagster-university/pages/dagster-dbt/lesson-5/3-creating-assets-that-depend-on-dbt-models.md @@ -111,49 +111,49 @@ Now we’re ready to create the asset! deps=["location_metrics"], ) def airport_trips(database: DuckDBResource) -> MaterializeResult: - """ - A chart of where trips from the airport go - """ - - query = """ - select - zone, - destination_borough, - trips - from location_metrics - where from_airport - """ - - with database.get_connection() as conn: - airport_trips = conn.execute(query).fetch_df() - - fig = px.bar( - airport_trips, - x="zone", - y="trips", - color="destination_borough", - barmode="relative", - labels={ - "zone": "Zone", - "trips": "Number of Trips", - "destination_borough": "Destination Borough" - }, - ) + """ + A chart of where trips from the airport go + """ + + query = """ + select + zone, + destination_borough, + trips + from location_metrics + where from_airport + """ + + with database.get_connection() as conn: + airport_trips = conn.execute(query).fetch_df() + + fig = px.bar( + airport_trips, + x="zone", + y="trips", + color="destination_borough", + barmode="relative", + labels={ + "zone": "Zone", + "trips": "Number of Trips", + "destination_borough": "Destination Borough" + }, + ) - pio.write_image(fig, constants.AIRPORT_TRIPS_FILE_PATH) + pio.write_image(fig, constants.AIRPORT_TRIPS_FILE_PATH) - with open(constants.AIRPORT_TRIPS_FILE_PATH, 'rb') as file: - image_data = file.read() + with open(constants.AIRPORT_TRIPS_FILE_PATH, 'rb') as file: + image_data = file.read() - # Convert the image data to base64 - base64_data = base64.b64encode(image_data).decode('utf-8') - md_content = f"![Image](data:image/jpeg;base64,{base64_data})" + # Convert the image data to base64 + base64_data = base64.b64encode(image_data).decode('utf-8') + md_content = f"![Image](data:image/jpeg;base64,{base64_data})" - return MaterializeResult( - metadata={ - "preview": MetadataValue.md(md_content) - } - ) + return MaterializeResult( + metadata={ + "preview": MetadataValue.md(md_content) + } + ) ``` 5. Reload your code location to see the new `airport_trips` asset within the `metrics` group. Notice how the asset graph links the dependency between the `location_metrics` dbt asset and the new `airport_trips` chart asset: