Skip to content

Commit

Permalink
Merge pull request #2026 from NiallRees/fix/disabled_tests_in_stats
Browse files Browse the repository at this point in the history
Exclude tests for disabled models in compile stats
  • Loading branch information
drewbanin authored Jan 21, 2020
2 parents 1021637 + 554b32e commit 38244bf
Showing 1 changed file with 20 additions and 6 deletions.
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

0 comments on commit 38244bf

Please sign in to comment.