collate-dbt-artifacts-parser 0.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.
Files changed (67) hide show
  1. collate_dbt_artifacts_parser/__init__.py +21 -0
  2. collate_dbt_artifacts_parser/parser.py +390 -0
  3. collate_dbt_artifacts_parser/parsers/__init__.py +16 -0
  4. collate_dbt_artifacts_parser/parsers/base.py +26 -0
  5. collate_dbt_artifacts_parser/parsers/catalog/__init__.py +16 -0
  6. collate_dbt_artifacts_parser/parsers/catalog/catalog_cloud.py +85 -0
  7. collate_dbt_artifacts_parser/parsers/catalog/catalog_v1.py +85 -0
  8. collate_dbt_artifacts_parser/parsers/manifest/__init__.py +16 -0
  9. collate_dbt_artifacts_parser/parsers/manifest/manifest_cloud.py +4172 -0
  10. collate_dbt_artifacts_parser/parsers/manifest/manifest_v1.py +1548 -0
  11. collate_dbt_artifacts_parser/parsers/manifest/manifest_v10.py +1667 -0
  12. collate_dbt_artifacts_parser/parsers/manifest/manifest_v11.py +1449 -0
  13. collate_dbt_artifacts_parser/parsers/manifest/manifest_v12.py +4182 -0
  14. collate_dbt_artifacts_parser/parsers/manifest/manifest_v2.py +1553 -0
  15. collate_dbt_artifacts_parser/parsers/manifest/manifest_v3.py +1565 -0
  16. collate_dbt_artifacts_parser/parsers/manifest/manifest_v4.py +1748 -0
  17. collate_dbt_artifacts_parser/parsers/manifest/manifest_v5.py +1763 -0
  18. collate_dbt_artifacts_parser/parsers/manifest/manifest_v6.py +1799 -0
  19. collate_dbt_artifacts_parser/parsers/manifest/manifest_v7.py +1917 -0
  20. collate_dbt_artifacts_parser/parsers/manifest/manifest_v8.py +1258 -0
  21. collate_dbt_artifacts_parser/parsers/manifest/manifest_v9.py +1431 -0
  22. collate_dbt_artifacts_parser/parsers/run_results/__init__.py +16 -0
  23. collate_dbt_artifacts_parser/parsers/run_results/run_results_cloud.py +90 -0
  24. collate_dbt_artifacts_parser/parsers/run_results/run_results_v1.py +75 -0
  25. collate_dbt_artifacts_parser/parsers/run_results/run_results_v2.py +76 -0
  26. collate_dbt_artifacts_parser/parsers/run_results/run_results_v3.py +147 -0
  27. collate_dbt_artifacts_parser/parsers/run_results/run_results_v4.py +147 -0
  28. collate_dbt_artifacts_parser/parsers/run_results/run_results_v5.py +79 -0
  29. collate_dbt_artifacts_parser/parsers/run_results/run_results_v6.py +89 -0
  30. collate_dbt_artifacts_parser/parsers/sources/__init__.py +16 -0
  31. collate_dbt_artifacts_parser/parsers/sources/sources_cloud.py +107 -0
  32. collate_dbt_artifacts_parser/parsers/sources/sources_v1.py +88 -0
  33. collate_dbt_artifacts_parser/parsers/sources/sources_v2.py +100 -0
  34. collate_dbt_artifacts_parser/parsers/sources/sources_v3.py +107 -0
  35. collate_dbt_artifacts_parser/parsers/utils.py +67 -0
  36. collate_dbt_artifacts_parser/parsers/version_map.py +124 -0
  37. collate_dbt_artifacts_parser/resources/catalog/catalog_cloud.json +425 -0
  38. collate_dbt_artifacts_parser/resources/catalog/catalog_v1.json +425 -0
  39. collate_dbt_artifacts_parser/resources/manifest/manifest_cloud.json +22719 -0
  40. collate_dbt_artifacts_parser/resources/manifest/manifest_v1.json +5074 -0
  41. collate_dbt_artifacts_parser/resources/manifest/manifest_v10.json +5638 -0
  42. collate_dbt_artifacts_parser/resources/manifest/manifest_v11.json +6256 -0
  43. collate_dbt_artifacts_parser/resources/manifest/manifest_v12.json +22727 -0
  44. collate_dbt_artifacts_parser/resources/manifest/manifest_v2.json +5128 -0
  45. collate_dbt_artifacts_parser/resources/manifest/manifest_v3.json +5225 -0
  46. collate_dbt_artifacts_parser/resources/manifest/manifest_v4.json +5939 -0
  47. collate_dbt_artifacts_parser/resources/manifest/manifest_v5.json +5984 -0
  48. collate_dbt_artifacts_parser/resources/manifest/manifest_v6.json +6209 -0
  49. collate_dbt_artifacts_parser/resources/manifest/manifest_v7.json +6575 -0
  50. collate_dbt_artifacts_parser/resources/manifest/manifest_v8.json +4434 -0
  51. collate_dbt_artifacts_parser/resources/manifest/manifest_v9.json +4965 -0
  52. collate_dbt_artifacts_parser/resources/run-results/run-results_cloud.json +265 -0
  53. collate_dbt_artifacts_parser/resources/run-results/run-results_v1.json +183 -0
  54. collate_dbt_artifacts_parser/resources/run-results/run-results_v2.json +190 -0
  55. collate_dbt_artifacts_parser/resources/run-results/run-results_v3.json +381 -0
  56. collate_dbt_artifacts_parser/resources/run-results/run-results_v4.json +400 -0
  57. collate_dbt_artifacts_parser/resources/run-results/run-results_v5.json +229 -0
  58. collate_dbt_artifacts_parser/resources/run-results/run-results_v6.json +264 -0
  59. collate_dbt_artifacts_parser/resources/sources/sources_cloud.json +280 -0
  60. collate_dbt_artifacts_parser/resources/sources/sources_v1.json +212 -0
  61. collate_dbt_artifacts_parser/resources/sources/sources_v2.json +261 -0
  62. collate_dbt_artifacts_parser/resources/sources/sources_v3.json +280 -0
  63. collate_dbt_artifacts_parser/utils.py +27 -0
  64. collate_dbt_artifacts_parser-0.1.dist-info/METADATA +531 -0
  65. collate_dbt_artifacts_parser-0.1.dist-info/RECORD +67 -0
  66. collate_dbt_artifacts_parser-0.1.dist-info/WHEEL +4 -0
  67. collate_dbt_artifacts_parser-0.1.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,21 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with
