Skip to content

Commit

Permalink
allow setting enabled and depends_on_nodes from ModelNodeArgs (#7930)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelleArk authored Jun 27, 2023
1 parent 6a1e3a6 commit a84fa50
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20230627-152207.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Features
body: allow setting enabled and depends_on_nodes from ModelNodeArgs
time: 2023-06-27T15:22:07.313639-04:00
custom:
Author: michelleark
Issue: "7506"
4 changes: 3 additions & 1 deletion core/dbt/contracts/graph/node_args.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass, field
from datetime import datetime
from typing import Optional
from typing import Optional, List

from dbt.contracts.graph.unparsed import NodeVersion

Expand All @@ -17,3 +17,5 @@ class ModelNodeArgs:
latest_version: Optional[NodeVersion] = None
deprecation_date: Optional[datetime] = None
generated_at: datetime = field(default_factory=datetime.utcnow)
depends_on_nodes: List[str] = field(default_factory=list)
enabled: bool = True
4 changes: 4 additions & 0 deletions core/dbt/contracts/graph/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,8 @@ class ModelNode(CompiledNode):
@classmethod
def from_args(cls, args: ModelNodeArgs) -> "ModelNode":
unique_id = f"{NodeType.Model}.{args.package_name}.{args.name}"
if args.version:
unique_id = f"{unique_id}.{args.version}"

return cls(
resource_type=NodeType.Model,
Expand All @@ -599,6 +601,8 @@ def from_args(cls, args: ModelNodeArgs) -> "ModelNode":
checksum=FileHash.from_contents(f"{unique_id},{args.generated_at}"),
original_file_path="",
path="",
depends_on=DependsOn(nodes=args.depends_on_nodes),
config=NodeConfig(enabled=args.enabled),
)

@property
Expand Down

0 comments on commit a84fa50

Please sign in to comment.