dvt-core 0.58.6__cp311-cp311-macosx_10_9_x86_64.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 (324) hide show
  1. dbt/__init__.py +7 -0
  2. dbt/_pydantic_shim.py +26 -0
  3. dbt/artifacts/__init__.py +0 -0
  4. dbt/artifacts/exceptions/__init__.py +1 -0
  5. dbt/artifacts/exceptions/schemas.py +31 -0
  6. dbt/artifacts/resources/__init__.py +116 -0
  7. dbt/artifacts/resources/base.py +67 -0
  8. dbt/artifacts/resources/types.py +93 -0
  9. dbt/artifacts/resources/v1/analysis.py +10 -0
  10. dbt/artifacts/resources/v1/catalog.py +23 -0
  11. dbt/artifacts/resources/v1/components.py +274 -0
  12. dbt/artifacts/resources/v1/config.py +277 -0
  13. dbt/artifacts/resources/v1/documentation.py +11 -0
  14. dbt/artifacts/resources/v1/exposure.py +51 -0
  15. dbt/artifacts/resources/v1/function.py +52 -0
  16. dbt/artifacts/resources/v1/generic_test.py +31 -0
  17. dbt/artifacts/resources/v1/group.py +21 -0
  18. dbt/artifacts/resources/v1/hook.py +11 -0
  19. dbt/artifacts/resources/v1/macro.py +29 -0
  20. dbt/artifacts/resources/v1/metric.py +172 -0
  21. dbt/artifacts/resources/v1/model.py +145 -0
  22. dbt/artifacts/resources/v1/owner.py +10 -0
  23. dbt/artifacts/resources/v1/saved_query.py +111 -0
  24. dbt/artifacts/resources/v1/seed.py +41 -0
  25. dbt/artifacts/resources/v1/semantic_layer_components.py +72 -0
  26. dbt/artifacts/resources/v1/semantic_model.py +314 -0
  27. dbt/artifacts/resources/v1/singular_test.py +14 -0
  28. dbt/artifacts/resources/v1/snapshot.py +91 -0
  29. dbt/artifacts/resources/v1/source_definition.py +84 -0
  30. dbt/artifacts/resources/v1/sql_operation.py +10 -0
  31. dbt/artifacts/resources/v1/unit_test_definition.py +77 -0
  32. dbt/artifacts/schemas/__init__.py +0 -0
  33. dbt/artifacts/schemas/base.py +191 -0
  34. dbt/artifacts/schemas/batch_results.py +24 -0
  35. dbt/artifacts/schemas/catalog/__init__.py +11 -0
  36. dbt/artifacts/schemas/catalog/v1/__init__.py +0 -0
  37. dbt/artifacts/schemas/catalog/v1/catalog.py +59 -0
  38. dbt/artifacts/schemas/freshness/__init__.py +1 -0
  39. dbt/artifacts/schemas/freshness/v3/__init__.py +0 -0
  40. dbt/artifacts/schemas/freshness/v3/freshness.py +158 -0
  41. dbt/artifacts/schemas/manifest/__init__.py +2 -0
  42. dbt/artifacts/schemas/manifest/v12/__init__.py +0 -0
  43. dbt/artifacts/schemas/manifest/v12/manifest.py +211 -0
  44. dbt/artifacts/schemas/results.py +147 -0
  45. dbt/artifacts/schemas/run/__init__.py +2 -0
  46. dbt/artifacts/schemas/run/v5/__init__.py +0 -0
  47. dbt/artifacts/schemas/run/v5/run.py +184 -0
  48. dbt/artifacts/schemas/upgrades/__init__.py +4 -0
  49. dbt/artifacts/schemas/upgrades/upgrade_manifest.py +174 -0
  50. dbt/artifacts/schemas/upgrades/upgrade_manifest_dbt_version.py +2 -0
  51. dbt/artifacts/utils/validation.py +153 -0
  52. dbt/cli/__init__.py +1 -0
  53. dbt/cli/context.py +17 -0
  54. dbt/cli/exceptions.py +57 -0
  55. dbt/cli/flags.py +560 -0
  56. dbt/cli/main.py +2403 -0
  57. dbt/cli/option_types.py +121 -0
  58. dbt/cli/options.py +80 -0
  59. dbt/cli/params.py +844 -0
  60. dbt/cli/requires.py +490 -0
  61. dbt/cli/resolvers.py +50 -0
  62. dbt/cli/types.py +40 -0
  63. dbt/clients/__init__.py +0 -0
  64. dbt/clients/checked_load.py +83 -0
  65. dbt/clients/git.py +164 -0
  66. dbt/clients/jinja.py +206 -0
  67. dbt/clients/jinja_static.py +245 -0
  68. dbt/clients/registry.py +192 -0
  69. dbt/clients/yaml_helper.py +68 -0
  70. dbt/compilation.py +876 -0
  71. dbt/compute/__init__.py +14 -0
  72. dbt/compute/engines/__init__.py +12 -0
  73. dbt/compute/engines/spark_engine.cpython-311-darwin.so +0 -0
  74. dbt/compute/engines/spark_engine.py +642 -0
  75. dbt/compute/federated_executor.cpython-311-darwin.so +0 -0
  76. dbt/compute/federated_executor.py +1080 -0
  77. dbt/compute/filter_pushdown.cpython-311-darwin.so +0 -0
  78. dbt/compute/filter_pushdown.py +273 -0
  79. dbt/compute/jar_provisioning.cpython-311-darwin.so +0 -0
  80. dbt/compute/jar_provisioning.py +255 -0
  81. dbt/compute/java_compat.cpython-311-darwin.so +0 -0
  82. dbt/compute/java_compat.py +689 -0
  83. dbt/compute/jdbc_utils.cpython-311-darwin.so +0 -0
  84. dbt/compute/jdbc_utils.py +678 -0
  85. dbt/compute/metadata/__init__.py +40 -0
  86. dbt/compute/metadata/adapters_registry.cpython-311-darwin.so +0 -0
  87. dbt/compute/metadata/adapters_registry.py +370 -0
  88. dbt/compute/metadata/registry.cpython-311-darwin.so +0 -0
  89. dbt/compute/metadata/registry.py +674 -0
  90. dbt/compute/metadata/store.cpython-311-darwin.so +0 -0
  91. dbt/compute/metadata/store.py +1499 -0
  92. dbt/compute/smart_selector.cpython-311-darwin.so +0 -0
  93. dbt/compute/smart_selector.py +377 -0
  94. dbt/compute/strategies/__init__.py +55 -0
  95. dbt/compute/strategies/base.cpython-311-darwin.so +0 -0
  96. dbt/compute/strategies/base.py +165 -0
  97. dbt/compute/strategies/dataproc.cpython-311-darwin.so +0 -0
  98. dbt/compute/strategies/dataproc.py +207 -0
  99. dbt/compute/strategies/emr.cpython-311-darwin.so +0 -0
  100. dbt/compute/strategies/emr.py +203 -0
  101. dbt/compute/strategies/local.cpython-311-darwin.so +0 -0
  102. dbt/compute/strategies/local.py +443 -0
  103. dbt/compute/strategies/standalone.cpython-311-darwin.so +0 -0
  104. dbt/compute/strategies/standalone.py +262 -0
  105. dbt/config/__init__.py +4 -0
  106. dbt/config/catalogs.py +94 -0
  107. dbt/config/compute.cpython-311-darwin.so +0 -0
  108. dbt/config/compute.py +513 -0
  109. dbt/config/dvt_profile.cpython-311-darwin.so +0 -0
  110. dbt/config/dvt_profile.py +342 -0
  111. dbt/config/profile.py +422 -0
  112. dbt/config/project.py +873 -0
  113. dbt/config/project_utils.py +28 -0
  114. dbt/config/renderer.py +231 -0
  115. dbt/config/runtime.py +553 -0
  116. dbt/config/selectors.py +208 -0
  117. dbt/config/utils.py +77 -0
  118. dbt/constants.py +28 -0
  119. dbt/context/__init__.py +0 -0
  120. dbt/context/base.py +745 -0
  121. dbt/context/configured.py +135 -0
  122. dbt/context/context_config.py +382 -0
  123. dbt/context/docs.py +82 -0
  124. dbt/context/exceptions_jinja.py +178 -0
  125. dbt/context/macro_resolver.py +195 -0
  126. dbt/context/macros.py +171 -0
  127. dbt/context/manifest.py +72 -0
  128. dbt/context/providers.py +2249 -0
  129. dbt/context/query_header.py +13 -0
  130. dbt/context/secret.py +58 -0
  131. dbt/context/target.py +74 -0
  132. dbt/contracts/__init__.py +0 -0
  133. dbt/contracts/files.py +413 -0
  134. dbt/contracts/graph/__init__.py +0 -0
  135. dbt/contracts/graph/manifest.py +1904 -0
  136. dbt/contracts/graph/metrics.py +97 -0
  137. dbt/contracts/graph/model_config.py +70 -0
  138. dbt/contracts/graph/node_args.py +42 -0
  139. dbt/contracts/graph/nodes.py +1806 -0
  140. dbt/contracts/graph/semantic_manifest.py +232 -0
  141. dbt/contracts/graph/unparsed.py +811 -0
  142. dbt/contracts/project.py +417 -0
  143. dbt/contracts/results.py +53 -0
  144. dbt/contracts/selection.py +23 -0
  145. dbt/contracts/sql.py +85 -0
  146. dbt/contracts/state.py +68 -0
  147. dbt/contracts/util.py +46 -0
  148. dbt/deprecations.py +348 -0
  149. dbt/deps/__init__.py +0 -0
  150. dbt/deps/base.py +152 -0
  151. dbt/deps/git.py +195 -0
  152. dbt/deps/local.py +79 -0
  153. dbt/deps/registry.py +130 -0
  154. dbt/deps/resolver.py +149 -0
  155. dbt/deps/tarball.py +120 -0
  156. dbt/docs/source/_ext/dbt_click.py +119 -0
  157. dbt/docs/source/conf.py +32 -0
  158. dbt/env_vars.py +64 -0
  159. dbt/event_time/event_time.py +40 -0
  160. dbt/event_time/sample_window.py +60 -0
  161. dbt/events/__init__.py +15 -0
  162. dbt/events/base_types.py +36 -0
  163. dbt/events/core_types_pb2.py +2 -0
  164. dbt/events/logging.py +108 -0
  165. dbt/events/types.py +2516 -0
  166. dbt/exceptions.py +1486 -0
  167. dbt/flags.py +89 -0
  168. dbt/graph/__init__.py +11 -0
  169. dbt/graph/cli.py +249 -0
  170. dbt/graph/graph.py +172 -0
  171. dbt/graph/queue.py +214 -0
  172. dbt/graph/selector.py +374 -0
  173. dbt/graph/selector_methods.py +975 -0
  174. dbt/graph/selector_spec.py +222 -0
  175. dbt/graph/thread_pool.py +18 -0
  176. dbt/hooks.py +21 -0
  177. dbt/include/README.md +49 -0
  178. dbt/include/__init__.py +3 -0
  179. dbt/include/data/adapters_registry.duckdb +0 -0
  180. dbt/include/data/build_registry.py +242 -0
  181. dbt/include/data/csv/adapter_queries.csv +33 -0
  182. dbt/include/data/csv/syntax_rules.csv +9 -0
  183. dbt/include/data/csv/type_mappings_bigquery.csv +28 -0
  184. dbt/include/data/csv/type_mappings_databricks.csv +30 -0
  185. dbt/include/data/csv/type_mappings_mysql.csv +40 -0
  186. dbt/include/data/csv/type_mappings_oracle.csv +30 -0
  187. dbt/include/data/csv/type_mappings_postgres.csv +56 -0
  188. dbt/include/data/csv/type_mappings_redshift.csv +33 -0
  189. dbt/include/data/csv/type_mappings_snowflake.csv +38 -0
  190. dbt/include/data/csv/type_mappings_sqlserver.csv +35 -0
  191. dbt/include/starter_project/.gitignore +4 -0
  192. dbt/include/starter_project/README.md +15 -0
  193. dbt/include/starter_project/__init__.py +3 -0
  194. dbt/include/starter_project/analyses/.gitkeep +0 -0
  195. dbt/include/starter_project/dbt_project.yml +36 -0
  196. dbt/include/starter_project/macros/.gitkeep +0 -0
  197. dbt/include/starter_project/models/example/my_first_dbt_model.sql +27 -0
  198. dbt/include/starter_project/models/example/my_second_dbt_model.sql +6 -0
  199. dbt/include/starter_project/models/example/schema.yml +21 -0
  200. dbt/include/starter_project/seeds/.gitkeep +0 -0
  201. dbt/include/starter_project/snapshots/.gitkeep +0 -0
  202. dbt/include/starter_project/tests/.gitkeep +0 -0
  203. dbt/internal_deprecations.py +26 -0
  204. dbt/jsonschemas/__init__.py +3 -0
  205. dbt/jsonschemas/jsonschemas.py +309 -0
  206. dbt/jsonschemas/project/0.0.110.json +4717 -0
  207. dbt/jsonschemas/project/0.0.85.json +2015 -0
  208. dbt/jsonschemas/resources/0.0.110.json +2636 -0
  209. dbt/jsonschemas/resources/0.0.85.json +2536 -0
  210. dbt/jsonschemas/resources/latest.json +6773 -0
  211. dbt/links.py +4 -0
  212. dbt/materializations/__init__.py +0 -0
  213. dbt/materializations/incremental/__init__.py +0 -0
  214. dbt/materializations/incremental/microbatch.py +236 -0
  215. dbt/mp_context.py +8 -0
  216. dbt/node_types.py +37 -0
  217. dbt/parser/__init__.py +23 -0
  218. dbt/parser/analysis.py +21 -0
  219. dbt/parser/base.py +548 -0
  220. dbt/parser/common.py +266 -0
  221. dbt/parser/docs.py +52 -0
  222. dbt/parser/fixtures.py +51 -0
  223. dbt/parser/functions.py +30 -0
  224. dbt/parser/generic_test.py +100 -0
  225. dbt/parser/generic_test_builders.py +333 -0
  226. dbt/parser/hooks.py +118 -0
  227. dbt/parser/macros.py +137 -0
  228. dbt/parser/manifest.py +2204 -0
  229. dbt/parser/models.py +573 -0
  230. dbt/parser/partial.py +1178 -0
  231. dbt/parser/read_files.py +445 -0
  232. dbt/parser/schema_generic_tests.py +422 -0
  233. dbt/parser/schema_renderer.py +111 -0
  234. dbt/parser/schema_yaml_readers.py +935 -0
  235. dbt/parser/schemas.py +1466 -0
  236. dbt/parser/search.py +149 -0
  237. dbt/parser/seeds.py +28 -0
  238. dbt/parser/singular_test.py +20 -0
  239. dbt/parser/snapshots.py +44 -0
  240. dbt/parser/sources.py +558 -0
  241. dbt/parser/sql.py +62 -0
  242. dbt/parser/unit_tests.py +621 -0
  243. dbt/plugins/__init__.py +20 -0
  244. dbt/plugins/contracts.py +9 -0
  245. dbt/plugins/exceptions.py +2 -0
  246. dbt/plugins/manager.py +163 -0
  247. dbt/plugins/manifest.py +21 -0
  248. dbt/profiler.py +20 -0
  249. dbt/py.typed +1 -0
  250. dbt/query_analyzer.cpython-311-darwin.so +0 -0
  251. dbt/query_analyzer.py +410 -0
  252. dbt/runners/__init__.py +2 -0
  253. dbt/runners/exposure_runner.py +7 -0
  254. dbt/runners/no_op_runner.py +45 -0
  255. dbt/runners/saved_query_runner.py +7 -0
  256. dbt/selected_resources.py +8 -0
  257. dbt/task/__init__.py +0 -0
  258. dbt/task/base.py +503 -0
  259. dbt/task/build.py +197 -0
  260. dbt/task/clean.py +56 -0
  261. dbt/task/clone.py +161 -0
  262. dbt/task/compile.py +150 -0
  263. dbt/task/compute.cpython-311-darwin.so +0 -0
  264. dbt/task/compute.py +458 -0
  265. dbt/task/debug.py +505 -0
  266. dbt/task/deps.py +280 -0
  267. dbt/task/docs/__init__.py +3 -0
  268. dbt/task/docs/api/__init__.py +23 -0
  269. dbt/task/docs/api/catalog.cpython-311-darwin.so +0 -0
  270. dbt/task/docs/api/catalog.py +204 -0
  271. dbt/task/docs/api/lineage.cpython-311-darwin.so +0 -0
  272. dbt/task/docs/api/lineage.py +234 -0
  273. dbt/task/docs/api/profile.cpython-311-darwin.so +0 -0
  274. dbt/task/docs/api/profile.py +204 -0
  275. dbt/task/docs/api/spark.cpython-311-darwin.so +0 -0
  276. dbt/task/docs/api/spark.py +186 -0
  277. dbt/task/docs/generate.py +947 -0
  278. dbt/task/docs/index.html +250 -0
  279. dbt/task/docs/serve.cpython-311-darwin.so +0 -0
  280. dbt/task/docs/serve.py +174 -0
  281. dbt/task/dvt_output.py +362 -0
  282. dbt/task/dvt_run.py +204 -0
  283. dbt/task/freshness.py +322 -0
  284. dbt/task/function.py +121 -0
  285. dbt/task/group_lookup.py +46 -0
  286. dbt/task/init.cpython-311-darwin.so +0 -0
  287. dbt/task/init.py +604 -0
  288. dbt/task/java.cpython-311-darwin.so +0 -0
  289. dbt/task/java.py +316 -0
  290. dbt/task/list.py +236 -0
  291. dbt/task/metadata.cpython-311-darwin.so +0 -0
  292. dbt/task/metadata.py +804 -0
  293. dbt/task/printer.py +175 -0
  294. dbt/task/profile.cpython-311-darwin.so +0 -0
  295. dbt/task/profile.py +1307 -0
  296. dbt/task/profile_serve.py +615 -0
  297. dbt/task/retract.py +438 -0
  298. dbt/task/retry.py +175 -0
  299. dbt/task/run.py +1387 -0
  300. dbt/task/run_operation.py +141 -0
  301. dbt/task/runnable.py +758 -0
  302. dbt/task/seed.py +103 -0
  303. dbt/task/show.py +149 -0
  304. dbt/task/snapshot.py +56 -0
  305. dbt/task/spark.cpython-311-darwin.so +0 -0
  306. dbt/task/spark.py +414 -0
  307. dbt/task/sql.py +110 -0
  308. dbt/task/target_sync.cpython-311-darwin.so +0 -0
  309. dbt/task/target_sync.py +766 -0
  310. dbt/task/test.py +464 -0
  311. dbt/tests/fixtures/__init__.py +1 -0
  312. dbt/tests/fixtures/project.py +620 -0
  313. dbt/tests/util.py +651 -0
  314. dbt/tracking.py +529 -0
  315. dbt/utils/__init__.py +3 -0
  316. dbt/utils/artifact_upload.py +151 -0
  317. dbt/utils/utils.py +408 -0
  318. dbt/version.py +270 -0
  319. dvt_cli/__init__.py +72 -0
  320. dvt_core-0.58.6.dist-info/METADATA +288 -0
  321. dvt_core-0.58.6.dist-info/RECORD +324 -0
  322. dvt_core-0.58.6.dist-info/WHEEL +5 -0
  323. dvt_core-0.58.6.dist-info/entry_points.txt +2 -0
  324. dvt_core-0.58.6.dist-info/top_level.txt +2 -0
