snowflake-cli-labs 3.0.0rc4__py3-none-any.whl → 3.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. README.md +21 -0
  2. {snowflake_cli_labs-3.0.0rc4.dist-info → snowflake_cli_labs-3.0.1.dist-info}/METADATA +6 -96
  3. snowflake_cli_labs-3.0.1.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 -61
  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 -395
  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.0rc4.dist-info/RECORD +0 -242
  242. snowflake_cli_labs-3.0.0rc4.dist-info/entry_points.txt +0 -2
  243. {snowflake_cli_labs-3.0.0rc4.dist-info → snowflake_cli_labs-3.0.1.dist-info}/WHEEL +0 -0
  244. {snowflake_cli_labs-3.0.0rc4.dist-info → snowflake_cli_labs-3.0.1.dist-info}/licenses/LICENSE +0 -0
@@ -1,173 +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 List, Literal, Optional, Union
19
-
20
- from pydantic import Field, field_validator
21
- from snowflake.cli.api.identifiers import FQN
22
- from snowflake.cli.api.project.schemas.entities.common import (
23
- EntityModelBase,
24
- ExternalAccessBaseModel,
25
- ImportsBaseModel,
26
- )
27
- from snowflake.cli.api.project.schemas.updatable_model import (
28
- DiscriminatorField,
29
- UpdatableModel,
30
- )
31
- from snowflake.cli.api.project.schemas.v1.snowpark.argument import Argument
32
-
33
-
34
- class PathMapping(UpdatableModel):
35
- class Config:
36
- frozen = True
37
-
38
- src: Path = Field(title="Source path (relative to project root)", default=None)
39
-
40
- dest: Optional[str] = Field(
41
- title="Destination path on stage",
42
- description="Paths are relative to stage root; paths ending with a slash indicate that the destination is a directory which source files should be copied into.",
43
- default=None,
44
- )
45
-
46
-
47
- class SnowparkEntityModel(EntityModelBase, ExternalAccessBaseModel, ImportsBaseModel):
48
- handler: str = Field(
49
- title="Function’s or procedure’s implementation of the object inside source module",
50
- examples=["functions.hello_function"],
51
- )
52
- returns: str = Field(
53
- title="Type of the result"
54
- ) # TODO: again, consider Literal/Enum
55
- signature: Union[str, List[Argument]] = Field(
56
- title="The signature parameter describes consecutive arguments passed to the object"
57
- )
58
- runtime: Optional[Union[str, float]] = Field(
59
- title="Python version to use when executing ", default=None
60
- )
61
- stage: str = Field(title="Stage in which artifacts will be stored")
62
- artifacts: List[Union[PathMapping, str]] = Field(title="List of required sources")
63
-
64
- @field_validator("artifacts")
65
- @classmethod
66
- def _convert_artifacts(cls, artifacts: Union[dict, str]):
67
- _artifacts = []
68
- for artefact in artifacts:
69
- if isinstance(artefact, PathMapping):
70
- _artifacts.append(artefact)
71
- else:
72
- _artifacts.append(PathMapping(src=artefact))
73
- return _artifacts
74
-
75
- @field_validator("runtime")
76
- @classmethod
77
- def convert_runtime(cls, runtime_input: Union[str, float]) -> str:
78
- if isinstance(runtime_input, float):
79
- return str(runtime_input)
80
- return runtime_input
81
-
82
- @field_validator("artifacts")
83
- @classmethod
84
- def validate_artifacts(cls, artifacts: List[Path]) -> List[Path]:
85
- for artefact in artifacts:
86
- if "*" in str(artefact):
87
- raise ValueError("Glob patterns not supported for Snowpark artifacts.")
88
- return artifacts
89
-
90
- @property
91
- def udf_sproc_identifier(self) -> UdfSprocIdentifier:
92
- return UdfSprocIdentifier.from_definition(self)
93
-
94
-
95
- class ProcedureEntityModel(SnowparkEntityModel):
96
- type: Literal["procedure"] = DiscriminatorField() # noqa: A003
97
- execute_as_caller: Optional[bool] = Field(
98
- title="Determine whether the procedure is executed with the privileges of "
99
- "the owner (you) or with the privileges of the caller",
100
- default=False,
101
- )
102
-
103
-
104
- class FunctionEntityModel(SnowparkEntityModel):
105
- type: Literal["function"] = DiscriminatorField() # noqa: A003
106
-
107
-
108
- class UdfSprocIdentifier:
109
- def __init__(self, identifier: FQN, arg_names, arg_types, arg_defaults):
110
- self._identifier = identifier
111
- self._arg_names = arg_names
112
- self._arg_types = arg_types
113
- self._arg_defaults = arg_defaults
114
-
115
- def _identifier_from_signature(self, sig: List[str], for_sql: bool = False):
116
- signature = self._comma_join(sig)
117
- id_ = self._identifier.sql_identifier if for_sql else self._identifier
118
- return f"{id_}({signature})"
119
-
120
- @staticmethod
121
- def _comma_join(*args):
122
- return ", ".join(*args)
123
-
124
- @property
125
- def identifier_with_arg_names(self):
126
- return self._identifier_from_signature(self._arg_names)
127
-
128
- @property
129
- def identifier_with_arg_types(self):
130
- return self._identifier_from_signature(self._arg_types)
131
-
132
- @property
133
- def identifier_with_arg_names_types(self):
134
- sig = [f"{n} {t}" for n, t in zip(self._arg_names, self._arg_types)]
135
- return self._identifier_from_signature(sig)
136
-
137
- @property
138
- def identifier_with_arg_names_types_defaults(self):
139
- return self._identifier_from_signature(self._full_signature())
140
-
141
- def _is_signature_type_a_string(self, sig_type: str) -> bool:
142
- return sig_type.lower() in ["string", "varchar"]
143
-
144
- def _full_signature(self):
145
- sig = []
146
- for name, _type, _default in zip(
147
- self._arg_names, self._arg_types, self._arg_defaults
148
- ):
149
- s = f"{name} {_type}"
150
- if _default:
151
- if self._is_signature_type_a_string(_type):
152
- _default = f"'{_default}'"
153
- s += f" default {_default}"
154
- sig.append(s)
155
- return sig
156
-
157
- @property
158
- def identifier_for_sql(self):
159
- return self._identifier_from_signature(self._full_signature(), for_sql=True)
160
-
161
- @classmethod
162
- def from_definition(cls, udf_sproc: SnowparkEntityModel):
163
- names = []
164
- types = []
165
- defaults = []
166
- if udf_sproc.signature and udf_sproc.signature != "null":
167
- for arg in udf_sproc.signature:
168
- names.append(arg.name) # type:ignore
169
- types.append(arg.arg_type) # type:ignore
170
- defaults.append(arg.default) # type:ignore
171
-
172
- identifier = udf_sproc.fqn.using_context()
173
- return cls(identifier, names, types, defaults)
@@ -1,109 +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
- from __future__ import annotations
15
-
16
- from dataclasses import dataclass
17
- from pathlib import Path, PurePosixPath
18
-
19
- from snowflake.cli._plugins.snowpark.snowpark_entity_model import PathMapping
20
- from snowflake.cli._plugins.snowpark.zipper import zip_dir
21
- from snowflake.cli.api.console import cli_console
22
- from snowflake.cli.api.constants import DEPLOYMENT_STAGE
23
- from snowflake.cli.api.identifiers import FQN
24
- from snowflake.cli.api.secure_path import SecurePath
25
-
26
-
27
- @dataclass
28
- class SnowparkProjectPaths:
29
- """
30
- This class represents allows you to manage files paths related to given project.
31
- """
32
-
33
- project_root: Path
34
-
35
- def path_relative_to_root(self, artifact_path: Path) -> Path:
36
- if artifact_path.is_absolute():
37
- return artifact_path
38
- return (self.project_root / artifact_path).resolve()
39
-
40
- def get_artefact_dto(self, artifact_path: PathMapping) -> Artefact:
41
- return Artefact(
42
- dest=artifact_path.dest,
43
- path=self.path_relative_to_root(artifact_path.src),
44
- )
45
-
46
- def get_dependencies_artefact(self) -> Artefact:
47
- return Artefact(dest=None, path=self.dependencies)
48
-
49
- @property
50
- def snowflake_requirements(self) -> SecurePath:
51
- return SecurePath(
52
- self.path_relative_to_root(Path("requirements.snowflake.txt"))
53
- )
54
-
55
- @property
56
- def requirements(self) -> SecurePath:
57
- return SecurePath(self.path_relative_to_root(Path("requirements.txt")))
58
-
59
- @property
60
- def dependencies(self) -> Path:
61
- return self.path_relative_to_root(Path("dependencies.zip"))
62
-
63
-
64
- @dataclass(unsafe_hash=True)
65
- class Artefact:
66
- """Helper for getting paths related to given artefact."""
67
-
68
- path: Path
69
- dest: str | None = None
70
-
71
- @property
72
- def _artefact_name(self) -> str:
73
- if self.path.is_dir():
74
- return self.path.stem + ".zip"
75
- return self.path.name
76
-
77
- @property
78
- def post_build_path(self) -> Path:
79
- """
80
- Returns post-build artefact path. Directories are mapped to corresponding .zip files.
81
- """
82
- return self.path.parent / self._artefact_name
83
-
84
- def upload_path(self, stage: FQN | str | None) -> str:
85
- """
86
- Path on stage to which the artefact should be uploaded.
87
- """
88
- stage = stage or DEPLOYMENT_STAGE
89
- if isinstance(stage, str):
90
- stage = FQN.from_stage(stage).using_context()
91
-
92
- stage_path = PurePosixPath(f"@{stage}")
93
- if self.dest:
94
- stage_path = stage_path / self.dest
95
- return str(stage_path) + "/"
96
-
97
- def import_path(self, stage: FQN | str | None) -> str:
98
- """Path for UDF/sproc imports clause."""
99
- return self.upload_path(stage) + self._artefact_name
100
-
101
- def build(self) -> None:
102
- """Build the artefact. Applies only to directories. Files are untouched."""
103
- if not self.path.is_dir():
104
- return
105
- cli_console.step(f"Creating: {self.post_build_path.name}")
106
- zip_dir(
107
- source=self.path,
108
- dest_zip=self.post_build_path,
109
- )
@@ -1,59 +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 typer
18
-
19
- AllowSharedLibrariesOption: bool = typer.Option(
20
- False,
21
- "--allow-shared-libraries",
22
- help="Allows shared (.so) libraries, when using packages installed through PIP.",
23
- )
24
-
25
-
26
- IgnoreAnacondaOption: bool = typer.Option(
27
- False,
28
- "--ignore-anaconda",
29
- help="Does not lookup packages on Snowflake Anaconda channel.",
30
- )
31
-
32
- SkipVersionCheckOption: bool = typer.Option(
33
- False,
34
- "--skip-version-check",
35
- help="Skip comparing versions of dependencies between requirements and Anaconda.",
36
- )
37
-
38
- IndexUrlOption: str | None = typer.Option(
39
- None,
40
- "--index-url",
41
- help="Base URL of the Python Package Index to use for package lookup. This should point to "
42
- " a repository compliant with PEP 503 (the simple repository API) or a local directory laid"
43
- " out in the same format.",
44
- show_default=False,
45
- )
46
-
47
- ReturnsOption: str = typer.Option(
48
- ...,
49
- "--returns",
50
- "-r",
51
- help="Data type for the procedure to return.",
52
- )
53
-
54
- OverwriteOption: bool = typer.Option(
55
- False,
56
- "--overwrite",
57
- "-o",
58
- help="Replaces an existing procedure with this one.",
59
- )
@@ -1,89 +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 fnmatch
18
- import logging
19
- from pathlib import Path
20
- from typing import Dict, List, Literal
21
- from zipfile import ZIP_DEFLATED, ZipFile
22
-
23
- log = logging.getLogger(__name__)
24
-
25
- IGNORED_FILES = [
26
- "**/.DS_Store",
27
- "**/.git",
28
- "**/.git/*",
29
- "**/.gitignore",
30
- "**/.env",
31
- "**/.env/*",
32
- "**/.venv",
33
- "**/.venv/*",
34
- "**/__pycache__",
35
- "**/*.zip",
36
- "**/*.pyc",
37
- "**/env",
38
- "**/env/*",
39
- "**/ENV",
40
- "**/ENV/*",
41
- "**/venv",
42
- "**/venv/*",
43
- "**/requirements.txt",
44
- "**/requirements.snowflake.txt",
45
- "**/requirements.other.txt",
46
- "**/snowflake.yml",
47
- ]
48
-
49
-
50
- def add_file_to_existing_zip(zip_file: str, file: str):
51
- """Adds another file to an existing zip file
52
-
53
- Args:
54
- zip_file (str): The existing zip file
55
- file (str): The new file to add
56
- """
57
- with ZipFile(zip_file, mode="a") as myzip:
58
- myzip.write(file, Path(file).name)
59
-
60
-
61
- def zip_dir(
62
- source: Path | List[Path],
63
- dest_zip: Path,
64
- mode: Literal["r", "w", "x", "a"] = "w",
65
- ) -> None:
66
-
67
- if isinstance(source, Path):
68
- source = [source]
69
-
70
- files_to_pack: Dict[Path, List[Path]] = {
71
- src: list(filter(_to_be_zipped, (f.absolute() for f in src.glob("**/*"))))
72
- for src in source
73
- }
74
-
75
- with ZipFile(dest_zip, mode, ZIP_DEFLATED, allowZip64=True) as package_zip:
76
- for src, files in files_to_pack.items():
77
- for file in files:
78
- log.debug("Adding %s to %s", file, dest_zip)
79
- package_zip.write(file, arcname=file.relative_to(src))
80
-
81
-
82
- def _to_be_zipped(file: Path) -> bool:
83
- for pattern in IGNORED_FILES:
84
- # This has to be a string because of fnmatch
85
- file_as_str = str(file)
86
- if file_as_str == pattern or fnmatch.fnmatch(file_as_str, pattern):
87
- return False
88
-
89
- return True
@@ -1,33 +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 snowflake.cli._plugins.spcs.compute_pool.commands import (
16
- app as compute_pools_app,
17
- )
18
- from snowflake.cli._plugins.spcs.image_registry.commands import app as registry_app
19
- from snowflake.cli._plugins.spcs.image_repository.commands import (
20
- app as image_repository_app,
21
- )
22
- from snowflake.cli._plugins.spcs.services.commands import app as services_app
23
- from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
24
-
25
- app = SnowTyperFactory(
26
- name="spcs",
27
- help="Manages Snowpark Container Services compute pools, services, image registries, and image repositories.",
28
- )
29
-
30
- app.add_typer(compute_pools_app)
31
- app.add_typer(services_app)
32
- app.add_typer(registry_app)
33
- app.add_typer(image_repository_app)
@@ -1,99 +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 sys
18
- from typing import TextIO
19
-
20
- from click import ClickException
21
- from snowflake.cli.api.constants import ObjectType
22
- from snowflake.cli.api.exceptions import ObjectAlreadyExistsError
23
- from snowflake.cli.api.project.util import unquote_identifier
24
- from snowflake.connector.errors import ProgrammingError
25
-
26
- if not sys.stdout.closed and sys.stdout.isatty():
27
- GREEN = "\033[32m"
28
- BLUE = "\033[34m"
29
- ORANGE = "\033[38:2:238:76:44m"
30
- GRAY = "\033[2m"
31
- ENDC = "\033[0m"
32
- else:
33
- GREEN = ""
34
- ORANGE = ""
35
- BLUE = ""
36
- GRAY = ""
37
- ENDC = ""
38
-
39
-
40
- def _prefix_line(prefix: str, line: str) -> str:
41
- """
42
- _prefix_line ensure the prefix is still present even when dealing with return characters
43
- """
44
- if "\r" in line:
45
- line = line.replace("\r", f"\r{prefix}")
46
- if "\n" in line[:-1]:
47
- line = line[:-1].replace("\n", f"\n{prefix}") + line[-1:]
48
- if not line.startswith("\r"):
49
- line = f"{prefix}{line}"
50
- return line
51
-
52
-
53
- def print_log_lines(file: TextIO, name, identifier, logs):
54
- prefix = f"{GREEN}{name}/{identifier}{ENDC} "
55
- logs = logs[0:-1]
56
- for log in logs:
57
- print(_prefix_line(prefix, log + "\n"), file=file, end="", flush=True)
58
-
59
-
60
- def strip_empty_lines(lines: list[str]) -> str:
61
- return "\n".join(stripped for l in lines if (stripped := l.strip()))
62
-
63
-
64
- def validate_and_set_instances(min_instances, max_instances, instance_name):
65
- """
66
- Used to validate that min_instances is positive and that max_instances is not less than min_instances. In the
67
- case that max_instances is none, sets it equal to min_instances by default. Used like `max_instances =
68
- validate_and_set_instances(min_instances, max_instances, "name")`.
69
- """
70
- if min_instances < 1:
71
- raise ClickException(f"min_{instance_name} must be positive")
72
-
73
- if max_instances is None:
74
- max_instances = min_instances
75
- elif max_instances < min_instances:
76
- raise ClickException(
77
- f"max_{instance_name} must be greater or equal to min_{instance_name}"
78
- )
79
- return max_instances
80
-
81
-
82
- def handle_object_already_exists(
83
- error: ProgrammingError,
84
- object_type: ObjectType,
85
- object_name: str,
86
- replace_available: bool = False,
87
- ):
88
- if error.errno == 2002:
89
- raise ObjectAlreadyExistsError(
90
- object_type=object_type,
91
- name=unquote_identifier(object_name),
92
- replace_available=replace_available,
93
- )
94
- else:
95
- raise error
96
-
97
-
98
- class NoPropertiesProvidedError(ClickException):
99
- pass
@@ -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.