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

Exclude tests for disabled models in compile stats #2026

Merged
merged 2 commits into from
Jan 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions core/dbt/compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,25 @@ def print_compile_stats(stats):
logger.info("Found {}".format(stat_line))


def _node_enabled(node):
# Disabled models are already excluded from the manifest
if node.resource_type == NodeType.Test and not node.config.enabled:
return False
else:
return True


def _generate_stats(manifest):
stats = defaultdict(int)
for node_name, node in itertools.chain(
manifest.nodes.items(),
manifest.macros.items()):
if _node_enabled(node):
stats[node.resource_type] += 1

return stats


def _add_prepended_cte(prepended_ctes, new_cte):
for cte in prepended_ctes:
if cte.id == new_cte.id:
Expand Down Expand Up @@ -199,12 +218,7 @@ def compile(self, manifest, write=True):

self.link_graph(linker, manifest)

stats = defaultdict(int)

for node_name, node in itertools.chain(
manifest.nodes.items(),
manifest.macros.items()):
stats[node.resource_type] += 1
stats = _generate_stats(manifest)

if write:
self.write_graph_file(linker, manifest)
Expand Down