dbt-bouncer 1.26.0__py3-none-any.whl → 1.27.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dbt_bouncer/runner.py +29 -6
- dbt_bouncer/utils.py +34 -1
- dbt_bouncer/version.py +1 -1
- {dbt_bouncer-1.26.0.dist-info → dbt_bouncer-1.27.1.dist-info}/METADATA +1 -1
- {dbt_bouncer-1.26.0.dist-info → dbt_bouncer-1.27.1.dist-info}/RECORD +8 -8
- {dbt_bouncer-1.26.0.dist-info → dbt_bouncer-1.27.1.dist-info}/LICENSE +0 -0
- {dbt_bouncer-1.26.0.dist-info → dbt_bouncer-1.27.1.dist-info}/WHEEL +0 -0
- {dbt_bouncer-1.26.0.dist-info → dbt_bouncer-1.27.1.dist-info}/entry_points.txt +0 -0
dbt_bouncer/runner.py
CHANGED
|
@@ -14,6 +14,7 @@ from tabulate import tabulate
|
|
|
14
14
|
from dbt_bouncer.utils import (
|
|
15
15
|
create_github_comment_file,
|
|
16
16
|
get_check_objects,
|
|
17
|
+
get_nested_value,
|
|
17
18
|
resource_in_path,
|
|
18
19
|
)
|
|
19
20
|
|
|
@@ -114,14 +115,36 @@ def runner(
|
|
|
114
115
|
iterate_value = next(iter(iterate_over_value))
|
|
115
116
|
for i in locals()[f"{iterate_value}s"]:
|
|
116
117
|
check_i = copy.deepcopy(check)
|
|
118
|
+
if iterate_value in ["model", "semantic_model", "snapshot", "source"]:
|
|
119
|
+
try:
|
|
120
|
+
d = getattr(i, iterate_value).config.meta
|
|
121
|
+
except Exception:
|
|
122
|
+
d = getattr(i, iterate_value).meta
|
|
123
|
+
elif iterate_value in ["catalog_node", "run_result"]:
|
|
124
|
+
d = {}
|
|
125
|
+
elif iterate_value in ["macro"]:
|
|
126
|
+
d = i.meta
|
|
127
|
+
else:
|
|
128
|
+
try:
|
|
129
|
+
d = i.config.meta
|
|
130
|
+
except Exception:
|
|
131
|
+
d = i.meta
|
|
132
|
+
meta_config = get_nested_value(
|
|
133
|
+
d,
|
|
134
|
+
["dbt-bouncer", "skip_checks"],
|
|
135
|
+
[],
|
|
136
|
+
)
|
|
117
137
|
if resource_in_path(check_i, i) and (
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
138
|
+
(
|
|
139
|
+
iterate_over_value != {"model"}
|
|
140
|
+
or (
|
|
141
|
+
iterate_over_value == {"model"}
|
|
142
|
+
and check_i.materialization == i.model.config.materialized
|
|
143
|
+
if check_i.materialization is not None
|
|
144
|
+
else True
|
|
145
|
+
)
|
|
124
146
|
)
|
|
147
|
+
and (check_i.name not in meta_config if meta_config != [] else True)
|
|
125
148
|
):
|
|
126
149
|
check_run_id = (
|
|
127
150
|
f"{check_i.name}:{check_i.index}:{i.unique_id.split('.')[-1]}"
|
dbt_bouncer/utils.py
CHANGED
|
@@ -9,7 +9,7 @@ import re
|
|
|
9
9
|
import sys
|
|
10
10
|
from functools import lru_cache
|
|
11
11
|
from pathlib import Path
|
|
12
|
-
from typing import TYPE_CHECKING, Any, List, Mapping, Type
|
|
12
|
+
from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, Type
|
|
13
13
|
|
|
14
14
|
import click
|
|
15
15
|
import yaml
|
|
@@ -58,6 +58,39 @@ def create_github_comment_file(
|
|
|
58
58
|
f.write(md_formatted_comment)
|
|
59
59
|
|
|
60
60
|
|
|
61
|
+
def get_nested_value(
|
|
62
|
+
d: Dict[str, Any], keys: List[str], default: Optional[Any] = None
|
|
63
|
+
) -> Any:
|
|
64
|
+
"""Retrieve a value from a nested dictionary using a list of keys.
|
|
65
|
+
|
|
66
|
+
This function safely traverses a dictionary structure, allowing access to
|
|
67
|
+
deeply nested values. If any key in the `keys` list does not exist at
|
|
68
|
+
its respective level, the function returns the specified default value.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
d: The dictionary to traverse.
|
|
72
|
+
keys: A list of strings representing the sequence of keys to follow
|
|
73
|
+
to reach the desired nested value.
|
|
74
|
+
default: The value to return if any key in the `keys` list is not
|
|
75
|
+
found at its corresponding level, or if an intermediate
|
|
76
|
+
value is not a dictionary. Defaults to None.
|
|
77
|
+
|
|
78
|
+
Returns:
|
|
79
|
+
The value found at the specified nested path, or the `default` value
|
|
80
|
+
if any part of the path is invalid or not found.
|
|
81
|
+
|
|
82
|
+
"""
|
|
83
|
+
current_level = d
|
|
84
|
+
for key in keys:
|
|
85
|
+
if isinstance(current_level, dict):
|
|
86
|
+
current_level = current_level.get(key, default) # type: ignore[assignment]
|
|
87
|
+
if current_level is default and key != keys[-1]:
|
|
88
|
+
return default
|
|
89
|
+
else:
|
|
90
|
+
return default
|
|
91
|
+
return current_level
|
|
92
|
+
|
|
93
|
+
|
|
61
94
|
def resource_in_path(check, resource) -> bool:
|
|
62
95
|
"""Validate that a check is applicable to a specific resource path.
|
|
63
96
|
|
dbt_bouncer/version.py
CHANGED
|
@@ -25,11 +25,11 @@ dbt_bouncer/config_file_parser.py,sha256=gq7fINTmLFVWR4todXkPd_dnh0-9vnM3jHYtgk1
|
|
|
25
25
|
dbt_bouncer/config_file_validator.py,sha256=lEPv6AfXmUGwuSpl4GzZ4LB0yId7yqjeB2raWfuBs3s,10893
|
|
26
26
|
dbt_bouncer/logger.py,sha256=qkwB-SVUE4YUUp-MtmbcDPUX7t3zdniQL5Linuomr94,1804
|
|
27
27
|
dbt_bouncer/main.py,sha256=n-jOsKlDwAlB2uF__J_DtkU8BC7CqeKMOU_f8axB1fo,6433
|
|
28
|
-
dbt_bouncer/runner.py,sha256=
|
|
29
|
-
dbt_bouncer/utils.py,sha256
|
|
30
|
-
dbt_bouncer/version.py,sha256=
|
|
31
|
-
dbt_bouncer-1.
|
|
32
|
-
dbt_bouncer-1.
|
|
33
|
-
dbt_bouncer-1.
|
|
34
|
-
dbt_bouncer-1.
|
|
35
|
-
dbt_bouncer-1.
|
|
28
|
+
dbt_bouncer/runner.py,sha256=fdgpOUS8ckS_rZbklOUqFSxmD6I8WYRhQU09HZI0Ghs,10628
|
|
29
|
+
dbt_bouncer/utils.py,sha256=-jZjc6R0tjHWqpTjgHIb7Ej6Cqwdbchbl7L8IB4mo1I,9890
|
|
30
|
+
dbt_bouncer/version.py,sha256=APUCpZKUckcAWXM15kqluOILmeKYdfcec8_x6P9moWg,149
|
|
31
|
+
dbt_bouncer-1.27.1.dist-info/LICENSE,sha256=gGXp4VL__ZWlTWhXHRjWJmkxl5X9UJ7L7n1dr2WlfsY,1074
|
|
32
|
+
dbt_bouncer-1.27.1.dist-info/METADATA,sha256=9VUgdeLjgF9ffY1Vxw4mUjVun8NEsbh29q0JjvHi6Ho,4606
|
|
33
|
+
dbt_bouncer-1.27.1.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
|
34
|
+
dbt_bouncer-1.27.1.dist-info/entry_points.txt,sha256=jEl2FZDm4gO8u4x9m8qS0zMf9Fk2FAwLfI4N4sreGxI,52
|
|
35
|
+
dbt_bouncer-1.27.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|