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

feature: Add the ability to run dbt-docs-generate on only changed files #210

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

astro30
Copy link

@astro30 astro30 commented Apr 12, 2024

This is addressing #196

dbt docs generate is very slow and is a bottleneck in development. The idea is to mimic the behavior of the other cli hooks such as dbt run to pick only the changed models to be documented in order to pursue check on column documentations, tests, etc.

@@ -236,7 +236,8 @@
description: The command is responsible for generating your project's documentation website.
entry: dbt-docs-generate
language: python
pass_filenames: false
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have turn this flags OFF to be able to get back filenames in the args

run_dbt_cmd,
)


def docs_generate_cmd(
def prepare_cmd(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed docs_generate_cmdto prepare_cmd to be aligned with the rest of the codebase

Comment on lines -19 to +33
config: Dict[str, Any] = {}
prefix: str = "",
postfix: str = "",
models: Optional[Sequence[str]] = None,
config: Dict[str, Any] = {},
) -> List[str]:
global_flags = get_flags(global_flags)
cmd_flags = get_flags(cmd_flags)
if models:
dbt_models = models
else:
dbt_models = paths_to_dbt_models(paths, prefix, postfix)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to not reinvent the wheel here, this is heavily inspired by dbt_runcurrent hook.

return extend_dbt_project_dir_flag(cmd, cmd_flags, dbt_project_dir)


def main(argv: Optional[Sequence[str]] = None) -> int:
parser = argparse.ArgumentParser()
add_filenames_args(parser)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get the filenames to be available

add_dbt_cmd_args(parser)
add_dbt_cmd_model_args(parser)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If models are passed, let them be go through to args

Comment on lines +239 to +240
require_serial: true
types_or: [sql]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want only .sql files to be considered. We are missing dbt models .py here

@qgallet
Copy link

qgallet commented Apr 29, 2024

Any news on this one ? This is a feature we'd also like to have for our workflows

@SuperbTUM
Copy link

So with this MR, we need another restriction of dbt-core>=1.7?

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

3 participants