4
+ # this work for additional information regarding copyright ownership.
5
+ # The ASF licenses this file to You under the Apache License, Version 2.0
6
+ # (the "License"); you may not use this file except in compliance with
7
+ # the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ """
18
+ A dbt artifacts parser in python
19
+ """
20
+
21
+ __version__ = "0.1"
@@ -0,0 +1,390 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with
4
+ # this work for additional information regarding copyright ownership.
5
+ # The ASF licenses this file to You under the Apache License, Version 2.0
6
+ # (the "License"); you may not use this file except in compliance with
7
+ # the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ from typing import Union
18
+
19
+ from pydantic import ValidationError
20
+
21
+ from collate_dbt_artifacts_parser.parsers.catalog.catalog_cloud import CatalogCLOUD
22
+ from collate_dbt_artifacts_parser.parsers.catalog.catalog_v1 import CatalogV1
23
+ from collate_dbt_artifacts_parser.parsers.manifest.manifest_cloud import ManifestCLOUD
24
+ from collate_dbt_artifacts_parser.parsers.manifest.manifest_v1 import ManifestV1
25
+ from collate_dbt_artifacts_parser.parsers.manifest.manifest_v2 import ManifestV2
26
+ from collate_dbt_artifacts_parser.parsers.manifest.manifest_v3 import ManifestV3
27
+ from collate_dbt_artifacts_parser.parsers.manifest.manifest_v4 import ManifestV4
28
+ from collate_dbt_artifacts_parser.parsers.manifest.manifest_v5 import ManifestV5
29
+ from collate_dbt_artifacts_parser.parsers.manifest.manifest_v6 import ManifestV6
30
+ from collate_dbt_artifacts_parser.parsers.manifest.manifest_v7 import ManifestV7
31
+ from collate_dbt_artifacts_parser.parsers.manifest.manifest_v8 import ManifestV8
32
+ from collate_dbt_artifacts_parser.parsers.manifest.manifest_v9 import ManifestV9
33
+ from collate_dbt_artifacts_parser.parsers.manifest.manifest_v10 import ManifestV10
34
+ from collate_dbt_artifacts_parser.parsers.manifest.manifest_v11 import ManifestV11
35
+ from collate_dbt_artifacts_parser.parsers.manifest.manifest_v12 import ManifestV12
36
+ from collate_dbt_artifacts_parser.parsers.run_results.run_results_cloud import (
37
+ RunResultsCLOUD,
38
+ )
39
+ from collate_dbt_artifacts_parser.parsers.run_results.run_results_v1 import RunResultsV1
40
+ from collate_dbt_artifacts_parser.parsers.run_results.run_results_v2 import RunResultsV2
41
+ from collate_dbt_artifacts_parser.parsers.run_results.run_results_v3 import RunResultsV3
42
+ from collate_dbt_artifacts_parser.parsers.run_results.run_results_v4 import RunResultsV4
43
+ from collate_dbt_artifacts_parser.parsers.run_results.run_results_v5 import RunResultsV5
44
+ from collate_dbt_artifacts_parser.parsers.run_results.run_results_v6 import RunResultsV6
45
+ from collate_dbt_artifacts_parser.parsers.sources.sources_cloud import SourcesCLOUD
46
+ from collate_dbt_artifacts_parser.parsers.sources.sources_v1 import SourcesV1
47
+ from collate_dbt_artifacts_parser.parsers.sources.sources_v2 import SourcesV2
48
+ from collate_dbt_artifacts_parser.parsers.sources.sources_v3 import SourcesV3
49
+ from collate_dbt_artifacts_parser.parsers.utils import get_dbt_schema_version
50
+ from collate_dbt_artifacts_parser.parsers.version_map import ArtifactTypes
51
+
52
+
53
+ #
54
+ # catalog
55
+ #
56
+ def parse_catalog(catalog: dict) -> Union[CatalogV1, CatalogCLOUD]:
57
+ """Parse catalog.json
58
+
59
+ Args:
60
+ catalog: dict of catalog.json
61
+
62
+ Returns:
63
+ Union[CatalogV1]
64
+ """
65
+ dbt_schema_version = get_dbt_schema_version(artifact_json=catalog)
66
+ if dbt_schema_version == ArtifactTypes.CATALOG_V1.value.dbt_schema_version:
67
+ try:
68
+ return CatalogV1(**catalog)
69
+ except ValidationError:
70
+ return CatalogCLOUD(**catalog)
71
+ raise ValueError("Not a catalog.json")
72
+
73
+
74
+ def parse_catalog_v1(catalog: dict) -> Union[CatalogV1, CatalogCLOUD]:
75
+ """Parse catalog.json v1"""
76
+ dbt_schema_version = get_dbt_schema_version(artifact_json=catalog)
77
+ if dbt_schema_version == ArtifactTypes.CATALOG_V1.value.dbt_schema_version:
78
+ try:
79
+ return CatalogV1(**catalog)
80
+ except ValidationError:
81
+ return CatalogCLOUD(**catalog)
82
+ raise ValueError("Not a catalog.json v1")
83
+
84
+
85
+ #
86
+ # manifest
87
+ #
88
+ def parse_manifest(
89
+ manifest: dict,
90
+ ) -> Union[
91
+ ManifestV1,
92
+ ManifestV2,
93
+ ManifestV3,
94
+ ManifestV4,
95
+ ManifestV5,
96
+ ManifestV6,
97
+ ManifestV7,
98
+ ManifestV8,
99
+ ManifestV9,
100
+ ManifestV10,
101
+ ManifestV11,
102
+ ManifestV12,
103
+ ManifestCLOUD,
104
+ ]:
105
+ """Parse manifest.json
106
+
107
+ Args:
108
+ manifest: A dict of manifest.json
109
+
110
+ Returns:
111
+ Union[
112
+ ManifestV1, ManifestV2, ManifestV3, ManifestV4, ManifestV5,
113
+ ManifestV6, ManifestV7, ManifestV8, ManifestV9, ManifestV10,
114
+ ManifestV11, ManifestV12,
115
+ ]
116
+ """
117
+ dbt_schema_version = get_dbt_schema_version(artifact_json=manifest)
118
+ if dbt_schema_version == ArtifactTypes.MANIFEST_V1.value.dbt_schema_version:
119
+ return ManifestV1(**manifest)
120
+ elif dbt_schema_version == ArtifactTypes.MANIFEST_V2.value.dbt_schema_version:
121
+ return ManifestV2(**manifest)
122
+ elif dbt_schema_version == ArtifactTypes.MANIFEST_V3.value.dbt_schema_version:
123
+ return ManifestV3(**manifest)
124
+ elif dbt_schema_version == ArtifactTypes.MANIFEST_V4.value.dbt_schema_version:
125
+ return ManifestV4(**manifest)
126
+ elif dbt_schema_version == ArtifactTypes.MANIFEST_V5.value.dbt_schema_version:
127
+ return ManifestV5(**manifest)
128
+ elif dbt_schema_version == ArtifactTypes.MANIFEST_V6.value.dbt_schema_version:
129
+ return ManifestV6(**manifest)
130
+ elif dbt_schema_version == ArtifactTypes.MANIFEST_V7.value.dbt_schema_version:
131
+ return ManifestV7(**manifest)
132
+ elif dbt_schema_version == ArtifactTypes.MANIFEST_V8.value.dbt_schema_version:
133
+ return ManifestV8(**manifest)
134
+ elif dbt_schema_version == ArtifactTypes.MANIFEST_V9.value.dbt_schema_version:
135
+ return ManifestV9(**manifest)
136
+ elif dbt_schema_version == ArtifactTypes.MANIFEST_V10.value.dbt_schema_version:
137
+ return ManifestV10(**manifest)
138
+ elif dbt_schema_version == ArtifactTypes.MANIFEST_V11.value.dbt_schema_version:
139
+ return ManifestV11(**manifest)
140
+ elif dbt_schema_version == ArtifactTypes.MANIFEST_V12.value.dbt_schema_version:
141
+ try:
142
+ return ManifestV12(**manifest)
143
+ except ValidationError:
144
+ return ManifestCLOUD(**manifest)
145
+ raise ValueError("Not a manifest.json")
146
+
147
+
148
+ def parse_manifest_v1(manifest: dict) -> ManifestV1:
149
+ """Parse manifest.json ver.1"""
150
+ dbt_schema_version = get_dbt_schema_version(artifact_json=manifest)
151
+ if dbt_schema_version == ArtifactTypes.MANIFEST_V1.value.dbt_schema_version:
152
+ return ManifestV1(**manifest)
153
+ raise ValueError("Not a manifest.json v1")
154
+
155
+
156
+ def parse_manifest_v2(manifest: dict) -> ManifestV2:
157
+ """Parse manifest.json ver.2"""
158
+ dbt_schema_version = get_dbt_schema_version(artifact_json=manifest)
159
+ if dbt_schema_version == ArtifactTypes.MANIFEST_V2.value.dbt_schema_version:
160
+ return ManifestV2(**manifest)
161
+ raise ValueError("Not a manifest.json v2")
162
+
163
+
164
+ def parse_manifest_v3(manifest: dict) -> ManifestV3:
165
+ """Parse manifest.json ver.3"""
166
+ dbt_schema_version = get_dbt_schema_version(artifact_json=manifest)
167
+ if dbt_schema_version == ArtifactTypes.MANIFEST_V3.value.dbt_schema_version:
168
+ return ManifestV3(**manifest)
169
+ raise ValueError("Not a manifest.json v3")
170
+
171
+
172
+ def parse_manifest_v4(manifest: dict) -> ManifestV4:
173
+ """Parse manifest.json ver.4"""
174
+ dbt_schema_version = get_dbt_schema_version(artifact_json=manifest)
175
+ if dbt_schema_version == ArtifactTypes.MANIFEST_V4.value.dbt_schema_version:
176
+ return ManifestV4(**manifest)
177
+ raise ValueError("Not a manifest.json v4")
178
+
179
+
180
+ def parse_manifest_v5(manifest: dict) -> ManifestV5:
181
+ """Parse manifest.json ver.5"""
182
+ dbt_schema_version = get_dbt_schema_version(artifact_json=manifest)
183
+ if dbt_schema_version == ArtifactTypes.MANIFEST_V5.value.dbt_schema_version:
184
+ return ManifestV5(**manifest)
185
+ raise ValueError("Not a manifest.json v5")
186
+
187
+
188
+ def parse_manifest_v6(manifest: dict) -> ManifestV6:
189
+ """Parse manifest.json ver.6"""
190
+ dbt_schema_version = get_dbt_schema_version(artifact_json=manifest)
191
+ if dbt_schema_version == ArtifactTypes.MANIFEST_V6.value.dbt_schema_version:
192
+ return ManifestV6(**manifest)
193
+ raise ValueError("Not a manifest.json v6")
194
+
195
+
196
+ def parse_manifest_v7(manifest: dict) -> ManifestV7:
197
+ """Parse manifest.json ver.7"""
198
+ dbt_schema_version = get_dbt_schema_version(artifact_json=manifest)
199
+ if dbt_schema_version == ArtifactTypes.MANIFEST_V7.value.dbt_schema_version:
200
+ return ManifestV7(**manifest)
201
+ raise ValueError("Not a manifest.json v7")
202
+
203
+
204
+ def parse_manifest_v8(manifest: dict) -> ManifestV8:
205
+ """Parse manifest.json ver.8"""
206
+ dbt_schema_version = get_dbt_schema_version(artifact_json=manifest)
207
+ if dbt_schema_version == ArtifactTypes.MANIFEST_V8.value.dbt_schema_version:
208
+ return ManifestV8(**manifest)
209
+ raise ValueError("Not a manifest.json v8")
210
+
211
+
212
+ def parse_manifest_v9(manifest: dict) -> ManifestV9:
213
+ """Parse manifest.json ver.9"""
214
+ dbt_schema_version = get_dbt_schema_version(artifact_json=manifest)
215
+ if dbt_schema_version == ArtifactTypes.MANIFEST_V9.value.dbt_schema_version:
216
+ return ManifestV9(**manifest)
217
+ raise ValueError("Not a manifest.json v9")
218
+
219
+
220
+ def parse_manifest_v10(manifest: dict) -> ManifestV10:
221
+ """Parse manifest.json ver.10"""
222
+ dbt_schema_version = get_dbt_schema_version(artifact_json=manifest)
223
+ if dbt_schema_version == ArtifactTypes.MANIFEST_V10.value.dbt_schema_version:
224
+ return ManifestV10(**manifest)
225
+ raise ValueError("Not a manifest.json v10")
226
+
227
+
228
+ def parse_manifest_v11(manifest: dict) -> ManifestV11:
229
+ """Parse manifest.json ver.11"""
230
+ dbt_schema_version = get_dbt_schema_version(artifact_json=manifest)
231
+ if dbt_schema_version == ArtifactTypes.MANIFEST_V11.value.dbt_schema_version:
232
+ return ManifestV11(**manifest)
233
+ raise ValueError("Not a manifest.json v11")
234
+
235
+
236
+ def parse_manifest_v12(manifest: dict) -> Union[ManifestV12, ManifestCLOUD]:
237
+ """Parse manifest.json ver.12"""
238
+ dbt_schema_version = get_dbt_schema_version(artifact_json=manifest)
239
+ if dbt_schema_version == ArtifactTypes.MANIFEST_V12.value.dbt_schema_version:
240
+ try:
241
+ return ManifestV12(**manifest)
242
+ except ValidationError:
243
+ return ManifestCLOUD(**manifest)
244
+ raise ValueError("Not a manifest.json v12")
245
+
246
+
247
+ #
248
+ # run-results
249
+ #
250
+ def parse_run_results(
251
+ run_results: dict,
252
+ ) -> Union[
253
+ RunResultsV1,
254
+ RunResultsV2,
255
+ RunResultsV3,
256
+ RunResultsV4,
257
+ RunResultsV5,
258
+ RunResultsV6,
259
+ RunResultsCLOUD,
260
+ ]:
261
+ """Parse run-results.json
262
+
263
+ Args:
264
+ run_results: A dict of run-results.json
265
+
266
+ Returns:
267
+ Union[RunResultsV1, RunResultsV2, RunResultsV3, RunResultsV4]:
268
+ """
269
+ dbt_schema_version = get_dbt_schema_version(artifact_json=run_results)
270
+ if dbt_schema_version == ArtifactTypes.RUN_RESULTS_V1.value.dbt_schema_version:
271
+ return RunResultsV1(**run_results)
272
+ elif dbt_schema_version == ArtifactTypes.RUN_RESULTS_V2.value.dbt_schema_version:
273
+ return RunResultsV2(**run_results)
274
+ elif dbt_schema_version == ArtifactTypes.RUN_RESULTS_V3.value.dbt_schema_version:
275
+ return RunResultsV3(**run_results)
276
+ elif dbt_schema_version == ArtifactTypes.RUN_RESULTS_V4.value.dbt_schema_version:
277
+ return RunResultsV4(**run_results)
278
+ elif dbt_schema_version == ArtifactTypes.RUN_RESULTS_V5.value.dbt_schema_version:
279
+ return RunResultsV5(**run_results)
280
+ elif dbt_schema_version == ArtifactTypes.RUN_RESULTS_V6.value.dbt_schema_version:
281
+ try:
282
+ return RunResultsV6(**run_results)
283
+ except ValidationError:
284
+ return RunResultsCLOUD(**run_results)
285
+ raise ValueError("Not a run_results.json")
286
+
287
+
288
+ def parse_run_results_v1(run_results: dict) -> RunResultsV1:
289
+ """Parse run-results.json v1"""
290
+ dbt_schema_version = get_dbt_schema_version(artifact_json=run_results)
291
+ if dbt_schema_version == ArtifactTypes.RUN_RESULTS_V1.value.dbt_schema_version:
292
+ return RunResultsV1(**run_results)
293
+ raise ValueError("Not a run-results.json v1")
294
+
295
+
296
+ def parse_run_results_v2(run_results: dict) -> RunResultsV2:
297
+ """Parse run-results.json v2"""
298
+ dbt_schema_version = get_dbt_schema_version(artifact_json=run_results)
299
+ if dbt_schema_version == ArtifactTypes.RUN_RESULTS_V2.value.dbt_schema_version:
300
+ return RunResultsV2(**run_results)
301
+ raise ValueError("Not a run-results.json v2")
302
+
303
+
304
+ def parse_run_results_v3(run_results: dict) -> RunResultsV3:
305
+ """Parse run-results.json v3"""
306
+ dbt_schema_version = get_dbt_schema_version(artifact_json=run_results)
307
+ if dbt_schema_version == ArtifactTypes.RUN_RESULTS_V3.value.dbt_schema_version:
308
+ return RunResultsV3(**run_results)
309
+ raise ValueError("Not a run-results.json v3")
310
+
311
+
312
+ def parse_run_results_v4(run_results: dict) -> RunResultsV4:
313
+ """Parse run-results.json v4"""
314
+ dbt_schema_version = get_dbt_schema_version(artifact_json=run_results)
315
+ if dbt_schema_version == ArtifactTypes.RUN_RESULTS_V4.value.dbt_schema_version:
316
+ return RunResultsV4(**run_results)
317
+ raise ValueError("Not a run-results.json v4")
318
+
319
+
320
+ def parse_run_results_v5(run_results: dict) -> RunResultsV5:
321
+ """Parse run-results.json v5"""
322
+ dbt_schema_version = get_dbt_schema_version(artifact_json=run_results)
323
+ if dbt_schema_version == ArtifactTypes.RUN_RESULTS_V5.value.dbt_schema_version:
324
+ return RunResultsV5(**run_results)
325
+ raise ValueError("Not a run-results.json v5")
326
+
327
+
328
+ def parse_run_results_v6(run_results: dict) -> Union[RunResultsV6, RunResultsCLOUD]:
329
+ """Parse run-results.json v6"""
330
+ dbt_schema_version = get_dbt_schema_version(artifact_json=run_results)
331
+ if dbt_schema_version == ArtifactTypes.RUN_RESULTS_V6.value.dbt_schema_version:
332
+ try:
333
+ return RunResultsV6(**run_results)
334
+ except ValidationError:
335
+ return RunResultsCLOUD(**run_results)
336
+ raise ValueError("Not a run-results.json v6")
337
+
338
+
339
+ #
340
+ # sources
341
+ #
342
+ def parse_sources(
343
+ sources: dict,
344
+ ) -> Union[SourcesV1, SourcesV2, SourcesV3, SourcesCLOUD]:
345
+ """Parse sources.json
346
+
347
+ Args:
348
+ sources: A dict of sources.json
349
+
350
+ Returns:
351
+ Union[SourcesV1, SourcesV2, SourcesV3]
352
+ """
353
+ dbt_schema_version = get_dbt_schema_version(artifact_json=sources)
354
+ if dbt_schema_version == ArtifactTypes.SOURCES_V1.value.dbt_schema_version:
355
+ return SourcesV1(**sources)
356
+ elif dbt_schema_version == ArtifactTypes.SOURCES_V2.value.dbt_schema_version:
357
+ return SourcesV2(**sources)
358
+ elif dbt_schema_version == ArtifactTypes.SOURCES_V3.value.dbt_schema_version:
359
+ try:
360
+ return SourcesV3(**sources)
361
+ except ValidationError:
362
+ return SourcesCLOUD(**sources)
363
+ raise ValueError("Not a sources.json")
364
+
365
+
366
+ def parse_sources_v1(sources: dict) -> SourcesV1:
367
+ """Parse sources.json v1"""
368
+ dbt_schema_version = get_dbt_schema_version(artifact_json=sources)
369
+ if dbt_schema_version == ArtifactTypes.SOURCES_V1.value.dbt_schema_version:
370
+ return SourcesV1(**sources)
371
+ raise ValueError("Not a sources.json v1")
372
+
373
+
374
+ def parse_sources_v2(sources: dict) -> SourcesV2:
375
+ """Parse sources.json v2"""
376
+ dbt_schema_version = get_dbt_schema_version(artifact_json=sources)
377
+ if dbt_schema_version == ArtifactTypes.SOURCES_V2.value.dbt_schema_version:
378
+ return SourcesV2(**sources)
379
+ raise ValueError("Not a sources.json v2")
380
+
381
+
382
+ def parse_sources_v3(sources: dict) -> Union[SourcesV3, SourcesCLOUD]:
383
+ """Parse sources.json v3"""
384
+ dbt_schema_version = get_dbt_schema_version(artifact_json=sources)
385
+ if dbt_schema_version == ArtifactTypes.SOURCES_V3.value.dbt_schema_version:
386
+ try:
387
+ return SourcesV3(**sources)
388
+ except ValidationError:
389
+ return SourcesCLOUD(**sources)
390
+ raise ValueError("Not a sources.json v3")
@@ -0,0 +1,16 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with
4
+ # this work for additional information regarding copyright ownership.
5
+ # The ASF licenses this file to You under the Apache License, Version 2.0
6
+ # (the "License"); you may not use this file except in compliance with
7
+ # the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
@@ -0,0 +1,26 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with
4
+ # this work for additional information regarding copyright ownership.
5
+ # The ASF licenses this file to You under the Apache License, Version 2.0
6
+ # (the "License"); you may not use this file except in compliance with
7
+ # the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ # pylint: disable=no-name-in-module
19
+ # pylint: disable=no-self-argument
20
+ from pydantic import BaseModel
21
+
22
+
23
+ class BaseParserModel(BaseModel):
24
+ """
25
+ The base parser class
26
+ """
@@ -0,0 +1,16 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with
4
+ # this work for additional information regarding copyright ownership.
5
+ # The ASF licenses this file to You under the Apache License, Version 2.0
6
+ # (the "License"); you may not use this file except in compliance with
7
+ # the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
@@ -0,0 +1,85 @@
1
+ # generated by datamodel-codegen:
2
+ # filename: catalog_cloud.json
3
+
4
+ from __future__ import annotations
5
+
6
+ from typing import Any, Dict, List, Optional, Union
7
+
8
+ from pydantic import ConfigDict, Field
9
+
10
+ from collate_dbt_artifacts_parser.parsers.base import BaseParserModel
11
+
12
+
13
+ class Metadata(BaseParserModel):
14
+ model_config = ConfigDict(
15
+ extra="forbid",
16
+ )
17
+ dbt_schema_version: Optional[str] = None
18
+ dbt_version: Optional[str] = "1.10.0a1"
19
+ generated_at: Optional[str] = None
20
+ invocation_id: Optional[str] = None
21
+ env: Optional[Dict[str, str]] = None
22
+
23
+
24
+ class Metadata1(BaseParserModel):
25
+ model_config = ConfigDict(
26
+ extra="forbid",
27
+ )
28
+ type: str
29
+ schema_: str = Field(..., alias="schema")
30
+ name: str
31
+ database: Optional[str] = None
32
+ comment: Optional[str] = None
33
+ owner: Optional[str] = None
34
+
35
+
36
+ class Columns(BaseParserModel):
37
+ model_config = ConfigDict(
38
+ extra="forbid",
39
+ )
40
+ type: str
41
+ index: int
42
+ name: str
43
+ comment: Optional[str] = None
44
+
45
+
46
+ class Stats(BaseParserModel):
47
+ model_config = ConfigDict(
48
+ extra="forbid",
49
+ )
50
+ id: str
51
+ label: str
52
+ value: Optional[Union[bool, str, float]] = None
53
+ include: bool
54
+ description: Optional[str] = None
55
+
56
+
57
+ class Nodes(BaseParserModel):
58
+ model_config = ConfigDict(
59
+ extra="forbid",
60
+ )
61
+ metadata: Metadata1 = Field(..., title="TableMetadata")
62
+ columns: Dict[str, Columns]
63
+ stats: Dict[str, Stats]
64
+ unique_id: Optional[str] = None
65
+
66
+
67
+ class Sources(BaseParserModel):
68
+ model_config = ConfigDict(
69
+ extra="forbid",
70
+ )
71
+ metadata: Metadata1 = Field(..., title="TableMetadata")
72
+ columns: Dict[str, Columns]
73
+ stats: Dict[str, Stats]
74
+ unique_id: Optional[str] = None
75
+
76
+
77
+ class CatalogCLOUD(BaseParserModel):
78
+ model_config = ConfigDict(
79
+ extra="forbid",
80
+ )
81
+ metadata: Metadata = Field(..., title="CatalogMetadata")
82
+ nodes: Dict[str, Nodes]
83
+ sources: Dict[str, Sources]
84
+ errors: Optional[List[str]] = None
85
+ field_compile_results: Any = Field(None, alias="_compile_results")
@@ -0,0 +1,85 @@
1
+ # generated by datamodel-codegen:
2
+ # filename: catalog_v1.json
3
+
4
+ from __future__ import annotations
5
+
6
+ from typing import Any, Dict, List, Optional, Union
7
+
8
+ from pydantic import ConfigDict, Field
9
+
10
+ from collate_dbt_artifacts_parser.parsers.base import BaseParserModel
11
+
12
+
13
+ class Metadata(BaseParserModel):
14
+ model_config = ConfigDict(
15
+ extra="forbid",
16
+ )
17
+ dbt_schema_version: Optional[str] = None
18
+ dbt_version: Optional[str] = "1.9.0b2"
19
+ generated_at: Optional[str] = None
20
+ invocation_id: Optional[str] = None
21
+ env: Optional[Dict[str, str]] = None
22
+
23
+
24
+ class Metadata1(BaseParserModel):
25
+ model_config = ConfigDict(
26
+ extra="forbid",
27
+ )
28
+ type: str
29
+ schema_: str = Field(..., alias="schema")
30
+ name: str
31
+ database: Optional[str] = None
32
+ comment: Optional[str] = None
33
+ owner: Optional[str] = None
34
+
35
+
36
+ class Columns(BaseParserModel):
37
+ model_config = ConfigDict(
38
+ extra="forbid",
39
+ )
40
+ type: str
41
+ index: int
42
+ name: str
43
+ comment: Optional[str] = None
44
+
45
+
46
+ class Stats(BaseParserModel):
47
+ model_config = ConfigDict(
48
+ extra="forbid",
49
+ )
50
+ id: str
51
+ label: str
52
+ value: Optional[Union[bool, str, float]] = None
53
+ include: bool
54
+ description: Optional[str] = None
55
+
56
+
57
+ class Nodes(BaseParserModel):
58
+ model_config = ConfigDict(
59
+ extra="forbid",
60
+ )
61
+ metadata: Metadata1 = Field(..., title="TableMetadata")
62
+ columns: Dict[str, Columns]
63
+ stats: Dict[str, Stats]
64
+ unique_id: Optional[str] = None
65
+
66
+
67
+ class Sources(BaseParserModel):
68
+ model_config = ConfigDict(
69
+ extra="forbid",
70
+ )
71
+ metadata: Metadata1 = Field(..., title="TableMetadata")
72
+ columns: Dict[str, Columns]
73
+ stats: Dict[str, Stats]
74
+ unique_id: Optional[str] = None
75
+
76
+
77
+ class CatalogV1(BaseParserModel):
78
+ model_config = ConfigDict(
79
+ extra="forbid",
80
+ )
81
+ metadata: Metadata = Field(..., title="CatalogMetadata")
82
+ nodes: Dict[str, Nodes]
83
+ sources: Dict[str, Sources]
84
+ errors: Optional[List[str]] = None
85
+ field_compile_results: Any = Field(None, alias="_compile_results")
@@ -0,0 +1,16 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with
4
+ # this work for additional information regarding copyright ownership.
5
+ # The ASF licenses this file to You under the Apache License, Version 2.0
6
+ # (the "License"); you may not use this file except in compliance with
7
+ # the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #