Neha Chopra

12/05/2022, 10:59 PM
Hi Everyone! I am looking for some advice on Prefect-DBT Core integration. My company uses Prefect version 1. I initially started with cloning DBT repo into Prefect method(referred online resource) which worked fine locally but not inside the Prefect cloud as our internal org repos have strict security policies that don't allow them to be cloned inside 3rd party products. Hence, I decided to try out the git submodule method where the DBT repo resides as a submodule inside Prefect repo and I use DBTShellTask to execute the DAG commands(like below). The flow works fine in my local but in Prefect, it fails due to statement helper_script=f"cd { DBT_DIR}" as it is unable to access the right folder. It evaluates helper_script as (cd: /Users/my-username/Development/prefect-repo/containers/dbt-prefect-container/dbt-repo)
dbt = DbtShellTask(
        # profiles_dir=".",
        helper_script=f"cd {DBT_DIR}",
        dbt_kwargs={ # removed for readability}
        )(command="dbt docs generate")
The folder structure is like: prefect-repo |- containers |- dbt-prefect-container |-dbt-repo(submodule) |- flows | (from where I want to access the location DBT_DIR) My questions are: 1. Is it okay to use git submodule method inside Prefect? 2. How to pass correct repo location so that Prefect cloud doesn't start the root at local dir: /Users/my-username
1️⃣ 1

Mason Menges

12/06/2022, 5:27 PM
Hey @Neha Chopra this discourse article I think might offer some suggestions for how to get around this and how to set the path, Normally for prefect 1 we'd suggest containerizing the flow to ensure it has all of the necessary dependencies to run. All that said Prefect 2 is likely better able to accommodate this through deployments, this covers a lot of the common use cases around them