snowflake-cli 3.0.2__py3-none-any.whl → 3.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. snowflake/cli/__about__.py +1 -1
  2. snowflake/cli/_app/cli_app.py +3 -0
  3. snowflake/cli/_app/dev/docs/templates/overview.rst.jinja2 +1 -1
  4. snowflake/cli/_app/dev/docs/templates/usage.rst.jinja2 +2 -2
  5. snowflake/cli/_app/telemetry.py +69 -4
  6. snowflake/cli/_plugins/connection/commands.py +152 -99
  7. snowflake/cli/_plugins/connection/util.py +54 -9
  8. snowflake/cli/_plugins/cortex/manager.py +1 -1
  9. snowflake/cli/_plugins/git/commands.py +6 -3
  10. snowflake/cli/_plugins/git/manager.py +9 -4
  11. snowflake/cli/_plugins/nativeapp/artifacts.py +77 -13
  12. snowflake/cli/_plugins/nativeapp/codegen/artifact_processor.py +1 -1
  13. snowflake/cli/_plugins/nativeapp/codegen/compiler.py +7 -0
  14. snowflake/cli/_plugins/nativeapp/codegen/sandbox.py +10 -10
  15. snowflake/cli/_plugins/nativeapp/codegen/setup/native_app_setup_processor.py +2 -2
  16. snowflake/cli/_plugins/nativeapp/codegen/snowpark/extension_function_utils.py +1 -1
  17. snowflake/cli/_plugins/nativeapp/codegen/snowpark/python_processor.py +8 -8
  18. snowflake/cli/_plugins/nativeapp/codegen/templates/templates_processor.py +5 -3
  19. snowflake/cli/_plugins/nativeapp/commands.py +144 -188
  20. snowflake/cli/_plugins/nativeapp/constants.py +1 -0
  21. snowflake/cli/_plugins/nativeapp/entities/application.py +564 -351
  22. snowflake/cli/_plugins/nativeapp/entities/application_package.py +583 -929
  23. snowflake/cli/_plugins/nativeapp/entities/models/event_sharing_telemetry.py +58 -0
  24. snowflake/cli/_plugins/nativeapp/exceptions.py +12 -0
  25. snowflake/cli/_plugins/nativeapp/same_account_install_method.py +0 -2
  26. snowflake/cli/_plugins/nativeapp/sf_facade.py +30 -0
  27. snowflake/cli/_plugins/nativeapp/sf_facade_constants.py +25 -0
  28. snowflake/cli/_plugins/nativeapp/sf_facade_exceptions.py +117 -0
  29. snowflake/cli/_plugins/nativeapp/sf_sql_facade.py +525 -0
  30. snowflake/cli/_plugins/nativeapp/v2_conversions/{v2_to_v1_decorator.py → compat.py} +88 -117
  31. snowflake/cli/_plugins/nativeapp/version/commands.py +36 -32
  32. snowflake/cli/_plugins/notebook/manager.py +2 -2
  33. snowflake/cli/_plugins/object/commands.py +10 -1
  34. snowflake/cli/_plugins/object/manager.py +13 -5
  35. snowflake/cli/_plugins/snowpark/common.py +63 -21
  36. snowflake/cli/_plugins/snowpark/package/anaconda_packages.py +3 -3
  37. snowflake/cli/_plugins/spcs/common.py +29 -0
  38. snowflake/cli/_plugins/spcs/compute_pool/manager.py +7 -9
  39. snowflake/cli/_plugins/spcs/image_registry/manager.py +2 -2
  40. snowflake/cli/_plugins/spcs/image_repository/commands.py +4 -37
  41. snowflake/cli/_plugins/spcs/image_repository/manager.py +4 -1
  42. snowflake/cli/_plugins/spcs/services/commands.py +100 -17
  43. snowflake/cli/_plugins/spcs/services/manager.py +108 -16
  44. snowflake/cli/_plugins/sql/commands.py +9 -1
  45. snowflake/cli/_plugins/sql/manager.py +9 -4
  46. snowflake/cli/_plugins/stage/commands.py +28 -19
  47. snowflake/cli/_plugins/stage/diff.py +17 -17
  48. snowflake/cli/_plugins/stage/manager.py +304 -84
  49. snowflake/cli/_plugins/stage/md5.py +1 -1
  50. snowflake/cli/_plugins/streamlit/manager.py +5 -5
  51. snowflake/cli/_plugins/workspace/commands.py +27 -4
  52. snowflake/cli/_plugins/workspace/context.py +38 -0
  53. snowflake/cli/_plugins/workspace/manager.py +23 -13
  54. snowflake/cli/api/cli_global_context.py +4 -3
  55. snowflake/cli/api/commands/flags.py +23 -7
  56. snowflake/cli/api/config.py +30 -9
  57. snowflake/cli/api/connections.py +12 -1
  58. snowflake/cli/api/console/console.py +4 -19
  59. snowflake/cli/api/entities/common.py +4 -2
  60. snowflake/cli/api/entities/utils.py +36 -69
  61. snowflake/cli/api/errno.py +2 -0
  62. snowflake/cli/api/exceptions.py +41 -0
  63. snowflake/cli/api/identifiers.py +8 -0
  64. snowflake/cli/api/metrics.py +223 -7
  65. snowflake/cli/api/output/types.py +1 -1
  66. snowflake/cli/api/project/definition_conversion.py +293 -77
  67. snowflake/cli/api/project/schemas/entities/common.py +11 -0
  68. snowflake/cli/api/project/schemas/project_definition.py +30 -25
  69. snowflake/cli/api/rest_api.py +26 -4
  70. snowflake/cli/api/secure_utils.py +1 -1
  71. snowflake/cli/api/sql_execution.py +40 -29
  72. snowflake/cli/api/stage_path.py +244 -0
  73. snowflake/cli/api/utils/definition_rendering.py +3 -5
  74. {snowflake_cli-3.0.2.dist-info → snowflake_cli-3.2.0.dist-info}/METADATA +14 -15
  75. {snowflake_cli-3.0.2.dist-info → snowflake_cli-3.2.0.dist-info}/RECORD +78 -77
  76. {snowflake_cli-3.0.2.dist-info → snowflake_cli-3.2.0.dist-info}/WHEEL +1 -1
  77. snowflake/cli/_plugins/nativeapp/manager.py +0 -415
  78. snowflake/cli/_plugins/nativeapp/project_model.py +0 -211
  79. snowflake/cli/_plugins/nativeapp/run_processor.py +0 -184
  80. snowflake/cli/_plugins/nativeapp/teardown_processor.py +0 -70
  81. snowflake/cli/_plugins/nativeapp/version/version_processor.py +0 -98
  82. snowflake/cli/_plugins/workspace/action_context.py +0 -18
  83. {snowflake_cli-3.0.2.dist-info → snowflake_cli-3.2.0.dist-info}/entry_points.txt +0 -0
  84. {snowflake_cli-3.0.2.dist-info → snowflake_cli-3.2.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,184 +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 Optional
19
-
20
- import typer
21
- from snowflake.cli._plugins.nativeapp.artifacts import BundleMap
22
- from snowflake.cli._plugins.nativeapp.entities.application import ApplicationEntity
23
- from snowflake.cli._plugins.nativeapp.entities.application_package import (
24
- ApplicationPackageEntity,
25
- )
26
- from snowflake.cli._plugins.nativeapp.manager import (
27
- NativeAppCommandProcessor,
28
- NativeAppManager,
29
- )
30
- from snowflake.cli._plugins.nativeapp.policy import PolicyBase
31
- from snowflake.cli._plugins.nativeapp.same_account_install_method import (
32
- SameAccountInstallMethod,
33
- )
34
- from snowflake.cli.api.console import cli_console as cc
35
- from snowflake.cli.api.entities.common import get_sql_executor
36
- from snowflake.cli.api.entities.utils import (
37
- generic_sql_error_handler,
38
- )
39
- from snowflake.cli.api.errno import (
40
- APPLICATION_NO_LONGER_AVAILABLE,
41
- APPLICATION_OWNS_EXTERNAL_OBJECTS,
42
- )
43
- from snowflake.cli.api.project.schemas.v1.native_app.native_app import NativeApp
44
- from snowflake.connector import ProgrammingError
45
- from snowflake.connector.cursor import SnowflakeCursor
46
-
47
-
48
- class NativeAppRunProcessor(NativeAppManager, NativeAppCommandProcessor):
49
- def __init__(self, project_definition: NativeApp, project_root: Path):
50
- super().__init__(project_definition, project_root)
51
-
52
- def get_all_existing_versions(self) -> SnowflakeCursor:
53
- return ApplicationPackageEntity.version_list(
54
- self.package_name, self.package_role
55
- )
56
-
57
- def get_existing_version_info(self, version: str) -> Optional[dict]:
58
- return ApplicationPackageEntity.get_existing_version_info(
59
- version=version,
60
- package_name=self.package_name,
61
- package_role=self.package_role,
62
- )
63
-
64
- def drop_application_before_upgrade(
65
- self, policy: PolicyBase, is_interactive: bool, cascade: bool = False
66
- ):
67
- """
68
- This method will attempt to drop an application object if a previous upgrade fails.
69
- """
70
- if cascade:
71
- try:
72
- if application_objects := self.get_objects_owned_by_application():
73
- application_objects_str = self._application_objects_to_str(
74
- application_objects
75
- )
76
- cc.message(
77
- f"The following objects are owned by application {self.app_name} and need to be dropped:\n{application_objects_str}"
78
- )
79
- except ProgrammingError as err:
80
- if err.errno != APPLICATION_NO_LONGER_AVAILABLE:
81
- generic_sql_error_handler(err)
82
- cc.warning(
83
- "The application owns other objects but they could not be determined."
84
- )
85
- user_prompt = "Do you want the Snowflake CLI to drop these objects, then drop the existing application object and recreate it?"
86
- else:
87
- user_prompt = "Do you want the Snowflake CLI to drop the existing application object and recreate it?"
88
-
89
- if not policy.should_proceed(user_prompt):
90
- if is_interactive:
91
- cc.message("Not upgrading the application object.")
92
- raise typer.Exit(0)
93
- else:
94
- cc.message(
95
- "Cannot upgrade the application object non-interactively without --force."
96
- )
97
- raise typer.Exit(1)
98
- try:
99
- cascade_msg = " (cascade)" if cascade else ""
100
- cc.step(f"Dropping application object {self.app_name}{cascade_msg}.")
101
- cascade_sql = " cascade" if cascade else ""
102
- sql_executor = get_sql_executor()
103
- sql_executor.execute_query(f"drop application {self.app_name}{cascade_sql}")
104
- except ProgrammingError as err:
105
- if err.errno == APPLICATION_OWNS_EXTERNAL_OBJECTS and not cascade:
106
- # We need to cascade the deletion, let's try again (only if we didn't try with cascade already)
107
- return self.drop_application_before_upgrade(
108
- policy, is_interactive, cascade=True
109
- )
110
- else:
111
- generic_sql_error_handler(err)
112
-
113
- def create_or_upgrade_app(
114
- self,
115
- policy: PolicyBase,
116
- install_method: SameAccountInstallMethod,
117
- is_interactive: bool = False,
118
- ):
119
- def drop_app():
120
- self.drop_application_before_upgrade(policy, is_interactive)
121
-
122
- return ApplicationEntity.create_or_upgrade_app(
123
- console=cc,
124
- project_root=self.project_root,
125
- package_name=self.package_name,
126
- package_role=self.package_role,
127
- app_name=self.app_name,
128
- app_role=self.app_role,
129
- app_warehouse=self.application_warehouse,
130
- stage_schema=self.stage_schema,
131
- stage_fqn=self.stage_fqn,
132
- debug_mode=self.debug_mode,
133
- policy=policy,
134
- install_method=install_method,
135
- is_interactive=is_interactive,
136
- post_deploy_hooks=self.app_post_deploy_hooks,
137
- drop_application_before_upgrade=drop_app,
138
- )
139
-
140
- def process(
141
- self,
142
- bundle_map: BundleMap,
143
- policy: PolicyBase,
144
- version: Optional[str] = None,
145
- patch: Optional[int] = None,
146
- from_release_directive: bool = False,
147
- is_interactive: bool = False,
148
- validate: bool = True,
149
- *args,
150
- **kwargs,
151
- ):
152
- def deploy_package():
153
- self.deploy(
154
- bundle_map=bundle_map,
155
- prune=True,
156
- recursive=True,
157
- validate=validate,
158
- policy=policy,
159
- )
160
-
161
- def drop_app():
162
- self.drop_application_before_upgrade(policy, is_interactive)
163
-
164
- ApplicationEntity.deploy(
165
- console=cc,
166
- project_root=self.project_root,
167
- app_name=self.app_name,
168
- app_role=self.app_role,
169
- app_warehouse=self.application_warehouse,
170
- package_name=self.package_name,
171
- package_role=self.package_role,
172
- stage_schema=self.stage_schema,
173
- stage_fqn=self.stage_fqn,
174
- debug_mode=self.debug_mode,
175
- validate=validate,
176
- from_release_directive=from_release_directive,
177
- is_interactive=is_interactive,
178
- policy=policy,
179
- version=version,
180
- patch=patch,
181
- post_deploy_hooks=self.app_post_deploy_hooks,
182
- deploy_package=deploy_package,
183
- drop_application_before_upgrade=drop_app,
184
- )
@@ -1,70 +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 import ApplicationEntity
21
- from snowflake.cli._plugins.nativeapp.entities.application_package import (
22
- ApplicationPackageEntity,
23
- )
24
- from snowflake.cli._plugins.nativeapp.manager import (
25
- NativeAppCommandProcessor,
26
- NativeAppManager,
27
- )
28
- from snowflake.cli.api.console import cli_console as cc
29
-
30
-
31
- class NativeAppTeardownProcessor(NativeAppManager, NativeAppCommandProcessor):
32
- def __init__(self, project_definition: Dict, project_root: Path):
33
- super().__init__(project_definition, project_root)
34
-
35
- def drop_application(
36
- self, auto_yes: bool, interactive: bool = False, cascade: Optional[bool] = None
37
- ):
38
- return ApplicationEntity.drop(
39
- console=cc,
40
- app_name=self.app_name,
41
- app_role=self.app_role,
42
- auto_yes=auto_yes,
43
- interactive=interactive,
44
- cascade=cascade,
45
- )
46
-
47
- def drop_package(self, auto_yes: bool):
48
- return ApplicationPackageEntity.drop(
49
- console=cc,
50
- package_name=self.package_name,
51
- package_role=self.package_role,
52
- force_drop=auto_yes,
53
- )
54
-
55
- def process(
56
- self,
57
- interactive: bool,
58
- force_drop: bool = False,
59
- cascade: Optional[bool] = None,
60
- *args,
61
- **kwargs,
62
- ):
63
-
64
- # Drop the application object
65
- self.drop_application(
66
- auto_yes=force_drop, interactive=interactive, cascade=cascade
67
- )
68
-
69
- # Drop the application package
70
- self.drop_package(auto_yes=force_drop)
@@ -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,18 +0,0 @@
1
- from dataclasses import dataclass
2
- from pathlib import Path
3
- from typing import Callable, Optional
4
-
5
- from snowflake.cli.api.console.abc import AbstractConsole
6
-
7
-
8
- @dataclass
9
- class ActionContext:
10
- """
11
- An object that is passed to each action when called by WorkspaceManager
12
- """
13
-
14
- console: AbstractConsole
15
- project_root: Path
16
- default_role: str
17
- default_warehouse: Optional[str]
18
- get_entity: Callable