snowflake-cli-labs 2.8.0rc1__py3-none-any.whl → 2.8.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 (242) hide show
  1. README.md +21 -0
  2. {snowflake_cli_labs-2.8.0rc1.dist-info → snowflake_cli_labs-2.8.2.dist-info}/METADATA +7 -95
  3. snowflake_cli_labs-2.8.2.dist-info/RECORD +5 -0
  4. snowflake/cli/__about__.py +0 -17
  5. snowflake/cli/__init__.py +0 -13
  6. snowflake/cli/api/__init__.py +0 -48
  7. snowflake/cli/api/cli_global_context.py +0 -390
  8. snowflake/cli/api/commands/__init__.py +0 -13
  9. snowflake/cli/api/commands/alias.py +0 -23
  10. snowflake/cli/api/commands/decorators.py +0 -354
  11. snowflake/cli/api/commands/execution_metadata.py +0 -40
  12. snowflake/cli/api/commands/experimental_behaviour.py +0 -19
  13. snowflake/cli/api/commands/flags.py +0 -640
  14. snowflake/cli/api/commands/project_initialisation.py +0 -65
  15. snowflake/cli/api/commands/snow_typer.py +0 -237
  16. snowflake/cli/api/commands/typer_pre_execute.py +0 -26
  17. snowflake/cli/api/config.py +0 -348
  18. snowflake/cli/api/console/__init__.py +0 -17
  19. snowflake/cli/api/console/abc.py +0 -89
  20. snowflake/cli/api/console/console.py +0 -134
  21. snowflake/cli/api/console/enum.py +0 -17
  22. snowflake/cli/api/constants.py +0 -79
  23. snowflake/cli/api/errno.py +0 -27
  24. snowflake/cli/api/exceptions.py +0 -164
  25. snowflake/cli/api/feature_flags.py +0 -55
  26. snowflake/cli/api/identifiers.py +0 -154
  27. snowflake/cli/api/output/__init__.py +0 -13
  28. snowflake/cli/api/output/formats.py +0 -20
  29. snowflake/cli/api/output/types.py +0 -118
  30. snowflake/cli/api/plugins/__init__.py +0 -13
  31. snowflake/cli/api/plugins/command/__init__.py +0 -72
  32. snowflake/cli/api/plugins/command/plugin_hook_specs.py +0 -21
  33. snowflake/cli/api/plugins/plugin_config.py +0 -32
  34. snowflake/cli/api/project/__init__.py +0 -13
  35. snowflake/cli/api/project/definition.py +0 -84
  36. snowflake/cli/api/project/definition_manager.py +0 -134
  37. snowflake/cli/api/project/errors.py +0 -56
  38. snowflake/cli/api/project/project_verification.py +0 -23
  39. snowflake/cli/api/project/schemas/__init__.py +0 -13
  40. snowflake/cli/api/project/schemas/entities/application_entity.py +0 -44
  41. snowflake/cli/api/project/schemas/entities/application_package_entity.py +0 -66
  42. snowflake/cli/api/project/schemas/entities/common.py +0 -78
  43. snowflake/cli/api/project/schemas/entities/entities.py +0 -30
  44. snowflake/cli/api/project/schemas/identifier_model.py +0 -49
  45. snowflake/cli/api/project/schemas/native_app/__init__.py +0 -13
  46. snowflake/cli/api/project/schemas/native_app/application.py +0 -62
  47. snowflake/cli/api/project/schemas/native_app/native_app.py +0 -93
  48. snowflake/cli/api/project/schemas/native_app/package.py +0 -78
  49. snowflake/cli/api/project/schemas/native_app/path_mapping.py +0 -65
  50. snowflake/cli/api/project/schemas/project_definition.py +0 -199
  51. snowflake/cli/api/project/schemas/snowpark/__init__.py +0 -13
  52. snowflake/cli/api/project/schemas/snowpark/argument.py +0 -28
  53. snowflake/cli/api/project/schemas/snowpark/callable.py +0 -69
  54. snowflake/cli/api/project/schemas/snowpark/snowpark.py +0 -36
  55. snowflake/cli/api/project/schemas/streamlit/__init__.py +0 -13
  56. snowflake/cli/api/project/schemas/streamlit/streamlit.py +0 -46
  57. snowflake/cli/api/project/schemas/template.py +0 -77
  58. snowflake/cli/api/project/schemas/updatable_model.py +0 -194
  59. snowflake/cli/api/project/util.py +0 -261
  60. snowflake/cli/api/rendering/__init__.py +0 -13
  61. snowflake/cli/api/rendering/jinja.py +0 -112
  62. snowflake/cli/api/rendering/project_definition_templates.py +0 -39
  63. snowflake/cli/api/rendering/project_templates.py +0 -98
  64. snowflake/cli/api/rendering/sql_templates.py +0 -60
  65. snowflake/cli/api/rest_api.py +0 -172
  66. snowflake/cli/api/sanitizers.py +0 -43
  67. snowflake/cli/api/secure_path.py +0 -362
  68. snowflake/cli/api/secure_utils.py +0 -29
  69. snowflake/cli/api/sql_execution.py +0 -260
  70. snowflake/cli/api/utils/__init__.py +0 -13
  71. snowflake/cli/api/utils/cursor.py +0 -34
  72. snowflake/cli/api/utils/definition_rendering.py +0 -383
  73. snowflake/cli/api/utils/dict_utils.py +0 -73
  74. snowflake/cli/api/utils/error_handling.py +0 -23
  75. snowflake/cli/api/utils/graph.py +0 -97
  76. snowflake/cli/api/utils/models.py +0 -63
  77. snowflake/cli/api/utils/naming_utils.py +0 -13
  78. snowflake/cli/api/utils/path_utils.py +0 -36
  79. snowflake/cli/api/utils/templating_functions.py +0 -144
  80. snowflake/cli/api/utils/types.py +0 -35
  81. snowflake/cli/app/__init__.py +0 -22
  82. snowflake/cli/app/__main__.py +0 -31
  83. snowflake/cli/app/api_impl/__init__.py +0 -13
  84. snowflake/cli/app/api_impl/plugin/__init__.py +0 -13
  85. snowflake/cli/app/api_impl/plugin/plugin_config_provider_impl.py +0 -66
  86. snowflake/cli/app/build_and_push.sh +0 -8
  87. snowflake/cli/app/cli_app.py +0 -243
  88. snowflake/cli/app/commands_registration/__init__.py +0 -33
  89. snowflake/cli/app/commands_registration/builtin_plugins.py +0 -54
  90. snowflake/cli/app/commands_registration/command_plugins_loader.py +0 -169
  91. snowflake/cli/app/commands_registration/commands_registration_with_callbacks.py +0 -105
  92. snowflake/cli/app/commands_registration/exception_logging.py +0 -26
  93. snowflake/cli/app/commands_registration/threadsafe.py +0 -48
  94. snowflake/cli/app/commands_registration/typer_registration.py +0 -153
  95. snowflake/cli/app/constants.py +0 -19
  96. snowflake/cli/app/dev/__init__.py +0 -13
  97. snowflake/cli/app/dev/commands_structure.py +0 -48
  98. snowflake/cli/app/dev/docs/__init__.py +0 -13
  99. snowflake/cli/app/dev/docs/commands_docs_generator.py +0 -100
  100. snowflake/cli/app/dev/docs/generator.py +0 -35
  101. snowflake/cli/app/dev/docs/project_definition_docs_generator.py +0 -58
  102. snowflake/cli/app/dev/docs/project_definition_generate_json_schema.py +0 -227
  103. snowflake/cli/app/dev/docs/template_utils.py +0 -23
  104. snowflake/cli/app/dev/docs/templates/definition_description.rst.jinja2 +0 -38
  105. snowflake/cli/app/dev/docs/templates/overview.rst.jinja2 +0 -9
  106. snowflake/cli/app/dev/docs/templates/usage.rst.jinja2 +0 -57
  107. snowflake/cli/app/dev/pycharm_remote_debug.py +0 -46
  108. snowflake/cli/app/loggers.py +0 -199
  109. snowflake/cli/app/main_typer.py +0 -62
  110. snowflake/cli/app/printing.py +0 -181
  111. snowflake/cli/app/snow_connector.py +0 -243
  112. snowflake/cli/app/telemetry.py +0 -189
  113. snowflake/cli/plugins/__init__.py +0 -13
  114. snowflake/cli/plugins/connection/__init__.py +0 -13
  115. snowflake/cli/plugins/connection/commands.py +0 -330
  116. snowflake/cli/plugins/connection/plugin_spec.py +0 -30
  117. snowflake/cli/plugins/connection/util.py +0 -179
  118. snowflake/cli/plugins/cortex/__init__.py +0 -13
  119. snowflake/cli/plugins/cortex/commands.py +0 -327
  120. snowflake/cli/plugins/cortex/constants.py +0 -17
  121. snowflake/cli/plugins/cortex/manager.py +0 -189
  122. snowflake/cli/plugins/cortex/plugin_spec.py +0 -30
  123. snowflake/cli/plugins/cortex/types.py +0 -22
  124. snowflake/cli/plugins/git/__init__.py +0 -13
  125. snowflake/cli/plugins/git/commands.py +0 -305
  126. snowflake/cli/plugins/git/manager.py +0 -96
  127. snowflake/cli/plugins/git/plugin_spec.py +0 -30
  128. snowflake/cli/plugins/init/__init__.py +0 -13
  129. snowflake/cli/plugins/init/commands.py +0 -244
  130. snowflake/cli/plugins/init/plugin_spec.py +0 -30
  131. snowflake/cli/plugins/nativeapp/__init__.py +0 -13
  132. snowflake/cli/plugins/nativeapp/artifacts.py +0 -742
  133. snowflake/cli/plugins/nativeapp/codegen/__init__.py +0 -13
  134. snowflake/cli/plugins/nativeapp/codegen/artifact_processor.py +0 -91
  135. snowflake/cli/plugins/nativeapp/codegen/compiler.py +0 -130
  136. snowflake/cli/plugins/nativeapp/codegen/sandbox.py +0 -306
  137. snowflake/cli/plugins/nativeapp/codegen/setup/native_app_setup_processor.py +0 -172
  138. snowflake/cli/plugins/nativeapp/codegen/setup/setup_driver.py.source +0 -56
  139. snowflake/cli/plugins/nativeapp/codegen/snowpark/callback_source.py.jinja +0 -181
  140. snowflake/cli/plugins/nativeapp/codegen/snowpark/extension_function_utils.py +0 -217
  141. snowflake/cli/plugins/nativeapp/codegen/snowpark/models.py +0 -61
  142. snowflake/cli/plugins/nativeapp/codegen/snowpark/python_processor.py +0 -528
  143. snowflake/cli/plugins/nativeapp/commands.py +0 -439
  144. snowflake/cli/plugins/nativeapp/common_flags.py +0 -44
  145. snowflake/cli/plugins/nativeapp/constants.py +0 -27
  146. snowflake/cli/plugins/nativeapp/exceptions.py +0 -122
  147. snowflake/cli/plugins/nativeapp/feature_flags.py +0 -24
  148. snowflake/cli/plugins/nativeapp/init.py +0 -345
  149. snowflake/cli/plugins/nativeapp/manager.py +0 -823
  150. snowflake/cli/plugins/nativeapp/plugin_spec.py +0 -30
  151. snowflake/cli/plugins/nativeapp/policy.py +0 -50
  152. snowflake/cli/plugins/nativeapp/project_model.py +0 -195
  153. snowflake/cli/plugins/nativeapp/run_processor.py +0 -389
  154. snowflake/cli/plugins/nativeapp/teardown_processor.py +0 -301
  155. snowflake/cli/plugins/nativeapp/utils.py +0 -98
  156. snowflake/cli/plugins/nativeapp/v2_conversions/v2_to_v1_decorator.py +0 -135
  157. snowflake/cli/plugins/nativeapp/version/__init__.py +0 -13
  158. snowflake/cli/plugins/nativeapp/version/commands.py +0 -170
  159. snowflake/cli/plugins/nativeapp/version/version_processor.py +0 -362
  160. snowflake/cli/plugins/notebook/__init__.py +0 -13
  161. snowflake/cli/plugins/notebook/commands.py +0 -84
  162. snowflake/cli/plugins/notebook/exceptions.py +0 -20
  163. snowflake/cli/plugins/notebook/manager.py +0 -71
  164. snowflake/cli/plugins/notebook/plugin_spec.py +0 -30
  165. snowflake/cli/plugins/notebook/types.py +0 -16
  166. snowflake/cli/plugins/object/__init__.py +0 -13
  167. snowflake/cli/plugins/object/command_aliases.py +0 -94
  168. snowflake/cli/plugins/object/commands.py +0 -174
  169. snowflake/cli/plugins/object/common.py +0 -85
  170. snowflake/cli/plugins/object/manager.py +0 -96
  171. snowflake/cli/plugins/object/plugin_spec.py +0 -30
  172. snowflake/cli/plugins/object_stage_deprecated/__init__.py +0 -15
  173. snowflake/cli/plugins/object_stage_deprecated/commands.py +0 -122
  174. snowflake/cli/plugins/object_stage_deprecated/plugin_spec.py +0 -32
  175. snowflake/cli/plugins/snowpark/__init__.py +0 -13
  176. snowflake/cli/plugins/snowpark/commands.py +0 -548
  177. snowflake/cli/plugins/snowpark/common.py +0 -307
  178. snowflake/cli/plugins/snowpark/manager.py +0 -109
  179. snowflake/cli/plugins/snowpark/models.py +0 -156
  180. snowflake/cli/plugins/snowpark/package/__init__.py +0 -13
  181. snowflake/cli/plugins/snowpark/package/anaconda_packages.py +0 -233
  182. snowflake/cli/plugins/snowpark/package/commands.py +0 -256
  183. snowflake/cli/plugins/snowpark/package/manager.py +0 -43
  184. snowflake/cli/plugins/snowpark/package/utils.py +0 -26
  185. snowflake/cli/plugins/snowpark/package_utils.py +0 -354
  186. snowflake/cli/plugins/snowpark/plugin_spec.py +0 -30
  187. snowflake/cli/plugins/snowpark/snowpark_package_paths.py +0 -65
  188. snowflake/cli/plugins/snowpark/snowpark_shared.py +0 -95
  189. snowflake/cli/plugins/snowpark/zipper.py +0 -81
  190. snowflake/cli/plugins/spcs/__init__.py +0 -35
  191. snowflake/cli/plugins/spcs/common.py +0 -99
  192. snowflake/cli/plugins/spcs/compute_pool/__init__.py +0 -13
  193. snowflake/cli/plugins/spcs/compute_pool/commands.py +0 -240
  194. snowflake/cli/plugins/spcs/compute_pool/manager.py +0 -121
  195. snowflake/cli/plugins/spcs/image_registry/__init__.py +0 -13
  196. snowflake/cli/plugins/spcs/image_registry/commands.py +0 -65
  197. snowflake/cli/plugins/spcs/image_registry/manager.py +0 -105
  198. snowflake/cli/plugins/spcs/image_repository/__init__.py +0 -13
  199. snowflake/cli/plugins/spcs/image_repository/commands.py +0 -196
  200. snowflake/cli/plugins/spcs/image_repository/manager.py +0 -84
  201. snowflake/cli/plugins/spcs/jobs/__init__.py +0 -13
  202. snowflake/cli/plugins/spcs/jobs/commands.py +0 -78
  203. snowflake/cli/plugins/spcs/jobs/manager.py +0 -53
  204. snowflake/cli/plugins/spcs/plugin_spec.py +0 -30
  205. snowflake/cli/plugins/spcs/services/__init__.py +0 -13
  206. snowflake/cli/plugins/spcs/services/commands.py +0 -311
  207. snowflake/cli/plugins/spcs/services/manager.py +0 -170
  208. snowflake/cli/plugins/sql/__init__.py +0 -13
  209. snowflake/cli/plugins/sql/commands.py +0 -83
  210. snowflake/cli/plugins/sql/manager.py +0 -92
  211. snowflake/cli/plugins/sql/plugin_spec.py +0 -30
  212. snowflake/cli/plugins/sql/snowsql_templating.py +0 -28
  213. snowflake/cli/plugins/stage/__init__.py +0 -13
  214. snowflake/cli/plugins/stage/commands.py +0 -261
  215. snowflake/cli/plugins/stage/diff.py +0 -326
  216. snowflake/cli/plugins/stage/manager.py +0 -544
  217. snowflake/cli/plugins/stage/md5.py +0 -160
  218. snowflake/cli/plugins/stage/plugin_spec.py +0 -30
  219. snowflake/cli/plugins/streamlit/__init__.py +0 -13
  220. snowflake/cli/plugins/streamlit/commands.py +0 -186
  221. snowflake/cli/plugins/streamlit/manager.py +0 -222
  222. snowflake/cli/plugins/streamlit/plugin_spec.py +0 -30
  223. snowflake/cli/plugins/workspace/__init__.py +0 -13
  224. snowflake/cli/plugins/workspace/commands.py +0 -35
  225. snowflake/cli/plugins/workspace/plugin_spec.py +0 -30
  226. snowflake/cli/templates/default_snowpark/.gitignore +0 -4
  227. snowflake/cli/templates/default_snowpark/app/__init__.py +0 -0
  228. snowflake/cli/templates/default_snowpark/app/common.py +0 -2
  229. snowflake/cli/templates/default_snowpark/app/functions.py +0 -15
  230. snowflake/cli/templates/default_snowpark/app/procedures.py +0 -22
  231. snowflake/cli/templates/default_snowpark/requirements.txt +0 -1
  232. snowflake/cli/templates/default_snowpark/snowflake.yml +0 -23
  233. snowflake/cli/templates/default_streamlit/.gitignore +0 -4
  234. snowflake/cli/templates/default_streamlit/common/hello.py +0 -2
  235. snowflake/cli/templates/default_streamlit/environment.yml +0 -6
  236. snowflake/cli/templates/default_streamlit/pages/my_page.py +0 -3
  237. snowflake/cli/templates/default_streamlit/snowflake.yml +0 -10
  238. snowflake/cli/templates/default_streamlit/streamlit_app.py +0 -4
  239. snowflake_cli_labs-2.8.0rc1.dist-info/RECORD +0 -240
  240. snowflake_cli_labs-2.8.0rc1.dist-info/entry_points.txt +0 -2
  241. {snowflake_cli_labs-2.8.0rc1.dist-info → snowflake_cli_labs-2.8.2.dist-info}/WHEEL +0 -0
  242. {snowflake_cli_labs-2.8.0rc1.dist-info → snowflake_cli_labs-2.8.2.dist-info}/licenses/LICENSE +0 -0
