altimate-datapilot-cli 0.0.8__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.
- altimate_datapilot_cli-0.0.8.dist-info/AUTHORS.rst +5 -0
- altimate_datapilot_cli-0.0.8.dist-info/LICENSE +9 -0
- altimate_datapilot_cli-0.0.8.dist-info/METADATA +102 -0
- altimate_datapilot_cli-0.0.8.dist-info/RECORD +139 -0
- altimate_datapilot_cli-0.0.8.dist-info/WHEEL +5 -0
- altimate_datapilot_cli-0.0.8.dist-info/entry_points.txt +4 -0
- altimate_datapilot_cli-0.0.8.dist-info/top_level.txt +1 -0
- datapilot/__init__.py +1 -0
- datapilot/__main__.py +14 -0
- datapilot/cli/__init__.py +0 -0
- datapilot/cli/main.py +11 -0
- datapilot/clients/__init__.py +0 -0
- datapilot/clients/altimate/__init__.py +0 -0
- datapilot/clients/altimate/client.py +85 -0
- datapilot/clients/altimate/utils.py +75 -0
- datapilot/config/__init__.py +0 -0
- datapilot/config/config.py +16 -0
- datapilot/config/utils.py +32 -0
- datapilot/core/__init__.py +0 -0
- datapilot/core/insights/__init__.py +2 -0
- datapilot/core/insights/base/__init__.py +0 -0
- datapilot/core/insights/base/insight.py +34 -0
- datapilot/core/insights/report.py +16 -0
- datapilot/core/insights/schema.py +24 -0
- datapilot/core/insights/sql/__init__.py +0 -0
- datapilot/core/insights/sql/base/__init__.py +0 -0
- datapilot/core/insights/sql/base/insight.py +18 -0
- datapilot/core/insights/sql/runtime/__init__.py +0 -0
- datapilot/core/insights/sql/static/__init__.py +0 -0
- datapilot/core/insights/utils.py +20 -0
- datapilot/core/platforms/__init__.py +0 -0
- datapilot/core/platforms/dbt/__init__.py +0 -0
- datapilot/core/platforms/dbt/cli/__init__.py +0 -0
- datapilot/core/platforms/dbt/cli/cli.py +112 -0
- datapilot/core/platforms/dbt/constants.py +34 -0
- datapilot/core/platforms/dbt/exceptions.py +6 -0
- datapilot/core/platforms/dbt/executor.py +157 -0
- datapilot/core/platforms/dbt/factory.py +22 -0
- datapilot/core/platforms/dbt/formatting.py +45 -0
- datapilot/core/platforms/dbt/hooks/__init__.py +0 -0
- datapilot/core/platforms/dbt/hooks/executor_hook.py +86 -0
- datapilot/core/platforms/dbt/insights/__init__.py +115 -0
- datapilot/core/platforms/dbt/insights/base.py +133 -0
- datapilot/core/platforms/dbt/insights/checks/__init__.py +0 -0
- datapilot/core/platforms/dbt/insights/checks/base.py +26 -0
- datapilot/core/platforms/dbt/insights/checks/check_column_desc_are_same.py +105 -0
- datapilot/core/platforms/dbt/insights/checks/check_column_name_contract.py +154 -0
- datapilot/core/platforms/dbt/insights/checks/check_macro_args_have_desc.py +75 -0
- datapilot/core/platforms/dbt/insights/checks/check_macro_has_desc.py +63 -0
- datapilot/core/platforms/dbt/insights/checks/check_model_has_all_columns.py +96 -0
- datapilot/core/platforms/dbt/insights/checks/check_model_has_labels_keys.py +112 -0
- datapilot/core/platforms/dbt/insights/checks/check_model_has_meta_keys.py +108 -0
- datapilot/core/platforms/dbt/insights/checks/check_model_has_properties_file.py +64 -0
- datapilot/core/platforms/dbt/insights/checks/check_model_has_tests_by_group.py +118 -0
- datapilot/core/platforms/dbt/insights/checks/check_model_has_tests_by_name.py +114 -0
- datapilot/core/platforms/dbt/insights/checks/check_model_has_tests_by_type.py +119 -0
- datapilot/core/platforms/dbt/insights/checks/check_model_materialization_by_childs.py +129 -0
- datapilot/core/platforms/dbt/insights/checks/check_model_name_contract.py +132 -0
- datapilot/core/platforms/dbt/insights/checks/check_model_parents_and_childs.py +135 -0
- datapilot/core/platforms/dbt/insights/checks/check_model_parents_database.py +109 -0
- datapilot/core/platforms/dbt/insights/checks/check_model_parents_schema.py +109 -0
- datapilot/core/platforms/dbt/insights/checks/check_model_tags.py +87 -0
- datapilot/core/platforms/dbt/insights/checks/check_source_childs.py +97 -0
- datapilot/core/platforms/dbt/insights/checks/check_source_columns_have_desc.py +96 -0
- datapilot/core/platforms/dbt/insights/checks/check_source_has_all_columns.py +103 -0
- datapilot/core/platforms/dbt/insights/checks/check_source_has_freshness.py +94 -0
- datapilot/core/platforms/dbt/insights/checks/check_source_has_labels_keys.py +110 -0
- datapilot/core/platforms/dbt/insights/checks/check_source_has_loader.py +62 -0
- datapilot/core/platforms/dbt/insights/checks/check_source_has_meta_keys.py +117 -0
- datapilot/core/platforms/dbt/insights/checks/check_source_has_tests.py +82 -0
- datapilot/core/platforms/dbt/insights/checks/check_source_has_tests_by_group.py +117 -0
- datapilot/core/platforms/dbt/insights/checks/check_source_has_tests_by_name.py +113 -0
- datapilot/core/platforms/dbt/insights/checks/check_source_has_tests_by_type.py +119 -0
- datapilot/core/platforms/dbt/insights/checks/check_source_table_has_description.py +62 -0
- datapilot/core/platforms/dbt/insights/checks/check_source_tags.py +76 -0
- datapilot/core/platforms/dbt/insights/dbt_test/__init__.py +0 -0
- datapilot/core/platforms/dbt/insights/dbt_test/base.py +23 -0
- datapilot/core/platforms/dbt/insights/dbt_test/missing_primary_key_tests.py +130 -0
- datapilot/core/platforms/dbt/insights/dbt_test/test_coverage.py +118 -0
- datapilot/core/platforms/dbt/insights/governance/__init__.py +0 -0
- datapilot/core/platforms/dbt/insights/governance/base.py +23 -0
- datapilot/core/platforms/dbt/insights/governance/documentation_on_stale_columns.py +130 -0
- datapilot/core/platforms/dbt/insights/governance/exposures_dependent_on_private_models.py +90 -0
- datapilot/core/platforms/dbt/insights/governance/public_models_without_contracts.py +89 -0
- datapilot/core/platforms/dbt/insights/governance/undocumented_columns.py +148 -0
- datapilot/core/platforms/dbt/insights/governance/undocumented_public_models.py +110 -0
- datapilot/core/platforms/dbt/insights/modelling/README.md +15 -0
- datapilot/core/platforms/dbt/insights/modelling/__init__.py +0 -0
- datapilot/core/platforms/dbt/insights/modelling/base.py +31 -0
- datapilot/core/platforms/dbt/insights/modelling/direct_join_to_source.py +125 -0
- datapilot/core/platforms/dbt/insights/modelling/downstream_models_dependent_on_source.py +113 -0
- datapilot/core/platforms/dbt/insights/modelling/duplicate_sources.py +85 -0
- datapilot/core/platforms/dbt/insights/modelling/hard_coded_references.py +80 -0
- datapilot/core/platforms/dbt/insights/modelling/joining_of_upstream_concepts.py +79 -0
- datapilot/core/platforms/dbt/insights/modelling/model_fanout.py +126 -0
- datapilot/core/platforms/dbt/insights/modelling/multiple_sources_joined.py +83 -0
- datapilot/core/platforms/dbt/insights/modelling/root_model.py +82 -0
- datapilot/core/platforms/dbt/insights/modelling/source_fanout.py +102 -0
- datapilot/core/platforms/dbt/insights/modelling/staging_model_dependent_on_downstream_models.py +103 -0
- datapilot/core/platforms/dbt/insights/modelling/staging_model_dependent_on_staging_models.py +89 -0
- datapilot/core/platforms/dbt/insights/modelling/unused_sources.py +59 -0
- datapilot/core/platforms/dbt/insights/performance/__init__.py +0 -0
- datapilot/core/platforms/dbt/insights/performance/base.py +26 -0
- datapilot/core/platforms/dbt/insights/performance/chain_view_linking.py +92 -0
- datapilot/core/platforms/dbt/insights/performance/exposure_parent_materializations.py +104 -0
- datapilot/core/platforms/dbt/insights/schema.py +72 -0
- datapilot/core/platforms/dbt/insights/structure/__init__.py +0 -0
- datapilot/core/platforms/dbt/insights/structure/base.py +33 -0
- datapilot/core/platforms/dbt/insights/structure/model_directories_structure.py +92 -0
- datapilot/core/platforms/dbt/insights/structure/model_naming_conventions.py +97 -0
- datapilot/core/platforms/dbt/insights/structure/source_directories_structure.py +80 -0
- datapilot/core/platforms/dbt/insights/structure/test_directory_structure.py +74 -0
- datapilot/core/platforms/dbt/insights/utils.py +9 -0
- datapilot/core/platforms/dbt/schemas/__init__.py +0 -0
- datapilot/core/platforms/dbt/schemas/catalog.py +73 -0
- datapilot/core/platforms/dbt/schemas/manifest.py +462 -0
- datapilot/core/platforms/dbt/utils.py +525 -0
- datapilot/core/platforms/dbt/wrappers/__init__.py +0 -0
- datapilot/core/platforms/dbt/wrappers/catalog/__init__.py +0 -0
- datapilot/core/platforms/dbt/wrappers/catalog/v1/__init__.py +0 -0
- datapilot/core/platforms/dbt/wrappers/catalog/v1/wrapper.py +18 -0
- datapilot/core/platforms/dbt/wrappers/catalog/wrapper.py +9 -0
- datapilot/core/platforms/dbt/wrappers/manifest/__init__.py +0 -0
- datapilot/core/platforms/dbt/wrappers/manifest/v11/__init__.py +0 -0
- datapilot/core/platforms/dbt/wrappers/manifest/v11/schemas.py +47 -0
- datapilot/core/platforms/dbt/wrappers/manifest/v11/wrapper.py +396 -0
- datapilot/core/platforms/dbt/wrappers/manifest/wrapper.py +35 -0
- datapilot/core/platforms/dbt/wrappers/run_results/__init__.py +0 -0
- datapilot/core/platforms/dbt/wrappers/run_results/run_results.py +39 -0
- datapilot/exceptions/__init__.py +0 -0
- datapilot/exceptions/exceptions.py +10 -0
- datapilot/schemas/__init__.py +0 -0
- datapilot/schemas/constants.py +5 -0
- datapilot/schemas/nodes.py +19 -0
- datapilot/schemas/sql.py +10 -0
- datapilot/utils/__init__.py +0 -0
- datapilot/utils/formatting/__init__.py +0 -0
- datapilot/utils/formatting/utils.py +59 -0
- datapilot/utils/utils.py +317 -0
@@ -0,0 +1,396 @@
|
|
1
|
+
from typing import Dict
|
2
|
+
from typing import Set
|
3
|
+
|
4
|
+
from dbt_artifacts_parser.parsers.manifest.manifest_v11 import GenericTestNode
|
5
|
+
from dbt_artifacts_parser.parsers.manifest.manifest_v11 import ManifestV11
|
6
|
+
from dbt_artifacts_parser.parsers.manifest.manifest_v11 import SingularTestNode
|
7
|
+
|
8
|
+
from datapilot.core.platforms.dbt.constants import GENERIC
|
9
|
+
from datapilot.core.platforms.dbt.constants import OTHER_TEST_NODE
|
10
|
+
from datapilot.core.platforms.dbt.constants import SEED
|
11
|
+
from datapilot.core.platforms.dbt.constants import SINGULAR
|
12
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateDBTContract
|
13
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateDependsOn
|
14
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateExposureType
|
15
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateExternalTable
|
16
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateFileHash
|
17
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateFreshnessThreshold
|
18
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateManifestColumnInfo
|
19
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateManifestExposureNode
|
20
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateManifestMacroNode
|
21
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateManifestNode
|
22
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateManifestSourceNode
|
23
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateManifestTestNode
|
24
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateMaturityEnum
|
25
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateNodeConfig
|
26
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateOwner
|
27
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateQuoting
|
28
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateRefArgs
|
29
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateResourceType
|
30
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateSeedConfig
|
31
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateSeedNode
|
32
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateSourceConfig
|
33
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateTestConfig
|
34
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateTestMetadata
|
35
|
+
from datapilot.core.platforms.dbt.wrappers.manifest.v11.schemas import TEST_TYPE_TO_NODE_MAP
|
36
|
+
from datapilot.core.platforms.dbt.wrappers.manifest.v11.schemas import ExposureNode
|
37
|
+
from datapilot.core.platforms.dbt.wrappers.manifest.v11.schemas import MacroNode
|
38
|
+
from datapilot.core.platforms.dbt.wrappers.manifest.v11.schemas import ManifestNode
|
39
|
+
from datapilot.core.platforms.dbt.wrappers.manifest.v11.schemas import SeedNodeMap
|
40
|
+
from datapilot.core.platforms.dbt.wrappers.manifest.v11.schemas import SourceNode
|
41
|
+
from datapilot.core.platforms.dbt.wrappers.manifest.v11.schemas import TestNode
|
42
|
+
from datapilot.core.platforms.dbt.wrappers.manifest.wrapper import BaseManifestWrapper
|
43
|
+
|
44
|
+
|
45
|
+
class ManifestV11Wrapper(BaseManifestWrapper):
|
46
|
+
def __init__(self, manifest: ManifestV11):
|
47
|
+
self.manifest = manifest
|
48
|
+
|
49
|
+
def _get_node(self, node: ManifestNode) -> AltimateManifestNode:
|
50
|
+
(
|
51
|
+
sources,
|
52
|
+
metrics,
|
53
|
+
compiled_path,
|
54
|
+
compiled,
|
55
|
+
compiled_code,
|
56
|
+
depends_on_nodes,
|
57
|
+
depends_on_macros,
|
58
|
+
raw_code,
|
59
|
+
language,
|
60
|
+
contract,
|
61
|
+
) = ([], [], None, None, None, None, None, "", "", None)
|
62
|
+
if node.resource_type.value != SEED:
|
63
|
+
sources = node.sources
|
64
|
+
metrics = node.metrics
|
65
|
+
depends_on_nodes = node.depends_on.nodes if node.depends_on else None
|
66
|
+
depends_on_macros = node.depends_on.macros if node.depends_on else None
|
67
|
+
compiled_path = node.compiled_path
|
68
|
+
compiled = node.compiled
|
69
|
+
raw_code = node.raw_code
|
70
|
+
language = node.language
|
71
|
+
contract = AltimateDBTContract(**node.contract.__dict__) if node.contract else None
|
72
|
+
|
73
|
+
return AltimateManifestNode(
|
74
|
+
database=node.database,
|
75
|
+
schema_name=node.schema_,
|
76
|
+
name=node.name,
|
77
|
+
resource_type=AltimateResourceType(node.resource_type.value),
|
78
|
+
package_name=node.package_name,
|
79
|
+
path=node.path,
|
80
|
+
description=node.description,
|
81
|
+
original_file_path=node.original_file_path,
|
82
|
+
unique_id=node.unique_id,
|
83
|
+
fqn=node.fqn,
|
84
|
+
alias=node.alias,
|
85
|
+
raw_code=raw_code,
|
86
|
+
language=language,
|
87
|
+
config=AltimateNodeConfig(**node.config.__dict__) if node.config else None,
|
88
|
+
checksum=AltimateFileHash(
|
89
|
+
name=node.checksum.name if node.checksum else None,
|
90
|
+
checksum=node.checksum.checksum if node.checksum else None,
|
91
|
+
),
|
92
|
+
columns={
|
93
|
+
name: AltimateManifestColumnInfo(
|
94
|
+
name=column.name,
|
95
|
+
description=column.description,
|
96
|
+
meta=column.meta,
|
97
|
+
data_type=column.data_type,
|
98
|
+
quote=column.quote,
|
99
|
+
tags=column.tags,
|
100
|
+
)
|
101
|
+
for name, column in node.columns.items()
|
102
|
+
},
|
103
|
+
relation_name=node.relation_name,
|
104
|
+
sources=sources,
|
105
|
+
metrics=metrics,
|
106
|
+
depends_on=AltimateDependsOn(
|
107
|
+
nodes=depends_on_nodes,
|
108
|
+
macros=depends_on_macros,
|
109
|
+
),
|
110
|
+
compiled_path=compiled_path,
|
111
|
+
compiled=compiled,
|
112
|
+
compiled_code=compiled_code,
|
113
|
+
contract=contract,
|
114
|
+
meta=node.meta,
|
115
|
+
patch_path=node.patch_path,
|
116
|
+
)
|
117
|
+
|
118
|
+
def _get_source(self, source: SourceNode) -> AltimateManifestSourceNode:
|
119
|
+
return AltimateManifestSourceNode(
|
120
|
+
database=source.database,
|
121
|
+
resource_type=AltimateResourceType(source.resource_type.value),
|
122
|
+
schema_name=source.schema_,
|
123
|
+
name=source.name,
|
124
|
+
package_name=source.package_name,
|
125
|
+
path=source.path,
|
126
|
+
original_file_path=source.original_file_path,
|
127
|
+
unique_id=source.unique_id,
|
128
|
+
fqn=source.fqn,
|
129
|
+
source_name=source.source_name,
|
130
|
+
source_description=source.source_description,
|
131
|
+
loader=source.loader,
|
132
|
+
identifier=source.identifier,
|
133
|
+
quoting=AltimateQuoting(**source.quoting.dict()) if source.quoting else None,
|
134
|
+
loaded_at_field=source.loaded_at_field,
|
135
|
+
freshness=AltimateFreshnessThreshold(**source.freshness.dict()) if source.freshness else None,
|
136
|
+
external=AltimateExternalTable(**source.external.dict()) if source.external else None,
|
137
|
+
description=source.description,
|
138
|
+
columns={
|
139
|
+
name: AltimateManifestColumnInfo(
|
140
|
+
name=column.name,
|
141
|
+
description=column.description,
|
142
|
+
meta=column.meta,
|
143
|
+
data_type=column.data_type,
|
144
|
+
quote=column.quote,
|
145
|
+
tags=column.tags,
|
146
|
+
)
|
147
|
+
for name, column in source.columns.items()
|
148
|
+
},
|
149
|
+
meta=source.meta,
|
150
|
+
relation_name=source.relation_name,
|
151
|
+
source_meta=source.source_meta,
|
152
|
+
tags=source.tags,
|
153
|
+
config=AltimateSourceConfig(**source.config.dict()) if source.config else None,
|
154
|
+
patch_path=source.patch_path,
|
155
|
+
unrendered_config=source.unrendered_config,
|
156
|
+
created_at=source.created_at,
|
157
|
+
)
|
158
|
+
|
159
|
+
def _get_macro(self, macro: MacroNode) -> AltimateManifestMacroNode:
|
160
|
+
return AltimateManifestMacroNode(
|
161
|
+
name=macro.name,
|
162
|
+
resource_type=AltimateResourceType(macro.resource_type.value),
|
163
|
+
package_name=macro.package_name,
|
164
|
+
path=macro.path,
|
165
|
+
original_file_path=macro.original_file_path,
|
166
|
+
unique_id=macro.unique_id,
|
167
|
+
macro_sql=macro.macro_sql,
|
168
|
+
depends_on=(
|
169
|
+
AltimateDependsOn(
|
170
|
+
macros=macro.depends_on.macros,
|
171
|
+
)
|
172
|
+
if macro.depends_on
|
173
|
+
else None
|
174
|
+
),
|
175
|
+
description=macro.description,
|
176
|
+
meta=macro.meta,
|
177
|
+
docs=macro.docs,
|
178
|
+
patch_path=macro.patch_path,
|
179
|
+
arguments=[AltimateRefArgs(**arg.dict()) for arg in macro.arguments] if macro.arguments else None,
|
180
|
+
created_at=macro.created_at,
|
181
|
+
supported_languages=macro.supported_languages,
|
182
|
+
)
|
183
|
+
|
184
|
+
def _get_exposure(self, exposure: ExposureNode) -> AltimateManifestExposureNode:
|
185
|
+
return AltimateManifestExposureNode(
|
186
|
+
name=exposure.name,
|
187
|
+
resource_type=AltimateResourceType(exposure.resource_type.value),
|
188
|
+
package_name=exposure.package_name,
|
189
|
+
path=exposure.path,
|
190
|
+
original_file_path=exposure.original_file_path,
|
191
|
+
unique_id=exposure.unique_id,
|
192
|
+
fqn=exposure.fqn,
|
193
|
+
type=AltimateExposureType(exposure.type.value) if exposure.type else None,
|
194
|
+
owner=AltimateOwner(**exposure.owner.dict()) if exposure.owner else None,
|
195
|
+
description=exposure.description,
|
196
|
+
label=exposure.label,
|
197
|
+
maturity=AltimateMaturityEnum(exposure.maturity.value) if exposure.maturity else None,
|
198
|
+
meta=exposure.meta,
|
199
|
+
tags=exposure.tags,
|
200
|
+
config=AltimateSourceConfig(**exposure.config.dict()) if exposure.config else None,
|
201
|
+
unrendered_config=exposure.unrendered_config,
|
202
|
+
url=exposure.url,
|
203
|
+
depends_on=AltimateDependsOn(
|
204
|
+
nodes=exposure.depends_on.nodes,
|
205
|
+
macros=exposure.depends_on.macros,
|
206
|
+
)
|
207
|
+
if exposure.depends_on
|
208
|
+
else None,
|
209
|
+
refs=[AltimateRefArgs(**ref.dict()) for ref in exposure.refs] if exposure.refs else None,
|
210
|
+
sources=exposure.sources,
|
211
|
+
metrics=exposure.metrics,
|
212
|
+
created_at=exposure.created_at,
|
213
|
+
)
|
214
|
+
|
215
|
+
def _get_tests(self, test: TestNode) -> AltimateManifestTestNode:
|
216
|
+
test_metadata = None
|
217
|
+
if isinstance(test, GenericTestNode):
|
218
|
+
test_type = GENERIC
|
219
|
+
test_metadata = AltimateTestMetadata(**test.test_metadata.dict()) if test.test_metadata else None
|
220
|
+
elif isinstance(test, SingularTestNode):
|
221
|
+
test_type = SINGULAR
|
222
|
+
else:
|
223
|
+
test_type = OTHER_TEST_NODE
|
224
|
+
return AltimateManifestTestNode(
|
225
|
+
test_metadata=test_metadata,
|
226
|
+
test_type=test_type,
|
227
|
+
name=test.name,
|
228
|
+
resource_type=AltimateResourceType(test.resource_type.value),
|
229
|
+
package_name=test.package_name,
|
230
|
+
path=test.path,
|
231
|
+
original_file_path=test.original_file_path,
|
232
|
+
unique_id=test.unique_id,
|
233
|
+
fqn=test.fqn,
|
234
|
+
alias=test.alias,
|
235
|
+
checksum=AltimateFileHash(
|
236
|
+
name=test.checksum.name,
|
237
|
+
checksum=test.checksum.checksum,
|
238
|
+
)
|
239
|
+
if test.checksum
|
240
|
+
else None,
|
241
|
+
config=AltimateTestConfig(**test.config.dict()) if test.config else None,
|
242
|
+
description=test.description,
|
243
|
+
tags=test.tags,
|
244
|
+
columns={
|
245
|
+
name: AltimateManifestColumnInfo(
|
246
|
+
name=column.name,
|
247
|
+
description=column.description,
|
248
|
+
meta=column.meta,
|
249
|
+
data_type=column.data_type,
|
250
|
+
quote=column.quote,
|
251
|
+
tags=column.tags,
|
252
|
+
)
|
253
|
+
for name, column in test.columns.items()
|
254
|
+
}
|
255
|
+
if test.columns
|
256
|
+
else None,
|
257
|
+
meta=test.meta,
|
258
|
+
relation_name=test.relation_name,
|
259
|
+
group=test.group,
|
260
|
+
raw_code=test.raw_code,
|
261
|
+
language=test.language,
|
262
|
+
refs=[AltimateRefArgs(**ref.dict()) for ref in test.refs] if test.refs else None,
|
263
|
+
sources=test.sources,
|
264
|
+
metrics=test.metrics,
|
265
|
+
depends_on=AltimateDependsOn(
|
266
|
+
nodes=test.depends_on.nodes,
|
267
|
+
macros=test.depends_on.macros,
|
268
|
+
)
|
269
|
+
if test.depends_on
|
270
|
+
else None,
|
271
|
+
compiled_path=test.compiled_path,
|
272
|
+
compiled=test.compiled,
|
273
|
+
compiled_code=test.compiled_code,
|
274
|
+
)
|
275
|
+
|
276
|
+
def _get_seed(self, seed: SeedNodeMap) -> AltimateSeedNode:
|
277
|
+
return AltimateSeedNode(
|
278
|
+
database=seed.database,
|
279
|
+
schema_name=seed.schema_,
|
280
|
+
name=seed.name,
|
281
|
+
resource_type=AltimateResourceType(seed.resource_type.value),
|
282
|
+
package_name=seed.package_name,
|
283
|
+
path=seed.path,
|
284
|
+
original_file_path=seed.original_file_path,
|
285
|
+
unique_id=seed.unique_id,
|
286
|
+
fqn=seed.fqn,
|
287
|
+
alias=seed.alias,
|
288
|
+
checksum=AltimateFileHash(
|
289
|
+
name=seed.checksum.name,
|
290
|
+
checksum=seed.checksum.checksum,
|
291
|
+
)
|
292
|
+
if seed.checksum
|
293
|
+
else None,
|
294
|
+
config=AltimateSeedConfig(**seed.config.dict()) if seed.config else None,
|
295
|
+
description=seed.description,
|
296
|
+
tags=seed.tags,
|
297
|
+
columns={
|
298
|
+
name: AltimateManifestColumnInfo(
|
299
|
+
name=column.name,
|
300
|
+
description=column.description,
|
301
|
+
meta=column.meta,
|
302
|
+
data_type=column.data_type,
|
303
|
+
quote=column.quote,
|
304
|
+
tags=column.tags,
|
305
|
+
)
|
306
|
+
for name, column in seed.columns.items()
|
307
|
+
}
|
308
|
+
if seed.columns
|
309
|
+
else None,
|
310
|
+
meta=seed.meta,
|
311
|
+
group=seed.group,
|
312
|
+
docs=seed.docs.dict() if seed.docs else None,
|
313
|
+
patch_path=seed.patch_path,
|
314
|
+
build_path=seed.build_path,
|
315
|
+
deferred=seed.deferred,
|
316
|
+
unrendered_config=seed.unrendered_config,
|
317
|
+
created_at=seed.created_at,
|
318
|
+
config_call_dict=seed.config_call_dict,
|
319
|
+
)
|
320
|
+
|
321
|
+
def get_nodes(
|
322
|
+
self,
|
323
|
+
) -> Dict[str, AltimateManifestNode]:
|
324
|
+
nodes = {}
|
325
|
+
for node in self.manifest.nodes.values():
|
326
|
+
if (
|
327
|
+
node.resource_type.value
|
328
|
+
in [
|
329
|
+
AltimateResourceType.seed.value,
|
330
|
+
AltimateResourceType.test.value,
|
331
|
+
]
|
332
|
+
or node.package_name != self.get_package()
|
333
|
+
):
|
334
|
+
continue
|
335
|
+
nodes[node.unique_id] = self._get_node(node)
|
336
|
+
return nodes
|
337
|
+
|
338
|
+
def get_package(self) -> str:
|
339
|
+
return self.manifest.metadata.project_name
|
340
|
+
|
341
|
+
def get_sources(self) -> Dict[str, AltimateManifestSourceNode]:
|
342
|
+
sources = {}
|
343
|
+
for source in self.manifest.sources.values():
|
344
|
+
sources[source.unique_id] = self._get_source(source)
|
345
|
+
return sources
|
346
|
+
|
347
|
+
def get_macros(self) -> Dict[str, AltimateManifestMacroNode]:
|
348
|
+
macros = {}
|
349
|
+
for macro in self.manifest.macros.values():
|
350
|
+
if macro.resource_type.value == AltimateResourceType.macro.value and macro.package_name == self.get_package():
|
351
|
+
macros[macro.unique_id] = self._get_macro(macro)
|
352
|
+
return macros
|
353
|
+
|
354
|
+
def get_exposures(self) -> Dict[str, AltimateManifestExposureNode]:
|
355
|
+
exposures = {}
|
356
|
+
for exposure in self.manifest.exposures.values():
|
357
|
+
exposures[exposure.unique_id] = self._get_exposure(exposure)
|
358
|
+
return exposures
|
359
|
+
|
360
|
+
def get_tests(self, type=None) -> Dict[str, AltimateManifestTestNode]:
|
361
|
+
tests = {}
|
362
|
+
# Initialize types_union with TestNode
|
363
|
+
types = [GenericTestNode, SingularTestNode]
|
364
|
+
|
365
|
+
# Add other types to the union if provided
|
366
|
+
if type:
|
367
|
+
types = TEST_TYPE_TO_NODE_MAP.get(type)
|
368
|
+
|
369
|
+
for node in self.manifest.nodes.values():
|
370
|
+
# Check if the node is a test and of the correct type
|
371
|
+
if node.resource_type.value == AltimateResourceType.test.value:
|
372
|
+
if any(isinstance(node, t) for t in types):
|
373
|
+
tests[node.unique_id] = self._get_tests(node)
|
374
|
+
return tests
|
375
|
+
|
376
|
+
def get_seeds(self) -> Dict[str, AltimateSeedNode]:
|
377
|
+
seeds = {}
|
378
|
+
for seed in self.manifest.nodes.values():
|
379
|
+
if seed.resource_type.value == AltimateResourceType.seed.value:
|
380
|
+
seeds[seed.unique_id] = self._get_seed(seed)
|
381
|
+
return seeds
|
382
|
+
|
383
|
+
def parent_to_child_map(self, nodes: Dict[str, AltimateManifestNode]) -> Dict[str, Set[str]]:
|
384
|
+
"""
|
385
|
+
Current manifest contains information about parents
|
386
|
+
THis gives an information of node to childre
|
387
|
+
:param nodes: A dictionary of nodes in a manifest.
|
388
|
+
:return: A dictionary of all the children of a node.
|
389
|
+
"""
|
390
|
+
children_map = {}
|
391
|
+
for node_id, node in nodes.items():
|
392
|
+
if node_id not in children_map:
|
393
|
+
children_map[node_id] = set()
|
394
|
+
for parent in node.depends_on.nodes or []:
|
395
|
+
children_map.setdefault(parent, set()).add(node_id)
|
396
|
+
return children_map
|
@@ -0,0 +1,35 @@
|
|
1
|
+
from abc import ABC
|
2
|
+
from abc import abstractmethod
|
3
|
+
from typing import Dict
|
4
|
+
from typing import Set
|
5
|
+
|
6
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateManifestExposureNode
|
7
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateManifestNode
|
8
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateManifestSourceNode
|
9
|
+
from datapilot.core.platforms.dbt.schemas.manifest import AltimateManifestTestNode
|
10
|
+
|
11
|
+
|
12
|
+
class BaseManifestWrapper(ABC):
|
13
|
+
@abstractmethod
|
14
|
+
def get_nodes(self) -> Dict[str, AltimateManifestNode]:
|
15
|
+
pass
|
16
|
+
|
17
|
+
@abstractmethod
|
18
|
+
def get_package(self) -> str:
|
19
|
+
pass
|
20
|
+
|
21
|
+
@abstractmethod
|
22
|
+
def get_sources(self) -> Dict[str, AltimateManifestSourceNode]:
|
23
|
+
pass
|
24
|
+
|
25
|
+
@abstractmethod
|
26
|
+
def get_exposures(self) -> Dict[str, AltimateManifestExposureNode]:
|
27
|
+
pass
|
28
|
+
|
29
|
+
@abstractmethod
|
30
|
+
def parent_to_child_map(self, nodes: Dict[str, AltimateManifestNode]) -> Dict[str, Set[str]]:
|
31
|
+
pass
|
32
|
+
|
33
|
+
@abstractmethod
|
34
|
+
def get_tests(self, types=None) -> Dict[str, AltimateManifestTestNode]:
|
35
|
+
pass
|
File without changes
|
@@ -0,0 +1,39 @@
|
|
1
|
+
from abc import ABC
|
2
|
+
from abc import abstractmethod
|
3
|
+
|
4
|
+
from dbt_artifacts_parser.parsers.run_results.run_results_v1 import RunResultsV1
|
5
|
+
from dbt_artifacts_parser.parsers.run_results.run_results_v2 import RunResultsV2
|
6
|
+
from dbt_artifacts_parser.parsers.run_results.run_results_v3 import RunResultsV3
|
7
|
+
from dbt_artifacts_parser.parsers.run_results.run_results_v4 import RunResultsV4
|
8
|
+
from dbt_artifacts_parser.parsers.run_results.run_results_v5 import RunResultsV5
|
9
|
+
|
10
|
+
|
11
|
+
class BaseRunResultsWrapper(ABC):
|
12
|
+
@abstractmethod
|
13
|
+
def get_run_results(self):
|
14
|
+
pass
|
15
|
+
|
16
|
+
|
17
|
+
class RunResultsV1Wrapper(BaseRunResultsWrapper):
|
18
|
+
def __init__(self, run_results: RunResultsV1):
|
19
|
+
self.run_results = run_results
|
20
|
+
|
21
|
+
|
22
|
+
class RunResultsV2Wrapper(BaseRunResultsWrapper):
|
23
|
+
def __init__(self, run_results: RunResultsV2):
|
24
|
+
self.run_results = run_results
|
25
|
+
|
26
|
+
|
27
|
+
class RunResultsV3Wrapper(BaseRunResultsWrapper):
|
28
|
+
def __init__(self, run_results: RunResultsV3):
|
29
|
+
self.run_results = run_results
|
30
|
+
|
31
|
+
|
32
|
+
class RunResultsV4Wrapper(BaseRunResultsWrapper):
|
33
|
+
def __init__(self, run_results: RunResultsV4):
|
34
|
+
self.run_results = run_results
|
35
|
+
|
36
|
+
|
37
|
+
class RunResultsV5Wrapper(BaseRunResultsWrapper):
|
38
|
+
def __init__(self, run_results: RunResultsV5):
|
39
|
+
self.run_results = run_results
|
File without changes
|
File without changes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
from pydantic import BaseModel
|
2
|
+
|
3
|
+
|
4
|
+
class ModelNode(BaseModel):
|
5
|
+
unique_id: str
|
6
|
+
name: str
|
7
|
+
resource_type: str
|
8
|
+
database: str
|
9
|
+
alias: str
|
10
|
+
table_schema: str
|
11
|
+
|
12
|
+
|
13
|
+
class SourceNode(BaseModel):
|
14
|
+
unique_id: str
|
15
|
+
name: str
|
16
|
+
resource_type: str
|
17
|
+
table: str = ""
|
18
|
+
database: str
|
19
|
+
table_schema: str
|
datapilot/schemas/sql.py
ADDED
File without changes
|
File without changes
|
@@ -0,0 +1,59 @@
|
|
1
|
+
from tabulate import tabulate
|
2
|
+
|
3
|
+
from datapilot.core.insights.schema import Severity
|
4
|
+
|
5
|
+
RED = "\033[91m"
|
6
|
+
YELLOW = "\033[93m"
|
7
|
+
BLUE = "\033[94m"
|
8
|
+
NO_COLOR = "\033[0m"
|
9
|
+
|
10
|
+
BOLD = "\033[1m"
|
11
|
+
UNDERLINE = "\033[4m"
|
12
|
+
ITALIC = "\033[3m"
|
13
|
+
|
14
|
+
|
15
|
+
def numbered_list(items):
|
16
|
+
return "\n".join(f"{i}. {item}" for i, item in enumerate(items, 1))
|
17
|
+
|
18
|
+
|
19
|
+
def get_severity_color(severity: Severity):
|
20
|
+
colors = {
|
21
|
+
Severity.ERROR: RED,
|
22
|
+
Severity.WARNING: YELLOW,
|
23
|
+
Severity.INFO: BLUE,
|
24
|
+
}
|
25
|
+
return colors.get(severity, NO_COLOR) # Default to no color
|
26
|
+
|
27
|
+
|
28
|
+
def reset_color(do_format=True):
|
29
|
+
return NO_COLOR if do_format else ""
|
30
|
+
|
31
|
+
|
32
|
+
def bold(text, do_format=True):
|
33
|
+
return f"{BOLD if do_format else ''}{text}{NO_COLOR if do_format else ''}"
|
34
|
+
|
35
|
+
|
36
|
+
def underline(text, do_format=True):
|
37
|
+
return f"{UNDERLINE if do_format else ''}{text}{NO_COLOR if do_format else ''}"
|
38
|
+
|
39
|
+
|
40
|
+
def italic(text, do_format=True):
|
41
|
+
return f"{ITALIC if do_format else ''}{text}{NO_COLOR if do_format else ''}"
|
42
|
+
|
43
|
+
|
44
|
+
def tabulate_data(data, headers, tablefmt="grid"):
|
45
|
+
return tabulate(
|
46
|
+
data,
|
47
|
+
headers=headers,
|
48
|
+
tablefmt=tablefmt,
|
49
|
+
maxcolwidths=[None, None, None, 60, 60, 60],
|
50
|
+
)
|
51
|
+
|
52
|
+
|
53
|
+
def color_text(text, color):
|
54
|
+
return f"{color}{text}{NO_COLOR}"
|
55
|
+
|
56
|
+
|
57
|
+
def color_based_on_severity(severity: Severity):
|
58
|
+
color = get_severity_color(severity)
|
59
|
+
return color_text(severity.value, color)
|