snowflake-cli-labs 3.0.0rc5__py3-none-any.whl → 3.0.2__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 (244) hide show
  1. README.md +21 -0
  2. {snowflake_cli_labs-3.0.0rc5.dist-info → snowflake_cli_labs-3.0.2.dist-info}/METADATA +6 -96
  3. snowflake_cli_labs-3.0.2.dist-info/RECORD +5 -0
  4. snowflake/cli/__about__.py +0 -17
  5. snowflake/cli/__init__.py +0 -13
  6. snowflake/cli/_app/__init__.py +0 -22
  7. snowflake/cli/_app/__main__.py +0 -31
  8. snowflake/cli/_app/api_impl/__init__.py +0 -13
  9. snowflake/cli/_app/api_impl/plugin/__init__.py +0 -13
  10. snowflake/cli/_app/api_impl/plugin/plugin_config_provider_impl.py +0 -66
  11. snowflake/cli/_app/cli_app.py +0 -252
  12. snowflake/cli/_app/commands_registration/__init__.py +0 -33
  13. snowflake/cli/_app/commands_registration/builtin_plugins.py +0 -50
  14. snowflake/cli/_app/commands_registration/command_plugins_loader.py +0 -169
  15. snowflake/cli/_app/commands_registration/commands_registration_with_callbacks.py +0 -105
  16. snowflake/cli/_app/commands_registration/exception_logging.py +0 -26
  17. snowflake/cli/_app/commands_registration/threadsafe.py +0 -48
  18. snowflake/cli/_app/commands_registration/typer_registration.py +0 -153
  19. snowflake/cli/_app/constants.py +0 -19
  20. snowflake/cli/_app/dev/__init__.py +0 -13
  21. snowflake/cli/_app/dev/commands_structure.py +0 -48
  22. snowflake/cli/_app/dev/docs/__init__.py +0 -13
  23. snowflake/cli/_app/dev/docs/commands_docs_generator.py +0 -118
  24. snowflake/cli/_app/dev/docs/generator.py +0 -35
  25. snowflake/cli/_app/dev/docs/project_definition_docs_generator.py +0 -58
  26. snowflake/cli/_app/dev/docs/project_definition_generate_json_schema.py +0 -227
  27. snowflake/cli/_app/dev/docs/template_utils.py +0 -23
  28. snowflake/cli/_app/dev/docs/templates/definition_description.rst.jinja2 +0 -38
  29. snowflake/cli/_app/dev/docs/templates/overview.rst.jinja2 +0 -9
  30. snowflake/cli/_app/dev/docs/templates/usage.rst.jinja2 +0 -67
  31. snowflake/cli/_app/dev/pycharm_remote_debug.py +0 -46
  32. snowflake/cli/_app/loggers.py +0 -199
  33. snowflake/cli/_app/main_typer.py +0 -62
  34. snowflake/cli/_app/printing.py +0 -181
  35. snowflake/cli/_app/secret.py +0 -9
  36. snowflake/cli/_app/snow_connector.py +0 -309
  37. snowflake/cli/_app/telemetry.py +0 -220
  38. snowflake/cli/_app/version_check.py +0 -74
  39. snowflake/cli/_plugins/__init__.py +0 -13
  40. snowflake/cli/_plugins/connection/__init__.py +0 -13
  41. snowflake/cli/_plugins/connection/commands.py +0 -353
  42. snowflake/cli/_plugins/connection/plugin_spec.py +0 -30
  43. snowflake/cli/_plugins/connection/util.py +0 -195
  44. snowflake/cli/_plugins/cortex/__init__.py +0 -13
  45. snowflake/cli/_plugins/cortex/commands.py +0 -332
  46. snowflake/cli/_plugins/cortex/constants.py +0 -17
  47. snowflake/cli/_plugins/cortex/manager.py +0 -189
  48. snowflake/cli/_plugins/cortex/plugin_spec.py +0 -30
  49. snowflake/cli/_plugins/cortex/types.py +0 -22
  50. snowflake/cli/_plugins/git/__init__.py +0 -13
  51. snowflake/cli/_plugins/git/commands.py +0 -358
  52. snowflake/cli/_plugins/git/manager.py +0 -151
  53. snowflake/cli/_plugins/git/plugin_spec.py +0 -30
  54. snowflake/cli/_plugins/helpers/__init__.py +0 -13
  55. snowflake/cli/_plugins/helpers/commands.py +0 -90
  56. snowflake/cli/_plugins/helpers/plugin_spec.py +0 -30
  57. snowflake/cli/_plugins/init/__init__.py +0 -13
  58. snowflake/cli/_plugins/init/commands.py +0 -248
  59. snowflake/cli/_plugins/init/plugin_spec.py +0 -30
  60. snowflake/cli/_plugins/nativeapp/__init__.py +0 -13
  61. snowflake/cli/_plugins/nativeapp/artifacts.py +0 -757
  62. snowflake/cli/_plugins/nativeapp/bundle_context.py +0 -31
  63. snowflake/cli/_plugins/nativeapp/codegen/__init__.py +0 -13
  64. snowflake/cli/_plugins/nativeapp/codegen/artifact_processor.py +0 -91
  65. snowflake/cli/_plugins/nativeapp/codegen/compiler.py +0 -149
  66. snowflake/cli/_plugins/nativeapp/codegen/sandbox.py +0 -306
  67. snowflake/cli/_plugins/nativeapp/codegen/setup/native_app_setup_processor.py +0 -249
  68. snowflake/cli/_plugins/nativeapp/codegen/setup/setup_driver.py.source +0 -59
  69. snowflake/cli/_plugins/nativeapp/codegen/snowpark/callback_source.py.jinja +0 -181
  70. snowflake/cli/_plugins/nativeapp/codegen/snowpark/extension_function_utils.py +0 -217
  71. snowflake/cli/_plugins/nativeapp/codegen/snowpark/models.py +0 -61
  72. snowflake/cli/_plugins/nativeapp/codegen/snowpark/python_processor.py +0 -523
  73. snowflake/cli/_plugins/nativeapp/codegen/templates/templates_processor.py +0 -114
  74. snowflake/cli/_plugins/nativeapp/commands.py +0 -559
  75. snowflake/cli/_plugins/nativeapp/common_flags.py +0 -44
  76. snowflake/cli/_plugins/nativeapp/constants.py +0 -27
  77. snowflake/cli/_plugins/nativeapp/entities/__init__.py +0 -0
  78. snowflake/cli/_plugins/nativeapp/entities/application.py +0 -878
  79. snowflake/cli/_plugins/nativeapp/entities/application_package.py +0 -1392
  80. snowflake/cli/_plugins/nativeapp/exceptions.py +0 -113
  81. snowflake/cli/_plugins/nativeapp/feature_flags.py +0 -24
  82. snowflake/cli/_plugins/nativeapp/manager.py +0 -415
  83. snowflake/cli/_plugins/nativeapp/plugin_spec.py +0 -30
  84. snowflake/cli/_plugins/nativeapp/policy.py +0 -53
  85. snowflake/cli/_plugins/nativeapp/project_model.py +0 -211
  86. snowflake/cli/_plugins/nativeapp/run_processor.py +0 -184
  87. snowflake/cli/_plugins/nativeapp/same_account_install_method.py +0 -70
  88. snowflake/cli/_plugins/nativeapp/teardown_processor.py +0 -70
  89. snowflake/cli/_plugins/nativeapp/utils.py +0 -98
  90. snowflake/cli/_plugins/nativeapp/v2_conversions/v2_to_v1_decorator.py +0 -262
  91. snowflake/cli/_plugins/nativeapp/version/__init__.py +0 -13
  92. snowflake/cli/_plugins/nativeapp/version/commands.py +0 -141
  93. snowflake/cli/_plugins/nativeapp/version/version_processor.py +0 -98
  94. snowflake/cli/_plugins/notebook/__init__.py +0 -13
  95. snowflake/cli/_plugins/notebook/commands.py +0 -86
  96. snowflake/cli/_plugins/notebook/exceptions.py +0 -20
  97. snowflake/cli/_plugins/notebook/manager.py +0 -71
  98. snowflake/cli/_plugins/notebook/plugin_spec.py +0 -30
  99. snowflake/cli/_plugins/notebook/types.py +0 -15
  100. snowflake/cli/_plugins/object/__init__.py +0 -13
  101. snowflake/cli/_plugins/object/command_aliases.py +0 -95
  102. snowflake/cli/_plugins/object/commands.py +0 -180
  103. snowflake/cli/_plugins/object/common.py +0 -85
  104. snowflake/cli/_plugins/object/manager.py +0 -118
  105. snowflake/cli/_plugins/object/plugin_spec.py +0 -30
  106. snowflake/cli/_plugins/snowpark/__init__.py +0 -13
  107. snowflake/cli/_plugins/snowpark/commands.py +0 -450
  108. snowflake/cli/_plugins/snowpark/common.py +0 -268
  109. snowflake/cli/_plugins/snowpark/models.py +0 -150
  110. snowflake/cli/_plugins/snowpark/package/__init__.py +0 -13
  111. snowflake/cli/_plugins/snowpark/package/anaconda_packages.py +0 -199
  112. snowflake/cli/_plugins/snowpark/package/commands.py +0 -195
  113. snowflake/cli/_plugins/snowpark/package/manager.py +0 -44
  114. snowflake/cli/_plugins/snowpark/package/utils.py +0 -26
  115. snowflake/cli/_plugins/snowpark/package_utils.py +0 -354
  116. snowflake/cli/_plugins/snowpark/plugin_spec.py +0 -30
  117. snowflake/cli/_plugins/snowpark/snowpark_entity.py +0 -29
  118. snowflake/cli/_plugins/snowpark/snowpark_entity_model.py +0 -173
  119. snowflake/cli/_plugins/snowpark/snowpark_project_paths.py +0 -109
  120. snowflake/cli/_plugins/snowpark/snowpark_shared.py +0 -59
  121. snowflake/cli/_plugins/snowpark/zipper.py +0 -89
  122. snowflake/cli/_plugins/spcs/__init__.py +0 -33
  123. snowflake/cli/_plugins/spcs/common.py +0 -99
  124. snowflake/cli/_plugins/spcs/compute_pool/__init__.py +0 -13
  125. snowflake/cli/_plugins/spcs/compute_pool/commands.py +0 -241
  126. snowflake/cli/_plugins/spcs/compute_pool/manager.py +0 -121
  127. snowflake/cli/_plugins/spcs/image_registry/__init__.py +0 -13
  128. snowflake/cli/_plugins/spcs/image_registry/commands.py +0 -65
  129. snowflake/cli/_plugins/spcs/image_registry/manager.py +0 -105
  130. snowflake/cli/_plugins/spcs/image_repository/__init__.py +0 -13
  131. snowflake/cli/_plugins/spcs/image_repository/commands.py +0 -202
  132. snowflake/cli/_plugins/spcs/image_repository/manager.py +0 -84
  133. snowflake/cli/_plugins/spcs/plugin_spec.py +0 -30
  134. snowflake/cli/_plugins/spcs/services/__init__.py +0 -13
  135. snowflake/cli/_plugins/spcs/services/commands.py +0 -345
  136. snowflake/cli/_plugins/spcs/services/manager.py +0 -208
  137. snowflake/cli/_plugins/sql/__init__.py +0 -13
  138. snowflake/cli/_plugins/sql/commands.py +0 -86
  139. snowflake/cli/_plugins/sql/manager.py +0 -92
  140. snowflake/cli/_plugins/sql/plugin_spec.py +0 -30
  141. snowflake/cli/_plugins/sql/snowsql_templating.py +0 -28
  142. snowflake/cli/_plugins/stage/__init__.py +0 -13
  143. snowflake/cli/_plugins/stage/commands.py +0 -264
  144. snowflake/cli/_plugins/stage/diff.py +0 -280
  145. snowflake/cli/_plugins/stage/manager.py +0 -582
  146. snowflake/cli/_plugins/stage/md5.py +0 -160
  147. snowflake/cli/_plugins/stage/plugin_spec.py +0 -30
  148. snowflake/cli/_plugins/stage/utils.py +0 -54
  149. snowflake/cli/_plugins/streamlit/__init__.py +0 -13
  150. snowflake/cli/_plugins/streamlit/commands.py +0 -195
  151. snowflake/cli/_plugins/streamlit/manager.py +0 -220
  152. snowflake/cli/_plugins/streamlit/plugin_spec.py +0 -30
  153. snowflake/cli/_plugins/streamlit/streamlit_entity.py +0 -12
  154. snowflake/cli/_plugins/streamlit/streamlit_entity_model.py +0 -66
  155. snowflake/cli/_plugins/workspace/__init__.py +0 -13
  156. snowflake/cli/_plugins/workspace/action_context.py +0 -18
  157. snowflake/cli/_plugins/workspace/commands.py +0 -306
  158. snowflake/cli/_plugins/workspace/manager.py +0 -74
  159. snowflake/cli/_plugins/workspace/plugin_spec.py +0 -30
  160. snowflake/cli/api/__init__.py +0 -48
  161. snowflake/cli/api/cli_global_context.py +0 -247
  162. snowflake/cli/api/commands/__init__.py +0 -13
  163. snowflake/cli/api/commands/alias.py +0 -23
  164. snowflake/cli/api/commands/common.py +0 -25
  165. snowflake/cli/api/commands/decorators.py +0 -369
  166. snowflake/cli/api/commands/execution_metadata.py +0 -40
  167. snowflake/cli/api/commands/experimental_behaviour.py +0 -18
  168. snowflake/cli/api/commands/flags.py +0 -561
  169. snowflake/cli/api/commands/overrideable_parameter.py +0 -143
  170. snowflake/cli/api/commands/snow_typer.py +0 -247
  171. snowflake/cli/api/commands/utils.py +0 -18
  172. snowflake/cli/api/config.py +0 -380
  173. snowflake/cli/api/connections.py +0 -216
  174. snowflake/cli/api/console/__init__.py +0 -17
  175. snowflake/cli/api/console/abc.py +0 -94
  176. snowflake/cli/api/console/console.py +0 -134
  177. snowflake/cli/api/console/enum.py +0 -17
  178. snowflake/cli/api/constants.py +0 -90
  179. snowflake/cli/api/entities/common.py +0 -56
  180. snowflake/cli/api/entities/utils.py +0 -370
  181. snowflake/cli/api/errno.py +0 -28
  182. snowflake/cli/api/exceptions.py +0 -190
  183. snowflake/cli/api/feature_flags.py +0 -54
  184. snowflake/cli/api/identifiers.py +0 -190
  185. snowflake/cli/api/metrics.py +0 -92
  186. snowflake/cli/api/output/__init__.py +0 -13
  187. snowflake/cli/api/output/formats.py +0 -20
  188. snowflake/cli/api/output/types.py +0 -118
  189. snowflake/cli/api/plugins/__init__.py +0 -13
  190. snowflake/cli/api/plugins/command/__init__.py +0 -72
  191. snowflake/cli/api/plugins/command/plugin_hook_specs.py +0 -21
  192. snowflake/cli/api/plugins/plugin_config.py +0 -32
  193. snowflake/cli/api/project/__init__.py +0 -13
  194. snowflake/cli/api/project/definition.py +0 -126
  195. snowflake/cli/api/project/definition_conversion.py +0 -400
  196. snowflake/cli/api/project/definition_manager.py +0 -145
  197. snowflake/cli/api/project/errors.py +0 -56
  198. snowflake/cli/api/project/project_verification.py +0 -23
  199. snowflake/cli/api/project/schemas/__init__.py +0 -13
  200. snowflake/cli/api/project/schemas/entities/__init__.py +0 -13
  201. snowflake/cli/api/project/schemas/entities/common.py +0 -153
  202. snowflake/cli/api/project/schemas/entities/entities.py +0 -61
  203. snowflake/cli/api/project/schemas/project_definition.py +0 -330
  204. snowflake/cli/api/project/schemas/template.py +0 -77
  205. snowflake/cli/api/project/schemas/updatable_model.py +0 -202
  206. snowflake/cli/api/project/schemas/v1/__init__.py +0 -0
  207. snowflake/cli/api/project/schemas/v1/identifier_model.py +0 -51
  208. snowflake/cli/api/project/schemas/v1/native_app/__init__.py +0 -0
  209. snowflake/cli/api/project/schemas/v1/native_app/application.py +0 -61
  210. snowflake/cli/api/project/schemas/v1/native_app/native_app.py +0 -93
  211. snowflake/cli/api/project/schemas/v1/native_app/package.py +0 -84
  212. snowflake/cli/api/project/schemas/v1/native_app/path_mapping.py +0 -65
  213. snowflake/cli/api/project/schemas/v1/snowpark/__init__.py +0 -0
  214. snowflake/cli/api/project/schemas/v1/snowpark/argument.py +0 -28
  215. snowflake/cli/api/project/schemas/v1/snowpark/callable.py +0 -69
  216. snowflake/cli/api/project/schemas/v1/snowpark/snowpark.py +0 -36
  217. snowflake/cli/api/project/schemas/v1/streamlit/__init__.py +0 -0
  218. snowflake/cli/api/project/schemas/v1/streamlit/streamlit.py +0 -47
  219. snowflake/cli/api/project/util.py +0 -278
  220. snowflake/cli/api/rendering/__init__.py +0 -13
  221. snowflake/cli/api/rendering/jinja.py +0 -118
  222. snowflake/cli/api/rendering/project_definition_templates.py +0 -43
  223. snowflake/cli/api/rendering/project_templates.py +0 -98
  224. snowflake/cli/api/rendering/sql_templates.py +0 -105
  225. snowflake/cli/api/rest_api.py +0 -178
  226. snowflake/cli/api/sanitizers.py +0 -43
  227. snowflake/cli/api/secure_path.py +0 -360
  228. snowflake/cli/api/secure_utils.py +0 -118
  229. snowflake/cli/api/sql_execution.py +0 -280
  230. snowflake/cli/api/utils/__init__.py +0 -13
  231. snowflake/cli/api/utils/cursor.py +0 -34
  232. snowflake/cli/api/utils/definition_rendering.py +0 -415
  233. snowflake/cli/api/utils/dict_utils.py +0 -73
  234. snowflake/cli/api/utils/error_handling.py +0 -23
  235. snowflake/cli/api/utils/graph.py +0 -97
  236. snowflake/cli/api/utils/models.py +0 -63
  237. snowflake/cli/api/utils/naming_utils.py +0 -13
  238. snowflake/cli/api/utils/path_utils.py +0 -36
  239. snowflake/cli/api/utils/templating_functions.py +0 -144
  240. snowflake/cli/api/utils/types.py +0 -35
  241. snowflake_cli_labs-3.0.0rc5.dist-info/RECORD +0 -242
  242. snowflake_cli_labs-3.0.0rc5.dist-info/entry_points.txt +0 -2
  243. {snowflake_cli_labs-3.0.0rc5.dist-info → snowflake_cli_labs-3.0.2.dist-info}/WHEEL +0 -0
  244. {snowflake_cli_labs-3.0.0rc5.dist-info → snowflake_cli_labs-3.0.2.dist-info}/licenses/LICENSE +0 -0
