dbt-checkpoint icon indicating copy to clipboard operation
dbt-checkpoint copied to clipboard

add prj_root argument to dbt commands

Open joaobernardopa opened this issue 3 years ago • 4 comments

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

joaobernardopa avatar Dec 22 '21 11:12 joaobernardopa

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

samLozier avatar Jan 12 '22 19:01 samLozier

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. :/

MartinGuindon avatar Jan 12 '22 21:01 MartinGuindon

We too are using a monorepo so this change would allow us to use pre-commit-dbt.

robscriva avatar Jan 25 '22 02:01 robscriva

@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?

tomsej avatar Jan 26 '22 09:01 tomsej

Closing PR since already supported. Thanks @joaobernardopa!

ssassi avatar Oct 03 '22 18:10 ssassi