https://dagster.io/ logo
#integration-dbt
Title
# integration-dbt
m

Mike Needham

12/07/2022, 10:16 AM
so I have a working dbt set of models and when I try to use the load_assets_from_dbt_project poointing to my dbt project I get the error Error loading repository location myproject_dagsterdagster. core.errors.DagsterImportError Encountered ImportError: `cannot import name 'load_assets_from_dbt_project' from partially initialized module 'myproject_dagster' (most likely due to a circular import)
r

rex

12/07/2022, 1:21 PM
We’ll need more information to diagnose your error: • Could you show the snippet of code where you’re using
load_assets_from_dbt_project
? • How are you invoking dagit?
m

Mike Needham

12/07/2022, 1:31 PM
from myproject_dagster import load_assets_from_dbt_project from dagster import file_relative_path DBT_PROJECT_PATH = file_relative_path(file, "../../dbt-project/project1") DBT_PROFILES = file_relative_path(file, ".../../dbt-project/project1/") # dbt_assets = load_assets_from_dbt_manifest("../../dbt-project/project1/target") dbt_assets = load_assets_from_dbt_project ( project_dir = DBT_PROJECT_PATH, profiles_dir=DBT_PROFILES, key_prefix=["project1"] )
this is just from a scaffold project
and just running dagit from the terminal
using vscode remotely on a linux dev box
r

rex

12/07/2022, 2:06 PM
you should be importing load_assets_from_dbt_project from dagster-dbt
its a separate package you need to install
m

Mike Needham

12/07/2022, 3:09 PM
yes, that is what I followed. the instructions do not address the error. the code above is the snippet from the tutorial. all things are installed as far as I can tell
r

rex

12/07/2022, 3:13 PM
You are doing
from myproject_dagster import load_assets_from_dbt_project
The tutorial says
from dagster_dbt import load_assets_from_dbt_project
m

Mike Needham

12/07/2022, 3:22 PM
thank you, I missed that when trying something else
so i ripped everything out, re downloaded the dbt example and am trying to point to my existing dbt project in a different directory. I cannot seem to get the relative path to work. it either complains about not being to find the profile name of the project or it says invalid project directory. not dbt_project.yml
it must be something simple, but have tried various levels of ../../ with no success
r

rex

12/07/2022, 7:05 PM
it should be the file path relative to the current file you’re working in. You can debug if the file path is correct by printing out the file path locally
m

Mike Needham

12/07/2022, 8:27 PM
I have the path, but then it complains about the dbt_project.yml. not sure what else to do as the DBT project is fine and runs correctly
so i think i have the correct path now but am geting 2022-12-07 144528 -0600 - dagster.builtin - ERROR - Encountered an error while reading the project: 2022-12-07 144528 -0600 - dagster.builtin - ERROR - ERROR: Runtime Error Could not find profile named 'PM3_Loaders' 2022-12-07 144528 -0600 - dagster.builtin - ERROR - Encountered an error: Runtime Error Could not run dbt
that is the DBT project and is in the dbt_project.yml as the name
r

rex

12/07/2022, 8:47 PM
You’re running into dbt errors now, not Dagster errors. You should make sure that your dbt project is well formed. https://docs.getdbt.com/guides/legacy/debugging-errors#could-not-find-profile
m

Mike Needham

12/07/2022, 8:48 PM
it is I can run it with no errors
it is when I try and combine the two that it does not work. I have one vscode session with the dbt project open and one with the dagster project
r

rex

12/07/2022, 8:52 PM
Again, it looks like your profiles variable is wrong. This is usually hosted in the
/config
directory of your project. From what you posted above:
DBT_PROFILES = file_relative_path(__file__, ".../../dbt-project/project1/")
This should probably be
DBT_PROFILES = file_relative_path(__file__, ".../../dbt-project/project1/config")
The guide is here: https://docs.dagster.io/integrations/dbt/using-dbt-with-dagster/part-two#step-1-load-the-dbt-models-as-assets
m

Mike Needham

12/07/2022, 9:10 PM
I do not have them in a config directory . the dbt template put the dbt_project.yml in the root of the project
r

rex

12/07/2022, 9:11 PM
where did you put your
profiles.yml
?
m

Mike Needham

12/07/2022, 9:12 PM
whatever the default is. looks like .dbt
r

rex

12/07/2022, 9:13 PM
then use
DBT_PROFILES = file_relative_path(__file__, ".../../dbt-project/project1/.dbt")
?
m

Mike Needham

12/07/2022, 9:13 PM
that was it, I am an idiot. thank you for your help.
still trying to get a proof of concept going with this to try and sell my team on this approach
17 Views