Skip to content

Commit

Permalink
[du][dbt] fix indentation in dagster_dbt lession 5 (#22277)
Browse files Browse the repository at this point in the history
## Summary & Motivation


![image](https://github.com/dagster-io/dagster/assets/43840258/a4507d0e-2aec-46e3-8764-ddea1022d85c)


## How I Tested These Changes
  • Loading branch information
stianthaulow authored Jun 6, 2024
1 parent bdada50 commit 521bf24
Showing 1 changed file with 39 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

1 comment on commit 521bf24

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagster-university ready!

✅ Preview
https://dagster-university-3fi3e5s2y-elementl.vercel.app

Built with commit 521bf24.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.