-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Provide ability to exclude resource_types, instead of listing everything not excluded #9756
Changes from 7 commits
061a9ab
244bb80
c0acc91
87d2e40
c5444a6
9b8cbe8
510bb33
5a8afb1
39cce08
50f4952
4790a75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Features | ||
body: Allow excluding resource types for build, list, and clone commands | ||
time: 2024-03-12T14:04:07.086017-04:00 | ||
custom: | ||
Author: gshank | ||
Issue: "9237" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
from dbt_common.exceptions import DbtInternalError, CompilationError | ||
from dbt.graph import ResourceTypeSelector | ||
from dbt.node_types import NodeType, REFABLE_NODE_TYPES | ||
from dbt.task.base import BaseRunner | ||
from dbt.task.base import BaseRunner, resource_types_from_args | ||
from dbt.task.run import _validate_materialization_relations_dict | ||
from dbt.task.runnable import GraphRunnableTask | ||
|
||
|
@@ -132,18 +132,12 @@ def before_run(self, adapter, selected_uids: AbstractSet[str]): | |
|
||
@property | ||
def resource_types(self): | ||
if not self.args.resource_types: | ||
return REFABLE_NODE_TYPES | ||
|
||
values = set(self.args.resource_types) | ||
|
||
if "all" in values: | ||
values.remove("all") | ||
values.update(REFABLE_NODE_TYPES) | ||
|
||
values = [NodeType(val) for val in values if val in REFABLE_NODE_TYPES] | ||
resource_types = resource_types_from_args( | ||
self.args, set(REFABLE_NODE_TYPES), set(REFABLE_NODE_TYPES) | ||
) | ||
|
||
return list(values) | ||
resource_types = [NodeType(rt) for rt in resource_types if rt in REFABLE_NODE_TYPES] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps we could do this prior to returning from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the point of this is not so much converting to NodeType (which I did move to "resource_types_from_args) but limiting it to REFABLE_NODE_TYPES. Otherwise somebody could specify a resource_type that's not actually clonable. |
||
return list(resource_types) | ||
|
||
def get_node_selector(self) -> ResourceTypeSelector: | ||
resource_types = self.resource_types | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are all_resource_values and default_resource_values actually
Set[NodeType]
s?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Good catch. I've redefined them. As a sidenote, I'm always surprised by what mypy does and does not catch. I would have though it would complain about that. Maybe it automatically converts enums to strings?