-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[daggy-u][dbt] Update dbt course to use DbtProject (#23098)
## Summary & Motivation This PR updates the dbt course in Dagster University to use DbtProject. To do outside this PR: - update the knowledge check/quiz in Lesson 4. The `DAGSTER_DBT_PARSE_PROJECT_ON_LOAD` env var is no longer used. ## How I Tested These Changes (cherry picked from commit b6156a4)
- Loading branch information
1 parent
c2afce3
commit f73d328
Showing
10 changed files
with
133 additions
and
179 deletions.
There are no files selected for viewing
31 changes: 0 additions & 31 deletions
31
...ty/pages/dagster-dbt/lesson-3/3-defining-the-dbt-project-location-in-dagster.md
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
...versity/pages/dagster-dbt/lesson-3/3-representing-the-dbt-project-in-dagster.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
title: 'Lesson 3: Representing the dbt project in Dagster' | ||
module: 'dagster_dbt' | ||
lesson: '3' | ||
--- | ||
|
||
# Representing the dbt project in Dagster | ||
|
||
As you’ll frequently point your Dagster code to the `target/manifest.json` file and your dbt project in this course, it’ll be helpful to keep a reusable representation of the dbt project. This can be easily done using the `DbtProject` class. | ||
|
||
In the `dagster_university` directory, create a new `project.py` file and add the following imports: | ||
|
||
```python | ||
from pathlib import Path | ||
|
||
from dagster_dbt import DbtProject | ||
``` | ||
|
||
The `Path` class from the `pathlib` standard library will help us create an accurate pointer to where our dbt project is. The `DbtProject` class is imported from the `dagster_dbt` package that we installed earlier. | ||
|
||
After the import, add the following code: | ||
|
||
```python | ||
dbt_project = DbtProject( | ||
project_dir=Path(__file__).joinpath("..", "..", "analytics").resolve(), | ||
) | ||
``` | ||
|
||
This code creates a representation of the dbt project called `dbt_project`. The code defining the location of the project directory might look a little complicated, so let’s break it down: | ||
|
||
- The location of the `project.py` file (via `__file__`) is used as a point of reference for finding the dbt project | ||
- The arguments in `joinpath` point us towards our dbt project by appending the following to the current path: | ||
- Three directory levels up (`"..", "..", ".."`) | ||
- A directory named `analytics`, which is the directory containing our dbt project | ||
- The `resolve` method turns that path into an absolute file path that points to the dbt project correctly from any file we’re working in | ||
|
||
Now that you can access your dbt project from any other file with the `dbt_project` representation, let’s move on to the first place where you’ll use it: creating the Dagster resource that will run dbt. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
f73d328
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for dagster-docs ready!
✅ Preview
https://dagster-docs-8mu9siajk-elementl.vercel.app
https://release-1-8-0.dagster.dagster-docs.io
Built with commit f73d328.
This pull request is being automatically deployed with vercel-action