dbt/deprecations.py ADDED
@@ -0,0 +1,348 @@
1
+ import abc
2
+ from collections import defaultdict
3
+ from dataclasses import dataclass
4
+ from typing import Any, Callable, ClassVar, DefaultDict, Dict, List, Optional
5
+
6
+ import dbt.tracking
7
+ from dbt.events import types as core_types
8
+ from dbt.flags import get_flags
9
+ from dbt_common.dataclass_schema import dbtClassMixin
10
+ from dbt_common.events.functions import fire_event, warn_or_error
11
+ from dbt_common.events.types import Note
12
+
13
+
14
+ class DBTDeprecation:
15
+ _name: ClassVar[Optional[str]] = None
16
+ _event: ClassVar[Optional[str]] = None
17
+ _is_preview: ClassVar[bool] = False
18
+
19
+ @property
20
+ def name(self) -> str:
21
+ if self._name is not None:
22
+ return self._name
23
+ raise NotImplementedError("name not implemented for {}".format(self))
24
+
25
+ def track_deprecation_warn(self) -> None:
26
+ if dbt.tracking.active_user is not None:
27
+ dbt.tracking.track_deprecation_warn({"deprecation_name": self.name})
28
+
29
+ @property
30
+ def event(self) -> abc.ABCMeta:
31
+ if self._event is not None:
32
+ module_path = core_types
33
+ class_name = self._event
34
+
35
+ try:
36
+ return getattr(module_path, class_name)
37
+ except AttributeError:
38
+ msg = f"Event Class `{class_name}` is not defined in `{module_path}`"
39
+ raise NameError(msg)
40
+ raise NotImplementedError("event not implemented for {}".format(self._event))
41
+
42
+ def preview(self, base_event: abc.ABCMeta) -> None:
43
+ note_event = Note(msg=base_event.message()) # type: ignore
44
+ fire_event(note_event)
45
+
46
+ def show(self, *args, **kwargs) -> None:
47
+ if self._is_preview:
48
+ base_event = self.event(**kwargs)
49
+ self.preview(base_event)
50
+ else:
51
+ flags = get_flags()
52
+ if self.name not in active_deprecations or getattr(
53
+ flags, "show_all_deprecations", False
54
+ ):
55
+ event = self.event(**kwargs)
56
+ warn_or_error(event)
57
+ self.track_deprecation_warn()
58
+
59
+ active_deprecations[self.name] += 1
60
+
61
+
62
+ class PackageRedirectDeprecation(DBTDeprecation):
63
+ _name = "package-redirect"
64
+ _event = "PackageRedirectDeprecation"
65
+
66
+
67
+ class PackageInstallPathDeprecation(DBTDeprecation):
68
+ _name = "install-packages-path"
69
+ _event = "PackageInstallPathDeprecation"
70
+
71
+
72
+ # deprecations with a pattern of `project-config-*` for the name are not hardcoded
73
+ # they are called programatically via the pattern below
74
+ class ConfigSourcePathDeprecation(DBTDeprecation):
75
+ _name = "project-config-source-paths"
76
+ _event = "ConfigSourcePathDeprecation"
77
+
78
+
79
+ class ConfigDataPathDeprecation(DBTDeprecation):
80
+ _name = "project-config-data-paths"
81
+ _event = "ConfigDataPathDeprecation"
82
+
83
+
84
+ class ConfigLogPathDeprecation(DBTDeprecation):
85
+ _name = "project-config-log-path"
86
+ _event = "ConfigLogPathDeprecation"
87
+
88
+
89
+ class ConfigTargetPathDeprecation(DBTDeprecation):
90
+ _name = "project-config-target-path"
91
+ _event = "ConfigTargetPathDeprecation"
92
+
93
+
94
+ def renamed_method(old_name: str, new_name: str):
95
+ class AdapterDeprecationWarning(DBTDeprecation):
96
+ _name = "adapter:{}".format(old_name)
97
+ _event = "AdapterDeprecationWarning"
98
+
99
+ dep = AdapterDeprecationWarning()
100
+ deprecations_list.append(dep)
101
+ deprecations[dep.name] = dep
102
+
103
+
104
+ class MetricAttributesRenamed(DBTDeprecation):
105
+ _name = "metric-attr-renamed"
106
+ _event = "MetricAttributesRenamed"
107
+
108
+
109
+ class ExposureNameDeprecation(DBTDeprecation):
110
+ _name = "exposure-name"
111
+ _event = "ExposureNameDeprecation"
112
+
113
+
114
+ class CollectFreshnessReturnSignature(DBTDeprecation):
115
+ _name = "collect-freshness-return-signature"
116
+ _event = "CollectFreshnessReturnSignature"
117
+
118
+
119
+ class ProjectFlagsMovedDeprecation(DBTDeprecation):
120
+ _name = "project-flags-moved"
121
+ _event = "ProjectFlagsMovedDeprecation"
122
+
123
+
124
+ class PackageMaterializationOverrideDeprecation(DBTDeprecation):
125
+ _name = "package-materialization-override"
126
+ _event = "PackageMaterializationOverrideDeprecation"
127
+
128
+
129
+ class ResourceNamesWithSpacesDeprecation(DBTDeprecation):
130
+ _name = "resource-names-with-spaces"
131
+ _event = "ResourceNamesWithSpacesDeprecation"
132
+
133
+
134
+ class SourceFreshnessProjectHooksNotRun(DBTDeprecation):
135
+ _name = "source-freshness-project-hooks"
136
+ _event = "SourceFreshnessProjectHooksNotRun"
137
+
138
+
139
+ class MFTimespineWithoutYamlConfigurationDeprecation(DBTDeprecation):
140
+ _name = "mf-timespine-without-yaml-configuration"
141
+ _event = "MFTimespineWithoutYamlConfigurationDeprecation"
142
+
143
+
144
+ class MFCumulativeTypeParamsDeprecation(DBTDeprecation):
145
+ _name = "mf-cumulative-type-params-deprecation"
146
+ _event = "MFCumulativeTypeParamsDeprecation"
147
+
148
+
149
+ class MicrobatchMacroOutsideOfBatchesDeprecation(DBTDeprecation):
150
+ _name = "microbatch-macro-outside-of-batches-deprecation"
151
+ _event = "MicrobatchMacroOutsideOfBatchesDeprecation"
152
+
153
+
154
+ class GenericJSONSchemaValidationDeprecation(DBTDeprecation):
155
+ _name = "generic-json-schema-validation-deprecation"
156
+ _event = "GenericJSONSchemaValidationDeprecation"
157
+ _is_preview = True
158
+
159
+
160
+ class UnexpectedJinjaBlockDeprecation(DBTDeprecation):
161
+ _name = "unexpected-jinja-block-deprecation"
162
+ _event = "UnexpectedJinjaBlockDeprecation"
163
+
164
+
165
+ class DuplicateYAMLKeysDeprecation(DBTDeprecation):
166
+ _name = "duplicate-yaml-keys-deprecation"
167
+ _event = "DuplicateYAMLKeysDeprecation"
168
+
169
+
170
+ class CustomTopLevelKeyDeprecation(DBTDeprecation):
171
+ _name = "custom-top-level-key-deprecation"
172
+ _event = "CustomTopLevelKeyDeprecation"
173
+
174
+
175
+ class CustomKeyInConfigDeprecation(DBTDeprecation):
176
+ _name = "custom-key-in-config-deprecation"
177
+ _event = "CustomKeyInConfigDeprecation"
178
+
179
+
180
+ class CustomKeyInObjectDeprecation(DBTDeprecation):
181
+ _name = "custom-key-in-object-deprecation"
182
+ _event = "CustomKeyInObjectDeprecation"
183
+
184
+
185
+ class WEOInlcudeExcludeDeprecation(DBTDeprecation):
186
+ _name = "weo-include-exclude-deprecation"
187
+ _event = "WEOIncludeExcludeDeprecation"
188
+
189
+
190
+ class CustomOutputPathInSourceFreshnessDeprecation(DBTDeprecation):
191
+ _name = "custom-output-path-in-source-freshness-deprecation"
192
+ _event = "CustomOutputPathInSourceFreshnessDeprecation"
193
+
194
+
195
+ class SourceOverrideDeprecation(DBTDeprecation):
196
+ _name = "source-override-deprecation"
197
+ _event = "SourceOverrideDeprecation"
198
+
199
+
200
+ class PropertyMovedToConfigDeprecation(DBTDeprecation):
201
+ _name = "property-moved-to-config-deprecation"
202
+ _event = "PropertyMovedToConfigDeprecation"
203
+
204
+
205
+ class ModelParamUsageDeprecation(DBTDeprecation):
206
+ _name = "model-param-usage-deprecation"
207
+ _event = "ModelParamUsageDeprecation"
208
+
209
+
210
+ class EnvironmentVariableNamespaceDeprecation(DBTDeprecation):
211
+ _name = "environment-variable-namespace-deprecation"
212
+ _event = "EnvironmentVariableNamespaceDeprecation"
213
+
214
+
215
+ class MissingPlusPrefixDeprecation(DBTDeprecation):
216
+ _name = "missing-plus-prefix-in-config-deprecation"
217
+ _event = "MissingPlusPrefixDeprecation"
218
+
219
+
220
+ class ArgumentsPropertyInGenericTestDeprecation(DBTDeprecation):
221
+ _name = "arguments-property-in-generic-test-deprecation"
222
+ _event = "ArgumentsPropertyInGenericTestDeprecation"
223
+
224
+
225
+ class MissingArgumentsPropertyInGenericTestDeprecation(DBTDeprecation):
226
+ _name = "missing-arguments-property-in-generic-test-deprecation"
227
+ _event = "MissingArgumentsPropertyInGenericTestDeprecation"
228
+
229
+
230
+ class ModulesItertoolsUsageDeprecation(DBTDeprecation):
231
+ _name = "modules-itertools-usage-deprecation"
232
+ _event = "ModulesItertoolsUsageDeprecation"
233
+
234
+
235
+ def renamed_env_var(old_name: str, new_name: str):
236
+ class EnvironmentVariableRenamed(DBTDeprecation):
237
+ _name = f"environment-variable-renamed:{old_name}"
238
+ _event = "EnvironmentVariableRenamed"
239
+
240
+ dep = EnvironmentVariableRenamed()
241
+ deprecations_list.append(dep)
242
+ deprecations[dep.name] = dep
243
+
244
+ def cb():
245
+ dep.show(old_name=old_name, new_name=new_name)
246
+
247
+ return cb
248
+
249
+
250
+ def warn(name: str, *args, **kwargs) -> None:
251
+ if name not in deprecations:
252
+ # this should (hopefully) never happen
253
+ raise RuntimeError("Error showing deprecation warning: {}".format(name))
254
+
255
+ deprecations[name].show(*args, **kwargs)
256
+
257
+
258
+ def buffer(name: str, *args, **kwargs):
259
+ def show_callback():
260
+ deprecations[name].show(*args, **kwargs)
261
+
262
+ buffered_deprecations.append(show_callback)
263
+
264
+
265
+ def show_deprecations_summary() -> None:
266
+ summaries: List[Dict[str, Any]] = []
267
+ for deprecation, occurrences in active_deprecations.items():
268
+ deprecation_event = deprecations[deprecation].event()
269
+ summaries.append(
270
+ DeprecationSummary(
271
+ event_name=deprecation_event.__name__,
272
+ event_code=deprecation_event.code(),
273
+ occurrences=occurrences,
274
+ ).to_msg_dict()
275
+ )
276
+
277
+ if len(summaries) > 0:
278
+ show_all_hint = not get_flags().show_all_deprecations
279
+ warn_or_error(
280
+ core_types.DeprecationsSummary(summaries=summaries, show_all_hint=show_all_hint)
281
+ )
282
+
283
+
284
+ # these are globally available
285
+ # since modules are only imported once, active_deprecations is a singleton
286
+
287
+ active_deprecations: DefaultDict[str, int] = defaultdict(int)
288
+
289
+ deprecations_list: List[DBTDeprecation] = [
290
+ PackageRedirectDeprecation(),
291
+ PackageInstallPathDeprecation(),
292
+ ConfigSourcePathDeprecation(),
293
+ ConfigDataPathDeprecation(),
294
+ ExposureNameDeprecation(),
295
+ ConfigLogPathDeprecation(),
296
+ ConfigTargetPathDeprecation(),
297
+ CollectFreshnessReturnSignature(),
298
+ ProjectFlagsMovedDeprecation(),
299
+ PackageMaterializationOverrideDeprecation(),
300
+ ResourceNamesWithSpacesDeprecation(),
301
+ SourceFreshnessProjectHooksNotRun(),
302
+ MFTimespineWithoutYamlConfigurationDeprecation(),
303
+ MFCumulativeTypeParamsDeprecation(),
304
+ MicrobatchMacroOutsideOfBatchesDeprecation(),
305
+ GenericJSONSchemaValidationDeprecation(),
306
+ UnexpectedJinjaBlockDeprecation(),
307
+ DuplicateYAMLKeysDeprecation(),
308
+ CustomTopLevelKeyDeprecation(),
309
+ CustomKeyInConfigDeprecation(),
310
+ CustomKeyInObjectDeprecation(),
311
+ CustomOutputPathInSourceFreshnessDeprecation(),
312
+ PropertyMovedToConfigDeprecation(),
313
+ ModelParamUsageDeprecation(),
314
+ WEOInlcudeExcludeDeprecation(),
315
+ SourceOverrideDeprecation(),
316
+ EnvironmentVariableNamespaceDeprecation(),
317
+ MissingPlusPrefixDeprecation(),
318
+ ArgumentsPropertyInGenericTestDeprecation(),
319
+ MissingArgumentsPropertyInGenericTestDeprecation(),
320
+ ModulesItertoolsUsageDeprecation(),
321
+ ]
322
+
323
+ deprecations: Dict[str, DBTDeprecation] = {d.name: d for d in deprecations_list}
324
+
325
+ buffered_deprecations: List[Callable] = []
326
+
327
+
328
+ def reset_deprecations():
329
+ active_deprecations.clear()
330
+
331
+
332
+ def fire_buffered_deprecations():
333
+ [dep_fn() for dep_fn in buffered_deprecations]
334
+ buffered_deprecations.clear()
335
+
336
+
337
+ @dataclass
338
+ class DeprecationSummary(dbtClassMixin):
339
+ event_name: str
340
+ event_code: str
341
+ occurrences: int
342
+
343
+ def to_msg_dict(self) -> Dict[str, Any]:
344
+ return {
345
+ "event_name": self.event_name,
346
+ "event_code": self.event_code,
347
+ "occurrences": self.occurrences,
348
+ }
dbt/deps/__init__.py ADDED
File without changes
dbt/deps/base.py ADDED
@@ -0,0 +1,152 @@
1
+ import abc
2
+ import functools
3
+ import os
4
+ import tempfile
5
+ from contextlib import contextmanager
6
+ from pathlib import Path
7
+ from typing import Dict, Generic, List, Optional, TypeVar
8
+
9
+ from dbt.contracts.project import ProjectPackageMetadata
10
+ from dbt.events.types import DepsSetDownloadDirectory
11
+ from dbt_common.clients import system
12
+ from dbt_common.events.functions import fire_event
13
+ from dbt_common.utils.connection import connection_exception_retry
14
+
15
+ DOWNLOADS_PATH = None
16
+
17
+
18
+ def get_downloads_path():
19
+ return DOWNLOADS_PATH
20
+
21
+
22
+ @contextmanager
23
+ def downloads_directory():
24
+ global DOWNLOADS_PATH
25
+ remove_downloads = False
26
+ # the user might have set an environment variable. Set it to that, and do
27
+ # not remove it when finished.
28
+ if DOWNLOADS_PATH is None:
29
+ DOWNLOADS_PATH = os.getenv("DBT_DOWNLOADS_DIR")
30
+ remove_downloads = False
31
+ # if we are making a per-run temp directory, remove it at the end of
32
+ # successful runs
33
+ if DOWNLOADS_PATH is None:
34
+ DOWNLOADS_PATH = tempfile.mkdtemp(prefix="dbt-downloads-")
35
+ remove_downloads = True
36
+
37
+ system.make_directory(DOWNLOADS_PATH)
38
+ fire_event(DepsSetDownloadDirectory(path=DOWNLOADS_PATH))
39
+
40
+ yield DOWNLOADS_PATH
41
+
42
+ if remove_downloads:
43
+ system.rmtree(DOWNLOADS_PATH)
44
+ DOWNLOADS_PATH = None
45
+
46
+
47
+ class BasePackage(metaclass=abc.ABCMeta):
48
+ @abc.abstractproperty
49
+ def name(self) -> str:
50
+ raise NotImplementedError
51
+
52
+ def all_names(self) -> List[str]:
53
+ return [self.name]
54
+
55
+ @abc.abstractmethod
56
+ def source_type(self) -> str:
57
+ raise NotImplementedError
58
+
59
+
60
+ class PinnedPackage(BasePackage):
61
+ def __init__(self) -> None:
62
+ self._cached_metadata: Optional[ProjectPackageMetadata] = None
63
+
64
+ def __str__(self) -> str:
65
+ version = self.get_version()
66
+ if not version:
67
+ return self.name
68
+
69
+ return "{}@{}".format(self.name, version)
70
+
71
+ @abc.abstractmethod
72
+ def get_version(self) -> Optional[str]:
73
+ raise NotImplementedError
74
+
75
+ @abc.abstractmethod
76
+ def _fetch_metadata(self, project, renderer):
77
+ raise NotImplementedError
78
+
79
+ @abc.abstractmethod
80
+ def install(self, project, renderer):
81
+ raise NotImplementedError
82
+
83
+ @abc.abstractmethod
84
+ def nice_version_name(self):
85
+ raise NotImplementedError
86
+
87
+ @abc.abstractmethod
88
+ def to_dict(self) -> Dict[str, str]:
89
+ raise NotImplementedError
90
+
91
+ def fetch_metadata(self, project, renderer):
92
+ if not self._cached_metadata:
93
+ self._cached_metadata = self._fetch_metadata(project, renderer)
94
+ return self._cached_metadata
95
+
96
+ def get_project_name(self, project, renderer):
97
+ metadata = self.fetch_metadata(project, renderer)
98
+ return metadata.name
99
+
100
+ def get_installation_path(self, project, renderer):
101
+ dest_dirname = self.get_project_name(project, renderer)
102
+ return os.path.join(project.packages_install_path, dest_dirname)
103
+
104
+ def get_subdirectory(self):
105
+ return None
106
+
107
+ def _install(self, project, renderer):
108
+ metadata = self.fetch_metadata(project, renderer)
109
+
110
+ tar_name = f"{self.package}.{self.version}.tar.gz"
111
+ tar_path = (Path(get_downloads_path()) / tar_name).resolve(strict=False)
112
+ system.make_directory(str(tar_path.parent))
113
+
114
+ download_url = metadata.downloads.tarball
115
+ deps_path = project.packages_install_path
116
+ package_name = self.get_project_name(project, renderer)
117
+
118
+ download_untar_fn = functools.partial(
119
+ self.download_and_untar, download_url, str(tar_path), deps_path, package_name
120
+ )
121
+ connection_exception_retry(download_untar_fn, 5)
122
+
123
+ def download_and_untar(self, download_url, tar_path, deps_path, package_name):
124
+ """
125
+ Sometimes the download of the files fails and we want to retry. Sometimes the
126
+ download appears successful but the file did not make it through as expected
127
+ (generally due to a github incident). Either way we want to retry downloading
128
+ and untarring to see if we can get a success. Call this within
129
+ `connection_exception_retry`
130
+ """
131
+
132
+ system.download(download_url, tar_path)
133
+ system.untar_package(tar_path, deps_path, package_name)
134
+
135
+
136
+ SomePinned = TypeVar("SomePinned", bound=PinnedPackage)
137
+ SomeUnpinned = TypeVar("SomeUnpinned", bound="UnpinnedPackage")
138
+
139
+
140
+ class UnpinnedPackage(Generic[SomePinned], BasePackage):
141
+ @classmethod
142
+ @abc.abstractmethod
143
+ def from_contract(cls, contract):
144
+ raise NotImplementedError
145
+
146
+ @abc.abstractmethod
147
+ def incorporate(self: SomeUnpinned, other: SomeUnpinned) -> SomeUnpinned:
148
+ raise NotImplementedError
149
+
150
+ @abc.abstractmethod
151
+ def resolved(self) -> SomePinned:
152
+ raise NotImplementedError
dbt/deps/git.py ADDED
@@ -0,0 +1,195 @@
1
+ import os
2
+ from typing import Dict, List, Optional
3
+
4
+ from dbt.clients import git
5
+ from dbt.config.project import PartialProject, Project
6
+ from dbt.config.renderer import PackageRenderer
7
+ from dbt.contracts.project import GitPackage, ProjectPackageMetadata
8
+ from dbt.deps.base import PinnedPackage, UnpinnedPackage, get_downloads_path
9
+ from dbt.events.types import DepsScrubbedPackageName, DepsUnpinned, EnsureGitInstalled
10
+ from dbt.exceptions import MultipleVersionGitDepsError
11
+ from dbt.utils import md5
12
+ from dbt_common.clients import system
13
+ from dbt_common.events.functions import (
14
+ env_secrets,
15
+ fire_event,
16
+ scrub_secrets,
17
+ warn_or_error,
18
+ )
19
+ from dbt_common.exceptions import ExecutableError
20
+
21
+
22
+ def md5sum(s: str):
23
+ return md5(s, "latin-1")
24
+
25
+
26
+ class GitPackageMixin:
27
+ def __init__(
28
+ self,
29
+ git: str,
30
+ git_unrendered: str,
31
+ subdirectory: Optional[str] = None,
32
+ ) -> None:
33
+ super().__init__()
34
+ self.git = git
35
+ self.git_unrendered = git_unrendered
36
+ self.subdirectory = subdirectory
37
+
38
+ @property
39
+ def name(self):
40
+ return f"{self.git}/{self.subdirectory}" if self.subdirectory else self.git
41
+
42
+ def source_type(self) -> str:
43
+ return "git"
44
+
45
+
46
+ class GitPinnedPackage(GitPackageMixin, PinnedPackage):
47
+ def __init__(
48
+ self,
49
+ git: str,
50
+ git_unrendered: str,
51
+ revision: str,
52
+ warn_unpinned: bool = True,
53
+ subdirectory: Optional[str] = None,
54
+ ) -> None:
55
+ super().__init__(git, git_unrendered, subdirectory)
56
+ self.revision = revision
57
+ self.warn_unpinned = warn_unpinned
58
+ self.subdirectory = subdirectory
59
+ self._checkout_name = md5sum(self.name)
60
+
61
+ def to_dict(self) -> Dict[str, str]:
62
+ git_scrubbed = scrub_secrets(self.git_unrendered, env_secrets())
63
+ if self.git_unrendered != git_scrubbed:
64
+ warn_or_error(DepsScrubbedPackageName(package_name=git_scrubbed))
65
+ ret = {
66
+ "git": git_scrubbed,
67
+ "revision": self.revision,
68
+ }
69
+ if self.subdirectory:
70
+ ret["subdirectory"] = self.subdirectory
71
+ return ret
72
+
73
+ def get_version(self):
74
+ return self.revision
75
+
76
+ def get_subdirectory(self):
77
+ return self.subdirectory
78
+
79
+ def nice_version_name(self):
80
+ if self.revision == "HEAD":
81
+ return "HEAD (default revision)"
82
+ else:
83
+ return "revision {}".format(self.revision)
84
+
85
+ def _checkout(self):
86
+ """Performs a shallow clone of the repository into the downloads
87
+ directory. This function can be called repeatedly. If the project has
88
+ already been checked out at this version, it will be a no-op. Returns
89
+ the path to the checked out directory."""
90
+ try:
91
+ dir_ = git.clone_and_checkout(
92
+ self.git,
93
+ get_downloads_path(),
94
+ revision=self.revision,
95
+ dirname=self._checkout_name,
96
+ subdirectory=self.subdirectory,
97
+ )
98
+ except ExecutableError as exc:
99
+ if exc.cmd and exc.cmd[0] == "git":
100
+ fire_event(EnsureGitInstalled())
101
+ raise
102
+ return os.path.join(get_downloads_path(), dir_)
103
+
104
+ def _fetch_metadata(
105
+ self, project: Project, renderer: PackageRenderer
106
+ ) -> ProjectPackageMetadata:
107
+ path = self._checkout()
108
+
109
+ # raise warning (or error) if this package is not pinned
110
+ if (self.revision == "HEAD" or self.revision in ("main", "master")) and self.warn_unpinned:
111
+ warn_or_error(DepsUnpinned(revision=self.revision, git=self.git))
112
+
113
+ # now overwrite 'revision' with actual commit SHA
114
+ self.revision = git.get_current_sha(path)
115
+
116
+ partial = PartialProject.from_project_root(path)
117
+ return partial.render_package_metadata(renderer)
118
+
119
+ def install(self, project, renderer):
120
+ dest_path = self.get_installation_path(project, renderer)
121
+ if os.path.exists(dest_path):
122
+ if system.path_is_symlink(dest_path):
123
+ system.remove_file(dest_path)
124
+ else:
125
+ system.rmdir(dest_path)
126
+
127
+ system.move(self._checkout(), dest_path)
128
+
129
+
130
+ class GitUnpinnedPackage(GitPackageMixin, UnpinnedPackage[GitPinnedPackage]):
131
+ def __init__(
132
+ self,
133
+ git: str,
134
+ git_unrendered: str,
135
+ revisions: List[str],
136
+ warn_unpinned: bool = True,
137
+ subdirectory: Optional[str] = None,
138
+ ) -> None:
139
+ super().__init__(git, git_unrendered, subdirectory)
140
+ self.revisions = revisions
141
+ self.warn_unpinned = warn_unpinned
142
+ self.subdirectory = subdirectory
143
+
144
+ @classmethod
145
+ def from_contract(cls, contract: GitPackage) -> "GitUnpinnedPackage":
146
+ revisions = contract.get_revisions()
147
+
148
+ # we want to map None -> True
149
+ warn_unpinned = contract.warn_unpinned is not False
150
+ return cls(
151
+ git=contract.git,
152
+ git_unrendered=(contract.unrendered.get("git") or contract.git),
153
+ revisions=revisions,
154
+ warn_unpinned=warn_unpinned,
155
+ subdirectory=contract.subdirectory,
156
+ )
157
+
158
+ def all_names(self) -> List[str]:
159
+ if self.git.endswith(".git"):
160
+ other = self.git[:-4]
161
+ else:
162
+ other = self.git + ".git"
163
+
164
+ if self.subdirectory:
165
+ git_name = f"{self.git}/{self.subdirectory}"
166
+ other = f"{other}/{self.subdirectory}"
167
+ else:
168
+ git_name = self.git
169
+
170
+ return [git_name, other]
171
+
172
+ def incorporate(self, other: "GitUnpinnedPackage") -> "GitUnpinnedPackage":
173
+ warn_unpinned = self.warn_unpinned and other.warn_unpinned
174
+
175
+ return GitUnpinnedPackage(
176
+ git=self.git,
177
+ git_unrendered=self.git_unrendered,
178
+ revisions=self.revisions + other.revisions,
179
+ warn_unpinned=warn_unpinned,
180
+ subdirectory=self.subdirectory,
181
+ )
182
+
183
+ def resolved(self) -> GitPinnedPackage:
184
+ requested = set(self.revisions)
185
+ if len(requested) == 0:
186
+ requested = {"HEAD"}
187
+ elif len(requested) > 1:
188
+ raise MultipleVersionGitDepsError(self.name, requested)
189
+ return GitPinnedPackage(
190
+ git=self.git,
191
+ git_unrendered=self.git_unrendered,
192
+ revision=requested.pop(),
193
+ warn_unpinned=self.warn_unpinned,
194
+ subdirectory=self.subdirectory,
195
+ )