@@ -1,262 +0,0 @@
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
-
15
- from __future__ import annotations
16
-
17
- import inspect
18
- from functools import wraps
19
- from typing import Any, Dict, Optional, Type, TypeVar, Union
20
-
21
- import typer
22
- from click import ClickException
23
- from snowflake.cli._plugins.nativeapp.entities.application import ApplicationEntityModel
24
- from snowflake.cli._plugins.nativeapp.entities.application_package import (
25
- ApplicationPackageEntityModel,
26
- )
27
- from snowflake.cli.api.cli_global_context import (
28
- get_cli_context,
29
- get_cli_context_manager,
30
- )
31
- from snowflake.cli.api.commands.decorators import _options_decorator_factory
32
- from snowflake.cli.api.project.schemas.entities.common import EntityModelBase
33
- from snowflake.cli.api.project.schemas.project_definition import (
34
- DefinitionV11,
35
- DefinitionV20,
36
- )
37
- from snowflake.cli.api.project.schemas.v1.native_app.path_mapping import PathMapping
38
- from snowflake.cli.api.utils.definition_rendering import render_definition_template
39
-
40
-
41
- def _convert_v2_artifact_to_v1_dict(
42
- v2_artifact: Union[PathMapping, str]
43
- ) -> Union[Dict, str]:
44
- if isinstance(v2_artifact, PathMapping):
45
- return {
46
- "src": v2_artifact.src,
47
- "dest": v2_artifact.dest,
48
- "processors": v2_artifact.processors,
49
- }
50
- return v2_artifact
51
-
52
-
53
- def _pdf_v2_to_v1(
54
- v2_definition: DefinitionV20,
55
- package_entity_id: str = "",
56
- app_entity_id: str = "",
57
- app_required: bool = False,
58
- ) -> DefinitionV11:
59
- pdfv1: Dict[str, Any] = {"definition_version": "1.1", "native_app": {}}
60
-
61
- # Determine the application entity to convert, there can be zero or one
62
- app_definition = find_entity(
63
- v2_definition,
64
- ApplicationEntityModel,
65
- app_entity_id,
66
- disambiguation_option="--app-entity-id",
67
- required=app_required,
68
- )
69
-
70
- # Infer or verify the package if we have an app entity to convert
71
- if app_definition:
72
- target_package = app_definition.from_.target
73
- if package_entity_id:
74
- # If the user specified a package entity ID,
75
- # check that the app entity targets the user-specified package entity
76
- # if the app entity is used by the command being run
77
- if target_package != package_entity_id and app_required:
78
- raise ClickException(
79
- f"The application entity {app_definition.entity_id} does not "
80
- f"target the application package entity {package_entity_id}. Either"
81
- f"use --package-entity-id {target_package} to target the correct package entity, "
82
- f"or omit the --package-entity-id flag to automatically use the package entity "
83
- f"that the application entity targets."
84
- )
85
- elif target_package in v2_definition.get_entities_by_type(
86
- ApplicationPackageEntityModel.get_type()
87
- ):
88
- # If the user didn't target a specific package entity, use the one the app entity targets
89
- package_entity_id = target_package
90
-
91
- # Determine the package entity to convert, there must be one
92
- app_package_definition = find_entity(
93
- v2_definition,
94
- ApplicationPackageEntityModel,
95
- package_entity_id,
96
- disambiguation_option="--package-entity-id",
97
- required=True,
98
- )
99
- assert app_package_definition is not None # satisfy mypy
100
-
101
- # NativeApp
102
- if app_definition and app_definition.fqn.identifier:
103
- pdfv1["native_app"]["name"] = app_definition.fqn.identifier
104
- else:
105
- pdfv1["native_app"]["name"] = app_package_definition.fqn.identifier.split(
106
- "_pkg_"
107
- )[0]
108
- pdfv1["native_app"]["artifacts"] = [
109
- _convert_v2_artifact_to_v1_dict(a) for a in app_package_definition.artifacts
110
- ]
111
- pdfv1["native_app"]["source_stage"] = app_package_definition.stage
112
- pdfv1["native_app"]["bundle_root"] = app_package_definition.bundle_root
113
- pdfv1["native_app"]["generated_root"] = app_package_definition.generated_root
114
- pdfv1["native_app"]["deploy_root"] = app_package_definition.deploy_root
115
- pdfv1["native_app"]["scratch_stage"] = app_package_definition.scratch_stage
116
-
117
- # Package
118
- pdfv1["native_app"]["package"] = {}
119
- pdfv1["native_app"]["package"]["name"] = app_package_definition.fqn.identifier
120
- if app_package_definition.distribution:
121
- pdfv1["native_app"]["package"][
122
- "distribution"
123
- ] = app_package_definition.distribution
124
- if app_package_definition.meta and app_package_definition.meta.post_deploy:
125
- pdfv1["native_app"]["package"][
126
- "post_deploy"
127
- ] = app_package_definition.meta.post_deploy
128
- if app_package_definition.meta:
129
- if app_package_definition.meta.role:
130
- pdfv1["native_app"]["package"]["role"] = app_package_definition.meta.role
131
- if app_package_definition.meta.warehouse:
132
- pdfv1["native_app"]["package"][
133
- "warehouse"
134
- ] = app_package_definition.meta.warehouse
135
-
136
- # Application
137
- if app_definition:
138
- pdfv1["native_app"]["application"] = {}
139
- pdfv1["native_app"]["application"]["name"] = app_definition.fqn.identifier
140
- if app_definition.debug:
141
- pdfv1["native_app"]["application"]["debug"] = app_definition.debug
142
- if app_definition.meta:
143
- if app_definition.meta.role:
144
- pdfv1["native_app"]["application"]["role"] = app_definition.meta.role
145
- if app_definition.meta.warehouse:
146
- pdfv1["native_app"]["application"][
147
- "warehouse"
148
- ] = app_definition.meta.warehouse
149
- if app_definition.meta.post_deploy:
150
- pdfv1["native_app"]["application"][
151
- "post_deploy"
152
- ] = app_definition.meta.post_deploy
153
-
154
- result = render_definition_template(pdfv1, {})
155
- # Override the definition object in global context
156
- return result.project_definition
157
-
158
-
159
- T = TypeVar("T", bound=EntityModelBase)
160
-
161
-
162
- def find_entity(
163
- project_definition: DefinitionV20,
164
- entity_class: Type[T],
165
- entity_id: str,
166
- disambiguation_option: str,
167
- required: bool,
168
- ) -> T | None:
169
- """
170
- Find an entity of the specified type in the project definition file.
171
-
172
- If an ID is passed, only that entity will be considered,
173
- otherwise look for a single entity of the specified type.
174
-
175
- If there are multiple entities of the specified type,
176
- the user must specify which one to use using the CLI option
177
- named in the disambiguation_option parameter.
178
-
179
- If no entity is found, an error is raised if required is True,
180
- otherwise None is returned.
181
- """
182
-
183
- entity_type = entity_class.get_type()
184
- entities = project_definition.get_entities_by_type(entity_type)
185
-
186
- entity: Optional[T] = None
187
-
188
- if entity_id:
189
- # If we're looking for a specific entity, use that one directly
190
- entity = entities.get(entity_id)
191
- elif len(entities) == 1:
192
- # Otherwise, if there is only one entity, fall back to that one
193
- entity = next(iter(entities.values()))
194
- elif len(entities) > 1 and required:
195
- # If there are multiple entities and it's required,
196
- # the user must specify which one to use
197
- raise ClickException(
198
- f"More than one {entity_type} entity exists in the project definition file, "
199
- f"specify {disambiguation_option} to choose which one to operate on."
200
- )
201
-
202
- # If we don't have a package entity to convert, error out if it's required
203
- if not entity and required:
204
- with_id = f'with ID "{entity_id}" ' if entity_id else ""
205
- raise ClickException(
206
- f"Could not find an {entity_type} entity {with_id}in the project definition file."
207
- )
208
-
209
- return entity
210
-
211
-
212
- def nativeapp_definition_v2_to_v1(*, app_required: bool = False):
213
- """
214
- A command decorator that attempts to automatically convert a native app project from
215
- definition v2 to v1.1. Assumes with_project_definition() has already been called.
216
- The definition object in CliGlobalContext will be replaced with the converted object.
217
- Exactly one application package entity type is expected, and up to one application
218
- entity type is expected.
219
- """
220
-
221
- def decorator(func):
222
- @wraps(func)
223
- def wrapper(*args, **kwargs):
224
- original_pdf: Optional[DefinitionV20] = get_cli_context().project_definition
225
- if not original_pdf:
226
- raise ValueError(
227
- "Project definition could not be found. The nativeapp_definition_v2_to_v1 command decorator assumes with_project_definition() was called before it."
228
- )
229
- if original_pdf.definition_version == "2":
230
- package_entity_id = kwargs.get("package_entity_id", "")
231
- app_entity_id = kwargs.get("app_entity_id", "")
232
- pdfv1 = _pdf_v2_to_v1(
233
- original_pdf, package_entity_id, app_entity_id, app_required
234
- )
235
- get_cli_context_manager().override_project_definition = pdfv1
236
- return func(*args, **kwargs)
237
-
238
- return _options_decorator_factory(
239
- wrapper,
240
- additional_options=[
241
- inspect.Parameter(
242
- "package_entity_id",
243
- inspect.Parameter.KEYWORD_ONLY,
244
- annotation=Optional[str],
245
- default=typer.Option(
246
- default="",
247
- help="The ID of the package entity on which to operate when definition_version is 2 or higher.",
248
- ),
249
- ),
250
- inspect.Parameter(
251
- "app_entity_id",
252
- inspect.Parameter.KEYWORD_ONLY,
253
- annotation=Optional[str],
254
- default=typer.Option(
255
- default="",
256
- help="The ID of the application entity on which to operate when definition_version is 2 or higher.",
257
- ),
258
- ),
259
- ],
260
- )
261
-
262
- return decorator
@@ -1,13 +0,0 @@
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,141 +0,0 @@
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
-
15
- from __future__ import annotations
16
-
17
- import logging
18
- from typing import Optional
19
-
20
- import typer
21
- from click import MissingParameter
22
- from snowflake.cli._plugins.nativeapp.common_flags import ForceOption, InteractiveOption
23
- from snowflake.cli._plugins.nativeapp.run_processor import NativeAppRunProcessor
24
- from snowflake.cli._plugins.nativeapp.v2_conversions.v2_to_v1_decorator import (
25
- nativeapp_definition_v2_to_v1,
26
- )
27
- from snowflake.cli._plugins.nativeapp.version.version_processor import (
28
- NativeAppVersionCreateProcessor,
29
- NativeAppVersionDropProcessor,
30
- )
31
- from snowflake.cli.api.cli_global_context import get_cli_context
32
- from snowflake.cli.api.commands.decorators import (
33
- with_project_definition,
34
- )
35
- from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
36
- from snowflake.cli.api.output.types import CommandResult, MessageResult, QueryResult
37
- from snowflake.cli.api.project.project_verification import assert_project_type
38
-
39
- app = SnowTyperFactory(
40
- name="version",
41
- help="Manages versions defined in an application package",
42
- )
43
-
44
- log = logging.getLogger(__name__)
45
-
46
-
47
- @app.command(requires_connection=True)
48
- @with_project_definition()
49
- @nativeapp_definition_v2_to_v1()
50
- def create(
51
- version: Optional[str] = typer.Argument(
52
- None,
53
- help=f"""Version to define in your application package. If the version already exists, an auto-incremented patch is added to the version instead. Defaults to the version specified in the `manifest.yml` file.""",
54
- ),
55
- patch: Optional[int] = typer.Option(
56
- None,
57
- "--patch",
58
- help=f"""The patch number you want to create for an existing version.
59
- Defaults to undefined if it is not set, which means the Snowflake CLI either uses the patch specified in the `manifest.yml` file or automatically generates a new patch number.""",
60
- ),
61
- skip_git_check: Optional[bool] = typer.Option(
62
- False,
63
- "--skip-git-check",
64
- help="When enabled, the Snowflake CLI skips checking if your project has any untracked or stages files in git. Default: unset.",
65
- is_flag=True,
66
- ),
67
- interactive: bool = InteractiveOption,
68
- force: Optional[bool] = ForceOption,
69
- **options,
70
- ) -> CommandResult:
71
- """
72
- Adds a new patch to the provided version defined in your application package. If the version does not exist, creates a version with patch 0.
73
- """
74
-
75
- assert_project_type("native_app")
76
-
77
- if version is None and patch is not None:
78
- raise MissingParameter("Cannot provide a patch without version!")
79
-
80
- cli_context = get_cli_context()
81
- processor = NativeAppVersionCreateProcessor(
82
- project_definition=cli_context.project_definition.native_app,
83
- project_root=cli_context.project_root,
84
- )
85
- processor.process(
86
- version=version,
87
- patch=patch,
88
- force=force,
89
- interactive=interactive,
90
- skip_git_check=skip_git_check,
91
- )
92
- return MessageResult(f"Version create is now complete.")
93
-
94
-
95
- @app.command("list", requires_connection=True)
96
- @with_project_definition()
97
- @nativeapp_definition_v2_to_v1()
98
- def version_list(
99
- **options,
100
- ) -> CommandResult:
101
- """
102
- Lists all versions defined in an application package.
103
- """
104
-
105
- assert_project_type("native_app")
106
-
107
- cli_context = get_cli_context()
108
- processor = NativeAppRunProcessor(
109
- project_definition=cli_context.project_definition.native_app,
110
- project_root=cli_context.project_root,
111
- )
112
- cursor = processor.get_all_existing_versions()
113
- return QueryResult(cursor)
114
-
115
-
116
- @app.command(requires_connection=True)
117
- @with_project_definition()
118
- @nativeapp_definition_v2_to_v1()
119
- def drop(
120
- version: Optional[str] = typer.Argument(
121
- None,
122
- help="Version defined in an application package that you want to drop. Defaults to the version specified in the `manifest.yml` file.",
123
- ),
124
- interactive: bool = InteractiveOption,
125
- force: Optional[bool] = ForceOption,
126
- **options,
127
- ) -> CommandResult:
128
- """
129
- Drops a version defined in your application package. Versions can either be passed in as an argument to the command or read from the `manifest.yml` file.
130
- Dropping patches is not allowed.
131
- """
132
-
133
- assert_project_type("native_app")
134
-
135
- cli_context = get_cli_context()
136
- processor = NativeAppVersionDropProcessor(
137
- project_definition=cli_context.project_definition.native_app,
138
- project_root=cli_context.project_root,
139
- )
140
- processor.process(version, force, interactive)
141
- return MessageResult(f"Version drop is now complete.")
@@ -1,98 +0,0 @@
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
-
15
- from __future__ import annotations
16
-
17
- from pathlib import Path
18
- from typing import Dict, Optional
19
-
20
- from snowflake.cli._plugins.nativeapp.entities.application_package import (
21
- ApplicationPackageEntity,
22
- )
23
- from snowflake.cli._plugins.nativeapp.manager import (
24
- NativeAppCommandProcessor,
25
- NativeAppManager,
26
- )
27
- from snowflake.cli._plugins.nativeapp.run_processor import NativeAppRunProcessor
28
- from snowflake.cli.api.console import cli_console as cc
29
- from snowflake.cli.api.project.schemas.v1.native_app.native_app import NativeApp
30
-
31
-
32
- class NativeAppVersionCreateProcessor(NativeAppRunProcessor):
33
- def __init__(self, project_definition: Dict, project_root: Path):
34
- super().__init__(project_definition, project_root)
35
-
36
- def process(
37
- self,
38
- version: Optional[str],
39
- patch: Optional[int],
40
- force: bool,
41
- interactive: bool,
42
- skip_git_check: bool,
43
- *args,
44
- **kwargs,
45
- ):
46
- return ApplicationPackageEntity.version_create(
47
- console=cc,
48
- project_root=self.project_root,
49
- deploy_root=self.deploy_root,
50
- bundle_root=self.bundle_root,
51
- generated_root=self.generated_root,
52
- artifacts=self.artifacts,
53
- package_name=self.package_name,
54
- package_role=self.package_role,
55
- package_distribution=self.package_distribution,
56
- prune=True,
57
- recursive=True,
58
- paths=None,
59
- print_diff=True,
60
- validate=True,
61
- stage_fqn=self.stage_fqn,
62
- package_warehouse=self.package_warehouse,
63
- post_deploy_hooks=self.package_post_deploy_hooks,
64
- package_scripts=self.package_scripts,
65
- version=version,
66
- patch=patch,
67
- force=force,
68
- interactive=interactive,
69
- skip_git_check=skip_git_check,
70
- )
71
-
72
-
73
- class NativeAppVersionDropProcessor(NativeAppManager, NativeAppCommandProcessor):
74
- def __init__(self, project_definition: NativeApp, project_root: Path):
75
- super().__init__(project_definition, project_root)
76
-
77
- def process(
78
- self,
79
- version: Optional[str],
80
- force: bool,
81
- interactive: bool,
82
- *args,
83
- **kwargs,
84
- ):
85
- return ApplicationPackageEntity.version_drop(
86
- console=cc,
87
- project_root=self.project_root,
88
- deploy_root=self.deploy_root,
89
- bundle_root=self.bundle_root,
90
- generated_root=self.generated_root,
91
- artifacts=self.artifacts,
92
- package_name=self.package_name,
93
- package_role=self.package_role,
94
- package_distribution=self.package_distribution,
95
- version=version,
96
- force=force,
97
- interactive=interactive,
98
- )
@@ -1,13 +0,0 @@
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,86 +0,0 @@
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
-
15
- import logging
16
-
17
- import typer
18
- from snowflake.cli._plugins.notebook.manager import NotebookManager
19
- from snowflake.cli._plugins.notebook.types import NotebookStagePath
20
- from snowflake.cli.api.commands.flags import identifier_argument
21
- from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
22
- from snowflake.cli.api.identifiers import FQN
23
- from snowflake.cli.api.output.types import MessageResult
24
- from typing_extensions import Annotated
25
-
26
- app = SnowTyperFactory(
27
- name="notebook",
28
- help="Manages notebooks in Snowflake.",
29
- )
30
- log = logging.getLogger(__name__)
31
-
32
- NOTEBOOK_IDENTIFIER = identifier_argument(sf_object="notebook", example="MY_NOTEBOOK")
33
- NotebookFile: NotebookStagePath = typer.Option(
34
- "--notebook-file",
35
- "-f",
36
- help="Stage path with notebook file. For example `@stage/path/to/notebook.ipynb`",
37
- show_default=False,
38
- )
39
-
40
-
41
- @app.command(requires_connection=True)
42
- def execute(
43
- identifier: FQN = NOTEBOOK_IDENTIFIER,
44
- **options,
45
- ):
46
- """
47
- Executes a notebook in a headless mode.
48
- """
49
- # Execution does not return any meaningful result
50
- _ = NotebookManager().execute(notebook_name=identifier)
51
- return MessageResult(f"Notebook {identifier} executed.")
52
-
53
-
54
- @app.command(requires_connection=True)
55
- def get_url(
56
- identifier: FQN = NOTEBOOK_IDENTIFIER,
57
- **options,
58
- ):
59
- """Return a url to a notebook."""
60
- url = NotebookManager().get_url(notebook_name=identifier)
61
- return MessageResult(message=url)
62
-
63
-
64
- @app.command(name="open", requires_connection=True)
65
- def open_cmd(
66
- identifier: FQN = NOTEBOOK_IDENTIFIER,
67
- **options,
68
- ):
69
- """Opens a notebook in default browser"""
70
- url = NotebookManager().get_url(notebook_name=identifier)
71
- typer.launch(url)
72
- return MessageResult(message=url)
73
-
74
-
75
- @app.command(requires_connection=True)
76
- def create(
77
- identifier: Annotated[FQN, NOTEBOOK_IDENTIFIER],
78
- notebook_file: Annotated[NotebookStagePath, NotebookFile],
79
- **options,
80
- ):
81
- """Creates notebook from stage."""
82
- notebook_url = NotebookManager().create(
83
- notebook_name=identifier,
84
- notebook_file=notebook_file,
85
- )
86
- return MessageResult(message=notebook_url)
@@ -1,20 +0,0 @@
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
-
15
- from click.exceptions import ClickException
16
-
17
-
18
- class NotebookStagePathError(ClickException):
19
- def __init__(self, path: str):
20
- super().__init__(f"Cannot extract notebook file name from {path=}")