Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add prj_root argument to dbt commands #48

Conversation

joaobernardopa
Copy link

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 #39

@samLozier
Copy link

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

@MartinGuindon
Copy link

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

@robscriva
Copy link

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

@tomsej
Copy link
Contributor

tomsej commented Jan 26, 2022

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

@ssassi
Copy link
Collaborator

ssassi commented Oct 3, 2022

Closing PR since already supported. Thanks @joaobernardopa!

@ssassi ssassi closed this Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants