dbt-checkpoint
dbt-checkpoint copied to clipboard
add prj_root argument to dbt commands
This enhancement enables user to benefit from dbt-command hooks whenever their dbt project is not at the root level of the repo. It works by providing an additional argument to the dbt commands. Example: hooks: - id: dbt-docs-generate files: ^projects/ args: ["--prj-root","./common/dbt"] - id: dbt-deps files: ^projects/ args: ["--prj-root","./common/dbt"]
In this example, the root of the dbt project is located inside the folder './commond/dbt'.
Addresses issue https://github.com/offbi/pre-commit-dbt/issues/39
would it be relatively easy to also add a profiles-dir argument? i run these hooks both locally and in CI and that location can change
You can already pass the project-dir argument to the dbt-compile, dbt-run and dbt-test hooks as such:
- id: dbt-compile
args: ["--cmd-flags", "++project-dir", "./transform/dbt", "--"]
However the cmd-flags argument is not supported in the other hooks currently. :/
We too are using a monorepo so this change would allow us to use pre-commit-dbt
.
@joaobernardopa thank you for PR! But honestly, I am not sure about merging that. As @MartinGuindon mentioned pre-commit-dbt
is already supporting custom project-dir
with:
- id: dbt-compile
args: ["--cmd-flags", "++project-dir", "./transform/dbt", "--"]
Think this solution is more flexible to your proposal since you can add any other dbt
flag.
Unfortunately, this notation is supported only in compile
, run
, and test
. There is another PR #53 that is allowing it to clean
, deps
. Would it cover your requirements?
Closing PR since already supported. Thanks @joaobernardopa!