snowflake-cli 3.1.0__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.
- snowflake/cli/__about__.py +1 -1
- snowflake/cli/_app/dev/docs/templates/usage.rst.jinja2 +1 -1
- snowflake/cli/_plugins/connection/commands.py +124 -109
- snowflake/cli/_plugins/connection/util.py +54 -9
- snowflake/cli/_plugins/cortex/manager.py +1 -1
- snowflake/cli/_plugins/git/manager.py +4 -4
- snowflake/cli/_plugins/nativeapp/artifacts.py +64 -10
- snowflake/cli/_plugins/nativeapp/codegen/templates/templates_processor.py +5 -3
- snowflake/cli/_plugins/nativeapp/commands.py +10 -3
- snowflake/cli/_plugins/nativeapp/constants.py +1 -0
- snowflake/cli/_plugins/nativeapp/entities/application.py +501 -440
- snowflake/cli/_plugins/nativeapp/entities/application_package.py +563 -885
- snowflake/cli/_plugins/nativeapp/entities/models/event_sharing_telemetry.py +58 -0
- snowflake/cli/_plugins/nativeapp/same_account_install_method.py +0 -2
- snowflake/cli/_plugins/nativeapp/sf_facade.py +30 -0
- snowflake/cli/_plugins/nativeapp/sf_facade_constants.py +25 -0
- snowflake/cli/_plugins/nativeapp/sf_facade_exceptions.py +117 -0
- snowflake/cli/_plugins/nativeapp/sf_sql_facade.py +525 -0
- snowflake/cli/_plugins/nativeapp/v2_conversions/compat.py +1 -89
- snowflake/cli/_plugins/nativeapp/version/commands.py +6 -3
- snowflake/cli/_plugins/notebook/manager.py +2 -2
- snowflake/cli/_plugins/object/commands.py +10 -1
- snowflake/cli/_plugins/object/manager.py +13 -5
- snowflake/cli/_plugins/snowpark/common.py +3 -3
- snowflake/cli/_plugins/snowpark/package/anaconda_packages.py +1 -1
- snowflake/cli/_plugins/spcs/common.py +29 -0
- snowflake/cli/_plugins/spcs/compute_pool/manager.py +7 -9
- snowflake/cli/_plugins/spcs/image_registry/manager.py +2 -2
- snowflake/cli/_plugins/spcs/image_repository/manager.py +1 -1
- snowflake/cli/_plugins/spcs/services/commands.py +64 -13
- snowflake/cli/_plugins/spcs/services/manager.py +75 -15
- snowflake/cli/_plugins/sql/commands.py +9 -1
- snowflake/cli/_plugins/sql/manager.py +9 -4
- snowflake/cli/_plugins/stage/commands.py +20 -16
- snowflake/cli/_plugins/stage/diff.py +1 -1
- snowflake/cli/_plugins/stage/manager.py +140 -11
- snowflake/cli/_plugins/streamlit/manager.py +5 -5
- snowflake/cli/_plugins/workspace/commands.py +6 -3
- snowflake/cli/api/cli_global_context.py +1 -0
- snowflake/cli/api/config.py +23 -5
- snowflake/cli/api/console/console.py +4 -19
- snowflake/cli/api/entities/utils.py +19 -32
- snowflake/cli/api/errno.py +2 -0
- snowflake/cli/api/exceptions.py +9 -0
- snowflake/cli/api/metrics.py +223 -7
- snowflake/cli/api/output/types.py +1 -1
- snowflake/cli/api/project/definition_conversion.py +179 -62
- snowflake/cli/api/rest_api.py +26 -4
- snowflake/cli/api/secure_utils.py +1 -1
- snowflake/cli/api/sql_execution.py +35 -22
- snowflake/cli/api/stage_path.py +5 -2
- {snowflake_cli-3.1.0.dist-info → snowflake_cli-3.2.0.dist-info}/METADATA +7 -8
- {snowflake_cli-3.1.0.dist-info → snowflake_cli-3.2.0.dist-info}/RECORD +56 -55
- {snowflake_cli-3.1.0.dist-info → snowflake_cli-3.2.0.dist-info}/WHEEL +1 -1
- snowflake/cli/_plugins/nativeapp/manager.py +0 -392
- snowflake/cli/_plugins/nativeapp/project_model.py +0 -211
- snowflake/cli/_plugins/nativeapp/run_processor.py +0 -184
- snowflake/cli/_plugins/nativeapp/version/version_processor.py +0 -56
- {snowflake_cli-3.1.0.dist-info → snowflake_cli-3.2.0.dist-info}/entry_points.txt +0 -0
- {snowflake_cli-3.1.0.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,56 +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
|
-
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.api.console import cli_console as cc
|
|
28
|
-
from snowflake.cli.api.project.schemas.v1.native_app.native_app import NativeApp
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
class NativeAppVersionDropProcessor(NativeAppManager, NativeAppCommandProcessor):
|
|
32
|
-
def __init__(self, project_definition: NativeApp, project_root: Path):
|
|
33
|
-
super().__init__(project_definition, project_root)
|
|
34
|
-
|
|
35
|
-
def process(
|
|
36
|
-
self,
|
|
37
|
-
version: Optional[str],
|
|
38
|
-
force: bool,
|
|
39
|
-
interactive: bool,
|
|
40
|
-
*args,
|
|
41
|
-
**kwargs,
|
|
42
|
-
):
|
|
43
|
-
return ApplicationPackageEntity.version_drop(
|
|
44
|
-
console=cc,
|
|
45
|
-
project_root=self.project_root,
|
|
46
|
-
deploy_root=self.deploy_root,
|
|
47
|
-
bundle_root=self.bundle_root,
|
|
48
|
-
generated_root=self.generated_root,
|
|
49
|
-
artifacts=self.artifacts,
|
|
50
|
-
package_name=self.package_name,
|
|
51
|
-
package_role=self.package_role,
|
|
52
|
-
package_distribution=self.package_distribution,
|
|
53
|
-
version=version,
|
|
54
|
-
force=force,
|
|
55
|
-
interactive=interactive,
|
|
56
|
-
)
|
|
File without changes
|
|
File without changes
|