Skip to content

Commit

Permalink
dbt logs total GB processed
Browse files Browse the repository at this point in the history
  • Loading branch information
austinweisgrau committed Aug 22, 2024
1 parent 75d542c commit c871f2b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions parsons/utilities/dbt/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ def format_command_result(
log_summary_str = "No models ran."
log_message += "\n*Summary*: `{}`".format(log_summary_str)

log_message += "\n*GB Processed*: {:.2f}".format(manifest.total_gb_processed)

# Errors
if manifest.errors or manifest.fails:
log_message += "\nError messages:\n```{}```".format(
Expand Down
13 changes: 11 additions & 2 deletions parsons/utilities/dbt/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def __init__(self, command: str, dbt_manifest: dbtManifest) -> None:
self.dbt_manifest = dbt_manifest

def __getattr__(self, key):
if key in self.__dict__:
result = self.__dict__[key]
if key in dir(self):
result = getattr(self, key)
elif (
getattr(self.dbt_manifest, "metadata", {})
and key in self.dbt_manifest.metadata.__dict__
Expand Down Expand Up @@ -57,3 +57,12 @@ def summary(self) -> collections.Counter:
"""Counts of pass, warn, fail, error & skip."""
result = collections.Counter([str(i.status) for i in self.dbt_manifest])
return result

@property
def total_gb_processed(self) -> float:
"""Total GB processed by full dbt command run."""
result = (
sum([node.adapter_response.get("bytes_processed", 0) for node in self.dbt_manifest])
/ 1000000000
)
return result

0 comments on commit c871f2b

Please sign in to comment.