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

allow setting enabled and depends_on_nodes from ModelNodeArgs #7930

Merged
merged 3 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
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
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