snowflake-cli-labs 2.4.0rc1__py3-none-any.whl → 2.5.0__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 (204) hide show
  1. snowflake/cli/__about__.py +15 -1
  2. snowflake/cli/__init__.py +13 -0
  3. snowflake/cli/api/__init__.py +14 -0
  4. snowflake/cli/api/cli_global_context.py +26 -0
  5. snowflake/cli/api/commands/__init__.py +13 -0
  6. snowflake/cli/api/commands/alias.py +14 -0
  7. snowflake/cli/api/commands/decorators.py +14 -0
  8. snowflake/cli/api/commands/experimental_behaviour.py +14 -0
  9. snowflake/cli/api/commands/flags.py +21 -1
  10. snowflake/cli/api/commands/project_initialisation.py +19 -2
  11. snowflake/cli/api/commands/snow_typer.py +90 -1
  12. snowflake/cli/api/config.py +14 -0
  13. snowflake/cli/api/console/__init__.py +14 -0
  14. snowflake/cli/api/console/abc.py +14 -0
  15. snowflake/cli/api/console/console.py +14 -0
  16. snowflake/cli/api/console/enum.py +14 -0
  17. snowflake/cli/api/constants.py +14 -0
  18. snowflake/cli/api/exceptions.py +22 -0
  19. snowflake/cli/api/feature_flags.py +14 -1
  20. snowflake/cli/api/identifiers.py +16 -2
  21. snowflake/cli/api/output/__init__.py +13 -0
  22. snowflake/cli/api/output/formats.py +14 -0
  23. snowflake/cli/api/output/types.py +14 -0
  24. snowflake/cli/api/plugins/__init__.py +13 -0
  25. snowflake/cli/api/plugins/command/__init__.py +14 -0
  26. snowflake/cli/api/plugins/command/plugin_hook_specs.py +14 -0
  27. snowflake/cli/api/plugins/plugin_config.py +14 -0
  28. snowflake/cli/api/project/__init__.py +13 -0
  29. snowflake/cli/api/project/definition.py +54 -8
  30. snowflake/cli/api/project/definition_manager.py +28 -2
  31. snowflake/cli/api/project/errors.py +14 -0
  32. snowflake/cli/api/project/schemas/__init__.py +13 -0
  33. snowflake/cli/api/project/schemas/identifier_model.py +14 -0
  34. snowflake/cli/api/project/schemas/native_app/__init__.py +13 -0
  35. snowflake/cli/api/project/schemas/native_app/application.py +14 -0
  36. snowflake/cli/api/project/schemas/native_app/native_app.py +35 -0
  37. snowflake/cli/api/project/schemas/native_app/package.py +14 -0
  38. snowflake/cli/api/project/schemas/native_app/path_mapping.py +15 -1
  39. snowflake/cli/api/project/schemas/project_definition.py +14 -0
  40. snowflake/cli/api/project/schemas/snowpark/__init__.py +13 -0
  41. snowflake/cli/api/project/schemas/snowpark/argument.py +14 -0
  42. snowflake/cli/api/project/schemas/snowpark/callable.py +14 -0
  43. snowflake/cli/api/project/schemas/snowpark/snowpark.py +14 -0
  44. snowflake/cli/api/project/schemas/streamlit/__init__.py +13 -0
  45. snowflake/cli/api/project/schemas/streamlit/streamlit.py +14 -0
  46. snowflake/cli/api/project/schemas/updatable_model.py +14 -0
  47. snowflake/cli/api/project/util.py +32 -3
  48. snowflake/cli/api/secure_path.py +59 -7
  49. snowflake/cli/api/secure_utils.py +14 -0
  50. snowflake/cli/api/sql_execution.py +14 -0
  51. snowflake/cli/api/utils/__init__.py +13 -0
  52. snowflake/cli/api/utils/cursor.py +14 -0
  53. snowflake/cli/api/utils/definition_rendering.py +271 -0
  54. snowflake/cli/api/utils/dict_utils.py +73 -0
  55. snowflake/cli/api/utils/error_handling.py +14 -0
  56. snowflake/cli/api/utils/graph.py +97 -0
  57. snowflake/cli/api/utils/models.py +32 -0
  58. snowflake/cli/api/utils/naming_utils.py +13 -0
  59. snowflake/cli/api/utils/path_utils.py +14 -0
  60. snowflake/cli/api/utils/rendering.py +21 -152
  61. snowflake/cli/api/utils/types.py +18 -1
  62. snowflake/cli/app/__init__.py +14 -0
  63. snowflake/cli/app/__main__.py +14 -0
  64. snowflake/cli/app/api_impl/__init__.py +13 -0
  65. snowflake/cli/app/api_impl/plugin/__init__.py +13 -0
  66. snowflake/cli/app/api_impl/plugin/plugin_config_provider_impl.py +14 -0
  67. snowflake/cli/app/cli_app.py +14 -0
  68. snowflake/cli/app/commands_registration/__init__.py +14 -0
  69. snowflake/cli/app/commands_registration/builtin_plugins.py +14 -0
  70. snowflake/cli/app/commands_registration/command_plugins_loader.py +14 -0
  71. snowflake/cli/app/commands_registration/commands_registration_with_callbacks.py +14 -0
  72. snowflake/cli/app/commands_registration/exception_logging.py +14 -0
  73. snowflake/cli/app/commands_registration/threadsafe.py +14 -0
  74. snowflake/cli/app/commands_registration/typer_registration.py +14 -0
  75. snowflake/cli/app/constants.py +14 -1
  76. snowflake/cli/app/dev/__init__.py +13 -0
  77. snowflake/cli/app/dev/commands_structure.py +14 -0
  78. snowflake/cli/app/dev/docs/__init__.py +13 -0
  79. snowflake/cli/app/dev/docs/generator.py +14 -0
  80. snowflake/cli/app/dev/pycharm_remote_debug.py +14 -0
  81. snowflake/cli/app/loggers.py +14 -0
  82. snowflake/cli/app/main_typer.py +14 -0
  83. snowflake/cli/app/printing.py +17 -0
  84. snowflake/cli/app/snow_connector.py +17 -4
  85. snowflake/cli/app/telemetry.py +14 -0
  86. snowflake/cli/plugins/__init__.py +13 -0
  87. snowflake/cli/plugins/connection/__init__.py +13 -0
  88. snowflake/cli/plugins/connection/commands.py +27 -2
  89. snowflake/cli/plugins/connection/plugin_spec.py +15 -1
  90. snowflake/cli/plugins/connection/util.py +21 -1
  91. snowflake/cli/plugins/cortex/__init__.py +13 -0
  92. snowflake/cli/plugins/cortex/commands.py +16 -2
  93. snowflake/cli/plugins/cortex/constants.py +14 -0
  94. snowflake/cli/plugins/cortex/manager.py +14 -0
  95. snowflake/cli/plugins/cortex/plugin_spec.py +15 -1
  96. snowflake/cli/plugins/cortex/types.py +14 -0
  97. snowflake/cli/plugins/git/__init__.py +13 -0
  98. snowflake/cli/plugins/git/commands.py +16 -2
  99. snowflake/cli/plugins/git/manager.py +14 -0
  100. snowflake/cli/plugins/git/plugin_spec.py +15 -1
  101. snowflake/cli/plugins/nativeapp/__init__.py +13 -0
  102. snowflake/cli/plugins/nativeapp/artifacts.py +202 -98
  103. snowflake/cli/plugins/nativeapp/codegen/__init__.py +13 -0
  104. snowflake/cli/plugins/nativeapp/codegen/artifact_processor.py +14 -0
  105. snowflake/cli/plugins/nativeapp/codegen/compiler.py +14 -0
  106. snowflake/cli/plugins/nativeapp/codegen/sandbox.py +14 -0
  107. snowflake/cli/plugins/nativeapp/codegen/snowpark/callback_source.py.jinja +5 -5
  108. snowflake/cli/plugins/nativeapp/codegen/snowpark/extension_function_utils.py +34 -13
  109. snowflake/cli/plugins/nativeapp/codegen/snowpark/models.py +14 -0
  110. snowflake/cli/plugins/nativeapp/codegen/snowpark/python_processor.py +52 -13
  111. snowflake/cli/plugins/nativeapp/commands.py +63 -10
  112. snowflake/cli/plugins/nativeapp/common_flags.py +20 -0
  113. snowflake/cli/plugins/nativeapp/constants.py +15 -0
  114. snowflake/cli/plugins/nativeapp/exceptions.py +23 -2
  115. snowflake/cli/plugins/nativeapp/init.py +14 -0
  116. snowflake/cli/plugins/nativeapp/manager.py +118 -25
  117. snowflake/cli/plugins/nativeapp/plugin_spec.py +15 -1
  118. snowflake/cli/plugins/nativeapp/policy.py +14 -0
  119. snowflake/cli/plugins/nativeapp/run_processor.py +22 -3
  120. snowflake/cli/plugins/nativeapp/teardown_processor.py +14 -0
  121. snowflake/cli/plugins/nativeapp/utils.py +14 -0
  122. snowflake/cli/plugins/nativeapp/version/__init__.py +13 -0
  123. snowflake/cli/plugins/nativeapp/version/commands.py +19 -4
  124. snowflake/cli/plugins/nativeapp/version/version_processor.py +26 -4
  125. snowflake/cli/plugins/notebook/__init__.py +13 -0
  126. snowflake/cli/plugins/notebook/commands.py +16 -4
  127. snowflake/cli/plugins/notebook/exceptions.py +14 -0
  128. snowflake/cli/plugins/notebook/manager.py +14 -0
  129. snowflake/cli/plugins/notebook/plugin_spec.py +15 -1
  130. snowflake/cli/plugins/notebook/types.py +14 -0
  131. snowflake/cli/plugins/object/__init__.py +13 -11
  132. snowflake/cli/plugins/object/command_aliases.py +20 -6
  133. snowflake/cli/plugins/object/commands.py +16 -2
  134. snowflake/cli/plugins/object/common.py +14 -0
  135. snowflake/cli/plugins/object/manager.py +14 -0
  136. snowflake/cli/plugins/object/plugin_spec.py +16 -2
  137. snowflake/cli/plugins/object_stage_deprecated/__init__.py +14 -0
  138. snowflake/cli/plugins/object_stage_deprecated/commands.py +16 -2
  139. snowflake/cli/plugins/object_stage_deprecated/plugin_spec.py +16 -4
  140. snowflake/cli/plugins/snowpark/__init__.py +13 -4
  141. snowflake/cli/plugins/snowpark/commands.py +18 -2
  142. snowflake/cli/plugins/snowpark/common.py +15 -0
  143. snowflake/cli/plugins/snowpark/manager.py +14 -0
  144. snowflake/cli/plugins/snowpark/models.py +15 -1
  145. snowflake/cli/plugins/snowpark/package/__init__.py +13 -0
  146. snowflake/cli/plugins/snowpark/package/anaconda_packages.py +14 -0
  147. snowflake/cli/plugins/snowpark/package/commands.py +16 -2
  148. snowflake/cli/plugins/snowpark/package/manager.py +14 -0
  149. snowflake/cli/plugins/snowpark/package/utils.py +14 -0
  150. snowflake/cli/plugins/snowpark/package_utils.py +15 -1
  151. snowflake/cli/plugins/snowpark/plugin_spec.py +16 -2
  152. snowflake/cli/plugins/snowpark/snowpark_package_paths.py +14 -0
  153. snowflake/cli/plugins/snowpark/snowpark_shared.py +14 -0
  154. snowflake/cli/plugins/snowpark/zipper.py +20 -3
  155. snowflake/cli/plugins/spcs/__init__.py +16 -2
  156. snowflake/cli/plugins/spcs/common.py +14 -0
  157. snowflake/cli/plugins/spcs/compute_pool/__init__.py +13 -0
  158. snowflake/cli/plugins/spcs/compute_pool/commands.py +16 -2
  159. snowflake/cli/plugins/spcs/compute_pool/manager.py +14 -0
  160. snowflake/cli/plugins/spcs/image_registry/__init__.py +13 -0
  161. snowflake/cli/plugins/spcs/image_registry/commands.py +16 -2
  162. snowflake/cli/plugins/spcs/image_registry/manager.py +16 -0
  163. snowflake/cli/plugins/spcs/image_repository/__init__.py +13 -0
  164. snowflake/cli/plugins/spcs/image_repository/commands.py +16 -2
  165. snowflake/cli/plugins/spcs/image_repository/manager.py +14 -0
  166. snowflake/cli/plugins/spcs/jobs/__init__.py +13 -0
  167. snowflake/cli/plugins/spcs/jobs/commands.py +17 -3
  168. snowflake/cli/plugins/spcs/jobs/manager.py +14 -0
  169. snowflake/cli/plugins/spcs/plugin_spec.py +15 -1
  170. snowflake/cli/plugins/spcs/services/__init__.py +13 -0
  171. snowflake/cli/plugins/spcs/services/commands.py +16 -2
  172. snowflake/cli/plugins/spcs/services/manager.py +14 -0
  173. snowflake/cli/plugins/sql/__init__.py +13 -0
  174. snowflake/cli/plugins/sql/commands.py +16 -2
  175. snowflake/cli/plugins/sql/manager.py +14 -0
  176. snowflake/cli/plugins/sql/plugin_spec.py +15 -1
  177. snowflake/cli/plugins/sql/snowsql_templating.py +14 -0
  178. snowflake/cli/plugins/stage/__init__.py +13 -0
  179. snowflake/cli/plugins/stage/commands.py +17 -3
  180. snowflake/cli/plugins/stage/diff.py +14 -0
  181. snowflake/cli/plugins/stage/manager.py +16 -5
  182. snowflake/cli/plugins/stage/plugin_spec.py +16 -2
  183. snowflake/cli/plugins/streamlit/__init__.py +13 -0
  184. snowflake/cli/plugins/streamlit/commands.py +16 -2
  185. snowflake/cli/plugins/streamlit/manager.py +14 -0
  186. snowflake/cli/plugins/streamlit/plugin_spec.py +15 -1
  187. snowflake/cli/templates/default_snowpark/app/__init__.py +13 -0
  188. snowflake/cli/templates/default_snowpark/app/common.py +15 -0
  189. snowflake/cli/templates/default_snowpark/app/functions.py +14 -0
  190. snowflake/cli/templates/default_snowpark/app/procedures.py +14 -0
  191. snowflake/cli/templates/default_snowpark/snowflake.yml +1 -1
  192. snowflake/cli/templates/default_streamlit/common/hello.py +15 -0
  193. snowflake/cli/templates/default_streamlit/pages/my_page.py +14 -0
  194. snowflake/cli/templates/default_streamlit/snowflake.yml +1 -1
  195. snowflake/cli/templates/default_streamlit/streamlit_app.py +14 -0
  196. {snowflake_cli_labs-2.4.0rc1.dist-info → snowflake_cli_labs-2.5.0.dist-info}/METADATA +23 -7
  197. snowflake_cli_labs-2.5.0.dist-info/RECORD +206 -0
  198. snowflake/cli/plugins/nativeapp/feature_flags.py +0 -10
  199. snowflake/cli/templates/environment.yml.jinja +0 -5
  200. snowflake/cli/templates/streamlit_app_launcher.py.jinja +0 -19
  201. snowflake_cli_labs-2.4.0rc1.dist-info/RECORD +0 -206
  202. {snowflake_cli_labs-2.4.0rc1.dist-info → snowflake_cli_labs-2.5.0.dist-info}/WHEEL +0 -0
  203. {snowflake_cli_labs-2.4.0rc1.dist-info → snowflake_cli_labs-2.5.0.dist-info}/entry_points.txt +0 -0
  204. {snowflake_cli_labs-2.4.0rc1.dist-info → snowflake_cli_labs-2.5.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,13 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
@@ -1,3 +1,17 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from __future__ import annotations
2
16
 
3
17
  import sys
@@ -1,22 +1,30 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from __future__ import annotations
2
16
 
3
- import re
4
- from collections import defaultdict, deque
5
17
  from pathlib import Path
6
18
  from textwrap import dedent
7
- from typing import Dict, List, Optional, Set, cast
19
+ from typing import Dict, Optional
8
20
 
9
21
  import jinja2
10
22
  from click import ClickException
11
- from jinja2 import Environment, StrictUndefined, UndefinedError, loaders
23
+ from jinja2 import Environment, StrictUndefined, loaders
12
24
  from snowflake.cli.api.cli_global_context import cli_context
13
- from snowflake.cli.api.project.schemas.project_definition import (
14
- ProjectDefinition,
15
- )
16
25
  from snowflake.cli.api.secure_path import UNLIMITED, SecurePath
17
- from snowflake.cli.api.utils.models import EnvironWithDefinedDictFallback
18
26
 
19
- _CONTEXT_KEY = "ctx"
27
+ CONTEXT_KEY = "ctx"
20
28
  _YML_TEMPLATE_START = "<%"
21
29
  _YML_TEMPLATE_END = "%>"
22
30
 
@@ -55,7 +63,7 @@ def _env_bootstrap(env: Environment) -> Environment:
55
63
  return env
56
64
 
57
65
 
58
- def get_snowflake_cli_jinja_env():
66
+ def get_snowflake_cli_jinja_env() -> Environment:
59
67
  _random_block = "___very___unique___block___to___disable___logic___blocks___"
60
68
  return _env_bootstrap(
61
69
  Environment(
@@ -115,152 +123,13 @@ def jinja_render_from_file(
115
123
  return rendered_result
116
124
 
117
125
 
118
- def _add_project_context(project_definition: ProjectDefinition) -> Dict:
119
- """
120
- Updates the external data with variables from snowflake.yml definition file.
121
- """
122
- context_data = _resolve_variables_in_project(project_definition)
123
- return context_data
124
-
125
-
126
- def _remove_ctx_env_prefix(text: str) -> str:
127
- prefix = "ctx.env."
128
- if text.startswith(prefix):
129
- return text[len(prefix) :]
130
- return text
131
-
132
-
133
- def string_includes_template(text: str) -> bool:
134
- return bool(re.search(rf"{_YML_TEMPLATE_START}.+{_YML_TEMPLATE_END}", text))
135
-
136
-
137
- def _resolve_variables_in_project(project_definition: ProjectDefinition):
138
- # If there's project definition file then resolve variables from it
139
- if not project_definition or not project_definition.meets_version_requirement(
140
- "1.1"
141
- ):
142
- return {_CONTEXT_KEY: {"env": EnvironWithDefinedDictFallback({})}}
143
-
144
- variables_data: EnvironWithDefinedDictFallback = cast(
145
- EnvironWithDefinedDictFallback, project_definition.env
146
- )
147
-
148
- env_with_unresolved_keys: List[str] = _get_variables_with_dependencies(
149
- variables_data
150
- )
151
- other_env = set(variables_data) - set(env_with_unresolved_keys)
152
- env = get_snowflake_cli_jinja_env()
153
- context_data = {_CONTEXT_KEY: project_definition}
154
-
155
- # Resolve env section dependencies
156
- while env_with_unresolved_keys:
157
- key = env_with_unresolved_keys.pop()
158
- value = variables_data[key]
159
- if not isinstance(value, str):
160
- continue
161
- try: # try to evaluate the template given current state of know variables
162
- variables_data[key] = env.from_string(value).render(context_data)
163
- if string_includes_template(variables_data[key]):
164
- env_with_unresolved_keys.append(key)
165
- except UndefinedError:
166
- env_with_unresolved_keys.append(key)
167
-
168
- # Resolve templates in variables without references, for example
169
- for key in other_env:
170
- variable_value = variables_data[key]
171
- if not isinstance(variable_value, str):
172
- continue
173
- variables_data[key] = env.from_string(variable_value).render(context_data)
174
-
175
- return context_data
176
-
177
-
178
- def _check_for_cycles(nodes: defaultdict):
179
- nodes = nodes.copy()
180
- for key in list(nodes):
181
- q = deque([key])
182
- visited: List[str] = []
183
- while q:
184
- curr = q.popleft()
185
- if curr in visited:
186
- raise ClickException(
187
- "Cycle detected between variables: {}".format(" -> ".join(visited))
188
- )
189
- # Only nodes that have references can cause cycles
190
- if curr in nodes:
191
- visited.append(curr)
192
- q.extendleft(nodes[curr])
193
-
194
-
195
- def _get_variables_with_dependencies(variables_data: EnvironWithDefinedDictFallback):
196
- """
197
- Checks consistency of provided dictionary by
198
- 1. checking reference cycles
199
- 2. checking for missing variables
200
- """
201
- # Variables that are not specified in env section
202
- missing_variables: Set[str] = set()
203
- # Variables that require other variables
204
- variables_with_dependencies = defaultdict(list)
205
-
206
- for key, value in variables_data.items():
207
- # Templates are reserved only to string variables
208
- if not isinstance(value, str):
209
- continue
210
-
211
- required_variables = _search_for_required_variables(value)
212
-
213
- if required_variables:
214
- variables_with_dependencies[key] = required_variables
215
-
216
- for variable in required_variables:
217
- if variable not in variables_data:
218
- missing_variables.add(variable)
219
-
220
- # If there are unknown env variables then we raise an error
221
- if missing_variables:
222
- raise ClickException(
223
- "The following variables are used in environment definition but are not defined: {}".format(
224
- ", ".join(missing_variables)
225
- )
226
- )
227
-
228
- # Look for cycles between variables
229
- _check_for_cycles(variables_with_dependencies)
230
-
231
- # Sort by number of dependencies
232
- return sorted(
233
- list(variables_with_dependencies.keys()),
234
- key=lambda k: len(variables_with_dependencies[k]),
235
- )
236
-
237
-
238
- def _search_for_required_variables(variable_value: str):
239
- """
240
- Look for pattern in variable value. Returns a list of env variables required
241
- to expand this template.`
242
- """
243
- ctx_env_prefix = f"{_CONTEXT_KEY}.env."
244
- found_variables = re.findall(
245
- rf"({_YML_TEMPLATE_START}([\.\w ]+){_YML_TEMPLATE_END})+", variable_value
246
- )
247
- required_variables = []
248
- for _, variable in found_variables:
249
- var: str = variable.strip()
250
- if var.startswith(ctx_env_prefix):
251
- required_variables.append(var[len(ctx_env_prefix) :])
252
- return required_variables
253
-
254
-
255
126
  def snowflake_sql_jinja_render(content: str, data: Dict | None = None) -> str:
256
127
  data = data or {}
257
- if _CONTEXT_KEY in data:
128
+ if CONTEXT_KEY in data:
258
129
  raise ClickException(
259
- f"{_CONTEXT_KEY} in user defined data. The `{_CONTEXT_KEY}` variable is reserved for CLI usage."
130
+ f"{CONTEXT_KEY} in user defined data. The `{CONTEXT_KEY}` variable is reserved for CLI usage."
260
131
  )
261
132
 
262
- context_data = _add_project_context(
263
- project_definition=cli_context.project_definition
264
- )
133
+ context_data = cli_context.template_context
265
134
  context_data.update(data)
266
135
  return get_sql_cli_jinja_env().from_string(content).render(**context_data)
@@ -1,6 +1,23 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from __future__ import annotations
2
16
 
3
- from typing import Any
17
+ from typing import Any, Dict
18
+
19
+ Context = Dict[str, Any]
20
+ Definition = Dict[str, Any]
4
21
 
5
22
 
6
23
  def try_cast_to_bool(value: Any) -> bool:
@@ -1,3 +1,17 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  import logging
2
16
  import os
3
17
 
@@ -1,3 +1,17 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from __future__ import annotations
2
16
 
3
17
  import sys
@@ -0,0 +1,13 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
@@ -0,0 +1,13 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
@@ -1,3 +1,17 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from __future__ import annotations
2
16
 
3
17
  from typing import List
@@ -1,3 +1,17 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from __future__ import annotations
2
16
 
3
17
  import logging
@@ -1,3 +1,17 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from dataclasses import dataclass
2
16
 
3
17
  from snowflake.cli.api.plugins.command import CommandSpec
@@ -1,3 +1,17 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from snowflake.cli.plugins.connection import plugin_spec as connection_plugin_spec
2
16
  from snowflake.cli.plugins.cortex import plugin_spec as cortex_plugin_spec
3
17
  from snowflake.cli.plugins.git import plugin_spec as git_plugin_spec
@@ -1,3 +1,17 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from __future__ import annotations
2
16
 
3
17
  import logging
@@ -1,3 +1,17 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from __future__ import annotations
2
16
 
3
17
  from dataclasses import dataclass
@@ -1,3 +1,17 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from logging import Logger
2
16
  from typing import Callable
3
17
 
@@ -1,3 +1,17 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from __future__ import annotations
2
16
 
3
17
  import threading
@@ -1,3 +1,17 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from __future__ import annotations
2
16
 
3
17
  import logging
@@ -1,6 +1,19 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from __future__ import annotations
2
16
 
3
17
  from typing import Literal
4
18
 
5
19
  PARAM_APPLICATION_NAME: Literal["snowcli"] = "snowcli"
6
- PARAM_INTERNAL_APPLICATION_NAME: Literal["snowcli"] = "snowcli"
@@ -0,0 +1,13 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
@@ -1,3 +1,17 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from __future__ import annotations
2
16
 
3
17
  from dataclasses import dataclass, field
@@ -0,0 +1,13 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
@@ -1,3 +1,17 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from __future__ import annotations
2
16
 
3
17
  import logging
@@ -1,3 +1,17 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from __future__ import annotations
2
16
 
3
17
  from typing import Optional
@@ -1,3 +1,17 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from __future__ import annotations
2
16
 
3
17
  import logging
@@ -1,3 +1,17 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from __future__ import annotations
2
16
 
3
17
  import sys
@@ -1,3 +1,17 @@
1
+ # Copyright (c) 2024 Snowflake Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  from __future__ import annotations
2
16
 
3
17
  import json
@@ -28,6 +42,9 @@ NO_ITEMS_FOUND: str = "No data"
28
42
  # ensure we do not break URLs that wrap lines
29
43
  get_console().soft_wrap = True
30
44
 
45
+ # Disable markup to avoid escaping errors
46
+ get_console()._markup = False # noqa: SLF001
47
+
31
48
 
32
49
  class CustomJSONEncoder(JSONEncoder):
33
50
  """Custom JSON encoder handling serialization of non-standard types"""