From ed1d90233d2564455e48f87a017d7da36aca4c57 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Thu, 22 Jun 2023 18:53:08 -0400 Subject: [PATCH 1/2] allow setting enabled and depends_on_nodes from ModelNodeArgs --- core/dbt/contracts/graph/node_args.py | 4 +++- core/dbt/contracts/graph/nodes.py | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/dbt/contracts/graph/node_args.py b/core/dbt/contracts/graph/node_args.py index 0694952aef5..69e86686c6a 100644 --- a/core/dbt/contracts/graph/node_args.py +++ b/core/dbt/contracts/graph/node_args.py @@ -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 @@ -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 diff --git a/core/dbt/contracts/graph/nodes.py b/core/dbt/contracts/graph/nodes.py index d24384f6cad..c5cd99496f1 100644 --- a/core/dbt/contracts/graph/nodes.py +++ b/core/dbt/contracts/graph/nodes.py @@ -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, @@ -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 From f85e2981f7472259d1a474284bfd07bf3f0307d7 Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Tue, 27 Jun 2023 15:22:14 -0400 Subject: [PATCH 2/2] changelog entry --- .changes/unreleased/Features-20230627-152207.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Features-20230627-152207.yaml diff --git a/.changes/unreleased/Features-20230627-152207.yaml b/.changes/unreleased/Features-20230627-152207.yaml new file mode 100644 index 00000000000..ff2b8fabdc0 --- /dev/null +++ b/.changes/unreleased/Features-20230627-152207.yaml @@ -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"