Skip to content

Commit

Permalink
Attempt to fix popping config from selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
tatiana committed Aug 16, 2023
1 parent 36a89a6 commit 5b961a5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cosmos/dbt/selector.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations
from pathlib import Path

import copy
from pathlib import Path
from typing import TYPE_CHECKING

from cosmos.exceptions import CosmosValueError
Expand Down Expand Up @@ -88,22 +89,24 @@ def select_nodes_ids_by_intersection(nodes: dict[str, DbtNode], config: Selector
https://docs.getdbt.com/reference/node-selection/yaml-selectors
"""
selected_nodes = set()

if not config.is_empty:
for node_id, node in nodes.items():
if config.tags and not (sorted(node.tags) == sorted(config.tags)):
continue

supported_node_config = {key: value for key, value in node.config.items() if key in SUPPORTED_CONFIG}
config_tag = config.config.get("tags")
if config.config:
config_tag = config.config.get("tags")
if config_tag and config_tag not in supported_node_config.get("tags", []):
continue

# Remove 'tags' as they've already been filtered for
config.config.pop("tags", None)
config_copy = copy.deepcopy(config.config)
config_copy.pop("tags", None)
supported_node_config.pop("tags", None)

if not (config.config.items() <= supported_node_config.items()):
if not (config_copy.items() <= supported_node_config.items()):
continue

if config.paths and not (set(config.paths).issubset(set(node.file_path.parents))):
Expand Down

0 comments on commit 5b961a5

Please sign in to comment.