Ashley Dsouza
07/14/2022, 1:40 PMowen
07/14/2022, 5:23 PMowen
07/14/2022, 5:23 PMowen
07/14/2022, 5:29 PMimport os
from dagster import op
LOCAL_DBT_PROJECT_PATH = "/path/to/local/project"
@op
def clone_dbt_project():
if not os.path.exists(LOCAL_DBT_PROJECT_PATH):
os.makedirs(LOCAL_DBT_PROJECT_PATH)
# ... some code to download current state of the dbt Cloud project
from there, you could put this into a simple job, and run it on a schedule, maybe every 5 minutes or something like that. This would ensure that you had a reasonably up-to-date local copy.owen
07/14/2022, 5:34 PM@asset
def cloned_dbt_project():
if not os.path.exists(LOCAL_DBT_PROJECT_PATH):
os.makedirs(LOCAL_DBT_PROJECT_PATH)
# ... some code to download current state of the dbt Cloud
from there, you'd need a way to tell Dagster that the dbt Cloud assets depend on this cloned_dbt_project asset. I think you would be able to do that by messing with the sources.yml file in your dbt project (as dagster parses that to figure out how to map dbt sources to dagster assets). It'd definitely be a bit of a hack, but it should work well enough.owen
07/14/2022, 5:34 PMAshley Dsouza
07/15/2022, 2:55 PM