Skip to content

Commit

Permalink
Add access, has_group, contract_enforced, versioned to run_model (#7309)
Browse files Browse the repository at this point in the history
  • Loading branch information
gshank authored Apr 12, 2023
1 parent 2caf87c commit 922c753
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20230411-114149.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Track data about group, access, contract, version usage
time: 2023-04-11T11:41:49.84883-04:00
custom:
Author: gshank
Issue: 7170 7171
22 changes: 18 additions & 4 deletions core/dbt/task/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ def track_model_run(index, num_nodes, run_model_result):
if tracking.active_user is None:
raise DbtInternalError("cannot track model run with no active user")
invocation_id = get_invocation_id()
node = run_model_result.node
has_group = True if hasattr(node, "group") and node.group else False
if node.resource_type == NodeType.Model:
access = node.access.value if node.access is not None else None
contract_enforced = node.contract.enforced
versioned = True if node.version else False
else:
access = None
contract_enforced = False
versioned = False
tracking.track_model_run(
{
"invocation_id": invocation_id,
Expand All @@ -117,11 +127,15 @@ def track_model_run(index, num_nodes, run_model_result):
"run_status": str(run_model_result.status).upper(),
"run_skipped": run_model_result.status == NodeStatus.Skipped,
"run_error": run_model_result.status == NodeStatus.Error,
"model_materialization": run_model_result.node.get_materialization(),
"model_id": utils.get_hash(run_model_result.node),
"hashed_contents": utils.get_hashed_contents(run_model_result.node),
"model_materialization": node.get_materialization(),
"model_id": utils.get_hash(node),
"hashed_contents": utils.get_hashed_contents(node),
"timing": [t.to_dict(omit_none=True) for t in run_model_result.timing],
"language": str(run_model_result.node.language),
"language": str(node.language),
"has_group": has_group,
"contract_enforced": contract_enforced,
"access": access,
"versioned": versioned,
}
)

Expand Down
4 changes: 2 additions & 2 deletions core/dbt/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
PARTIAL_PARSER = "iglu:com.dbt/partial_parser/jsonschema/1-0-1"
PLATFORM_SPEC = "iglu:com.dbt/platform/jsonschema/1-0-0"
PROJECT_ID_SPEC = "iglu:com.dbt/project_id/jsonschema/1-0-1"
RESOURCE_COUNTS = "iglu:com.dbt/resource_counts/jsonschema/1-0-0"
RESOURCE_COUNTS = "iglu:com.dbt/resource_counts/jsonschema/1-0-1"
RPC_REQUEST_SPEC = "iglu:com.dbt/rpc_request/jsonschema/1-0-1"
RUNNABLE_TIMING = "iglu:com.dbt/runnable/jsonschema/1-0-0"
RUN_MODEL_SPEC = "iglu:com.dbt/run_model/jsonschema/1-0-2"
RUN_MODEL_SPEC = "iglu:com.dbt/run_model/jsonschema/1-0-3"


class TimeoutEmitter(Emitter):
Expand Down

0 comments on commit 922c753

Please sign in to comment.