@@ -1,196 +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 json
18
- from typing import Optional
19
-
20
- import requests
21
- import typer
22
- from click import ClickException
23
- from snowflake.cli.api.commands.flags import (
24
- IfNotExistsOption,
25
- ReplaceOption,
26
- like_option,
27
- )
28
- from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
29
- from snowflake.cli.api.console import cli_console
30
- from snowflake.cli.api.constants import ObjectType
31
- from snowflake.cli.api.output.types import (
32
- CollectionResult,
33
- MessageResult,
34
- SingleQueryResult,
35
- )
36
- from snowflake.cli.api.project.util import is_valid_object_name
37
- from snowflake.cli.plugins.object.command_aliases import (
38
- add_object_command_aliases,
39
- scope_option,
40
- )
41
- from snowflake.cli.plugins.spcs.image_registry.manager import RegistryManager
42
- from snowflake.cli.plugins.spcs.image_repository.manager import ImageRepositoryManager
43
-
44
- app = SnowTyperFactory(
45
- name="image-repository",
46
- help="Manages Snowpark Container Services image repositories.",
47
- short_help="Manages image repositories.",
48
- )
49
-
50
-
51
- def _repo_name_callback(name: str):
52
- if not is_valid_object_name(name, max_depth=2, allow_quoted=False):
53
- raise ClickException(
54
- f"'{name}' is not a valid image repository name. Note that image repository names must be unquoted identifiers. The same constraint also applies to database and schema names where you create an image repository."
55
- )
56
- return name
57
-
58
-
59
- REPO_NAME_ARGUMENT = typer.Argument(
60
- help="Name of the image repository.",
61
- callback=_repo_name_callback,
62
- show_default=False,
63
- )
64
-
65
- add_object_command_aliases(
66
- app=app,
67
- object_type=ObjectType.IMAGE_REPOSITORY,
68
- name_argument=REPO_NAME_ARGUMENT,
69
- like_option=like_option(
70
- help_example='`list --like "my%"` lists all image repositories that begin with “my”.'
71
- ),
72
- scope_option=scope_option(help_example="`list --in database my_db`"),
73
- ommit_commands=["describe"],
74
- )
75
-
76
-
77
- @app.command(requires_connection=True)
78
- def create(
79
- name: str = REPO_NAME_ARGUMENT,
80
- replace: bool = ReplaceOption(),
81
- if_not_exists: bool = IfNotExistsOption(),
82
- **options,
83
- ):
84
- """
85
- Creates a new image repository in the current schema.
86
- """
87
- return SingleQueryResult(
88
- ImageRepositoryManager().create(
89
- name=name, replace=replace, if_not_exists=if_not_exists
90
- )
91
- )
92
-
93
-
94
- @app.command("list-images", requires_connection=True)
95
- def list_images(
96
- name: str = REPO_NAME_ARGUMENT,
97
- **options,
98
- ) -> CollectionResult:
99
- """Lists images in the given repository."""
100
- repository_manager = ImageRepositoryManager()
101
- database = repository_manager.get_database()
102
- schema = repository_manager.get_schema()
103
- url = repository_manager.get_repository_url(name)
104
- api_url = repository_manager.get_repository_api_url(url)
105
- bearer_login = RegistryManager().login_to_registry(api_url)
106
- repos = []
107
- query: Optional[str] = f"{api_url}/_catalog?n=10"
108
-
109
- while query:
110
- # Make paginated catalog requests
111
- response = requests.get(
112
- query, headers={"Authorization": f"Bearer {bearer_login}"}
113
- )
114
-
115
- if response.status_code != 200:
116
- raise ClickException(f"Call to the registry failed {response.text}")
117
-
118
- data = json.loads(response.text)
119
- if "repositories" in data:
120
- repos.extend(data["repositories"])
121
-
122
- if "Link" in response.headers:
123
- # There are more results
124
- query = f"{api_url}/_catalog?n=10&last={repos[-1]}"
125
- else:
126
- query = None
127
-
128
- images = []
129
- for repo in repos:
130
- prefix = f"/{database}/{schema}/{name}/"
131
- repo = repo.replace("baserepo/", prefix)
132
- images.append({"image": repo})
133
-
134
- return CollectionResult(images)
135
-
136
-
137
- @app.command("list-tags", requires_connection=True)
138
- def list_tags(
139
- name: str = REPO_NAME_ARGUMENT,
140
- image_name: str = typer.Option(
141
- ...,
142
- "--image-name",
143
- "--image_name",
144
- "-i",
145
- help="Fully qualified name of the image as shown in the output of list-images",
146
- show_default=False,
147
- ),
148
- **options,
149
- ) -> CollectionResult:
150
- """Lists tags for the given image in a repository."""
151
-
152
- repository_manager = ImageRepositoryManager()
153
- url = repository_manager.get_repository_url(name)
154
- api_url = repository_manager.get_repository_api_url(url)
155
- bearer_login = RegistryManager().login_to_registry(api_url)
156
-
157
- image_realname = "/".join(image_name.split("/")[4:])
158
- tags = []
159
- query: Optional[str] = f"{api_url}/{image_realname}/tags/list?n=10"
160
-
161
- while query is not None:
162
- # Make paginated catalog requests
163
- response = requests.get(
164
- query, headers={"Authorization": f"Bearer {bearer_login}"}
165
- )
166
-
167
- if response.status_code != 200:
168
- cli_console.warning(f"Call to the registry failed {response.text}")
169
-
170
- data = json.loads(response.text)
171
- if "tags" in data:
172
- tags.extend(data["tags"])
173
-
174
- if "Link" in response.headers:
175
- # There are more results
176
- query = f"{api_url}/{image_realname}/tags/list?n=10&last={tags[-1]}"
177
- else:
178
- query = None
179
-
180
- tags_list = []
181
- for tag in tags:
182
- image_tag = f"{image_name}:{tag}"
183
- tags_list.append({"tag": image_tag})
184
-
185
- return CollectionResult(tags_list)
186
-
187
-
188
- @app.command("url", requires_connection=True)
189
- def repo_url(
190
- name: str = REPO_NAME_ARGUMENT,
191
- **options,
192
- ):
193
- """Returns the URL for the given repository."""
194
- return MessageResult(
195
- (ImageRepositoryManager().get_repository_url(repo_name=name, with_scheme=False))
196
- )
@@ -1,84 +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 urllib.parse import urlparse
16
-
17
- from snowflake.cli.api.constants import ObjectType
18
- from snowflake.cli.api.identifiers import FQN
19
- from snowflake.cli.api.sql_execution import SqlExecutionMixin
20
- from snowflake.cli.plugins.spcs.common import handle_object_already_exists
21
- from snowflake.connector.errors import ProgrammingError
22
-
23
-
24
- class ImageRepositoryManager(SqlExecutionMixin):
25
- def get_database(self):
26
- return self._conn.database
27
-
28
- def get_schema(self):
29
- return self._conn.schema
30
-
31
- def get_role(self):
32
- return self._conn.role
33
-
34
- def get_repository_url(self, repo_name: str, with_scheme: bool = True):
35
-
36
- repo_row = self.show_specific_object(
37
- "image repositories", repo_name, check_schema=True
38
- )
39
- if repo_row is None:
40
- fqn = FQN.from_string(repo_name).using_connection(self._conn)
41
- raise ProgrammingError(
42
- f"Image repository '{fqn.identifier}' does not exist or not authorized."
43
- )
44
- if with_scheme:
45
- return f"https://{repo_row['repository_url']}"
46
- else:
47
- return repo_row["repository_url"]
48
-
49
- def get_repository_api_url(self, repo_url):
50
- """
51
- Converts a repo URL to a registry OCI API URL.
52
- https://reg.com/db/schema/repo becomes https://reg.com/v2/db/schema/repo
53
- """
54
- parsed_url = urlparse(repo_url)
55
-
56
- scheme = parsed_url.scheme
57
- host = parsed_url.netloc
58
- path = parsed_url.path
59
-
60
- return f"{scheme}://{host}/v2{path}"
61
-
62
- def create(
63
- self,
64
- name: str,
65
- if_not_exists: bool,
66
- replace: bool,
67
- ):
68
- if if_not_exists and replace:
69
- raise ValueError(
70
- "'replace' and 'if_not_exists' options are mutually exclusive for ImageRepositoryManager.create"
71
- )
72
- elif replace:
73
- create_statement = "create or replace image repository"
74
- elif if_not_exists:
75
- create_statement = "create image repository if not exists"
76
- else:
77
- create_statement = "create image repository"
78
-
79
- try:
80
- return self._execute_schema_query(f"{create_statement} {name}", name=name)
81
- except ProgrammingError as e:
82
- handle_object_already_exists(
83
- e, ObjectType.IMAGE_REPOSITORY, name, replace_available=True
84
- )
@@ -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,78 +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 sys
16
- from pathlib import Path
17
-
18
- import typer
19
- from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
20
- from snowflake.cli.api.output.types import CommandResult, SingleQueryResult
21
- from snowflake.cli.plugins.spcs.common import print_log_lines
22
- from snowflake.cli.plugins.spcs.jobs.manager import JobManager
23
-
24
- app = SnowTyperFactory(
25
- name="job",
26
- help="Manages Snowpark jobs.",
27
- is_hidden=lambda: True,
28
- )
29
-
30
-
31
- @app.command(requires_connection=True)
32
- def create(
33
- compute_pool: str = typer.Option(
34
- ..., "--compute-pool", help="Name of the pool in which to run the job."
35
- ),
36
- spec_path: Path = typer.Option(
37
- ...,
38
- "--spec-path",
39
- help="Path to the `spec.yaml` file containing the job details.",
40
- file_okay=True,
41
- dir_okay=False,
42
- exists=True,
43
- ),
44
- **options,
45
- ) -> CommandResult:
46
- """
47
- Creates a job to run in a compute pool.
48
- """
49
- cursor = JobManager().create(compute_pool=compute_pool, spec_path=spec_path)
50
- return SingleQueryResult(cursor)
51
-
52
-
53
- @app.command(requires_connection=True)
54
- def logs(
55
- identifier: str = typer.Argument(..., help="Job id"),
56
- container_name: str = typer.Option(
57
- ..., "--container-name", help="Name of the container."
58
- ),
59
- **options,
60
- ):
61
- """
62
- Retrieves local logs from a job container.
63
- """
64
- results = JobManager().logs(job_name=identifier, container_name=container_name)
65
- cursor = results.fetchone()
66
- logs = next(iter(cursor)).split("\n")
67
- print_log_lines(sys.stdout, identifier, "0", logs)
68
-
69
-
70
- @app.command(requires_connection=True)
71
- def status(
72
- identifier: str = typer.Argument(..., help="ID of the job."), **options
73
- ) -> CommandResult:
74
- """
75
- Returns the status of a named Snowpark Container Services job.
76
- """
77
- cursor = JobManager().status(job_name=identifier)
78
- return SingleQueryResult(cursor)
@@ -1,53 +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 pathlib import Path
16
-
17
- from snowflake.cli.api.constants import DEFAULT_SIZE_LIMIT_MB
18
- from snowflake.cli.api.secure_path import SecurePath
19
- from snowflake.cli.api.sql_execution import SqlExecutionMixin
20
- from snowflake.connector.cursor import SnowflakeCursor
21
-
22
-
23
- class JobManager(SqlExecutionMixin):
24
- def create(self, compute_pool: str, spec_path: Path) -> SnowflakeCursor:
25
- spec = self._read_yaml(spec_path)
26
- return self._execute_schema_query(
27
- f"""\
28
- EXECUTE SERVICE
29
- IN COMPUTE POOL {compute_pool}
30
- FROM SPECIFICATION $$
31
- {spec}
32
- $$
33
- """
34
- )
35
-
36
- def _read_yaml(self, path: Path) -> str:
37
- # TODO(aivanou): Add validation towards schema
38
- # TODO(aivanou): Combine this with service manager
39
- import json
40
-
41
- import yaml
42
-
43
- with SecurePath(path).open("r", read_file_limit_mb=DEFAULT_SIZE_LIMIT_MB) as fh:
44
- data = yaml.safe_load(fh)
45
- return json.dumps(data)
46
-
47
- def status(self, job_name: str) -> SnowflakeCursor:
48
- return self._execute_query(f"CALL SYSTEM$GET_JOB_STATUS('{job_name}')")
49
-
50
- def logs(self, job_name: str, container_name: str):
51
- return self._execute_query(
52
- f"call SYSTEM$GET_JOB_LOGS('{job_name}', '{container_name}')"
53
- )
@@ -1,30 +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.api.plugins.command import (
16
- SNOWCLI_ROOT_COMMAND_PATH,
17
- CommandSpec,
18
- CommandType,
19
- plugin_hook_impl,
20
- )
21
- from snowflake.cli.plugins.spcs import app
22
-
23
-
24
- @plugin_hook_impl
25
- def command_spec():
26
- return CommandSpec(
27
- parent_command_path=SNOWCLI_ROOT_COMMAND_PATH,
28
- command_type=CommandType.COMMAND_GROUP,
29
- typer_instance=app.create_instance(),
30
- )
@@ -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.