snowflake-cli-labs 3.0.0rc2__py3-none-any.whl → 3.0.0rc3__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/commands_registration/builtin_plugins.py +2 -0
- snowflake/cli/_app/secret.py +9 -0
- snowflake/cli/_app/snow_connector.py +39 -27
- snowflake/cli/_plugins/git/manager.py +53 -7
- snowflake/cli/_plugins/helpers/commands.py +57 -0
- snowflake/cli/{api/project/schemas/snowpark/__init__.py → _plugins/helpers/plugin_spec.py} +17 -0
- snowflake/cli/{api/entities → _plugins/nativeapp}/application_entity.py +18 -64
- snowflake/cli/{api/project/schemas/entities → _plugins/nativeapp}/application_entity_model.py +2 -2
- snowflake/cli/{api/entities → _plugins/nativeapp}/application_package_entity.py +482 -33
- snowflake/cli/{api/project/schemas/entities → _plugins/nativeapp}/application_package_entity_model.py +3 -3
- snowflake/cli/_plugins/nativeapp/artifacts.py +10 -9
- snowflake/cli/_plugins/nativeapp/bundle_context.py +1 -1
- snowflake/cli/_plugins/nativeapp/codegen/artifact_processor.py +1 -1
- snowflake/cli/_plugins/nativeapp/codegen/compiler.py +1 -1
- snowflake/cli/_plugins/nativeapp/codegen/setup/native_app_setup_processor.py +1 -1
- snowflake/cli/_plugins/nativeapp/codegen/snowpark/extension_function_utils.py +1 -1
- snowflake/cli/_plugins/nativeapp/codegen/snowpark/models.py +1 -1
- snowflake/cli/_plugins/nativeapp/codegen/snowpark/python_processor.py +1 -1
- snowflake/cli/_plugins/nativeapp/codegen/templates/templates_processor.py +1 -1
- snowflake/cli/_plugins/nativeapp/commands.py +84 -16
- snowflake/cli/_plugins/nativeapp/exceptions.py +0 -9
- snowflake/cli/_plugins/nativeapp/manager.py +14 -9
- snowflake/cli/_plugins/nativeapp/policy.py +3 -0
- snowflake/cli/_plugins/nativeapp/project_model.py +2 -2
- snowflake/cli/_plugins/nativeapp/run_processor.py +16 -19
- snowflake/cli/_plugins/nativeapp/same_account_install_method.py +0 -4
- snowflake/cli/_plugins/nativeapp/teardown_processor.py +6 -6
- snowflake/cli/_plugins/nativeapp/v2_conversions/v2_to_v1_decorator.py +124 -88
- snowflake/cli/_plugins/nativeapp/version/commands.py +6 -24
- snowflake/cli/_plugins/nativeapp/version/version_processor.py +35 -235
- snowflake/cli/_plugins/snowpark/commands.py +4 -4
- snowflake/cli/_plugins/snowpark/common.py +4 -4
- snowflake/cli/{api/entities → _plugins/snowpark}/snowpark_entity.py +2 -2
- snowflake/cli/{api/project/schemas/entities/snowpark_entity.py → _plugins/snowpark/snowpark_entity_model.py} +3 -6
- snowflake/cli/_plugins/snowpark/snowpark_project_paths.py +1 -1
- snowflake/cli/_plugins/stage/manager.py +9 -4
- snowflake/cli/_plugins/streamlit/commands.py +3 -3
- snowflake/cli/_plugins/streamlit/manager.py +8 -4
- snowflake/cli/{api/entities → _plugins/streamlit}/streamlit_entity.py +2 -2
- snowflake/cli/{api/project/schemas/entities → _plugins/streamlit}/streamlit_entity_model.py +5 -12
- snowflake/cli/_plugins/workspace/commands.py +83 -36
- snowflake/cli/_plugins/workspace/plugin_spec.py +1 -1
- snowflake/cli/api/commands/snow_typer.py +1 -1
- snowflake/cli/api/entities/common.py +3 -0
- snowflake/cli/api/entities/utils.py +0 -14
- snowflake/cli/api/errno.py +1 -0
- snowflake/cli/api/identifiers.py +4 -3
- snowflake/cli/api/project/definition_conversion.py +10 -9
- snowflake/cli/api/project/schemas/entities/common.py +17 -4
- snowflake/cli/api/project/schemas/entities/entities.py +13 -10
- snowflake/cli/api/project/schemas/project_definition.py +6 -6
- snowflake/cli/api/project/schemas/v1/__init__.py +0 -0
- snowflake/cli/api/project/schemas/{identifier_model.py → v1/identifier_model.py} +0 -7
- snowflake/cli/api/project/schemas/v1/native_app/__init__.py +0 -0
- snowflake/cli/api/project/schemas/{native_app → v1/native_app}/native_app.py +4 -4
- snowflake/cli/api/project/schemas/v1/snowpark/__init__.py +0 -0
- snowflake/cli/api/project/schemas/{snowpark → v1/snowpark}/callable.py +2 -2
- snowflake/cli/api/project/schemas/{snowpark → v1/snowpark}/snowpark.py +2 -2
- snowflake/cli/api/project/schemas/v1/streamlit/__init__.py +0 -0
- snowflake/cli/api/project/schemas/{streamlit → v1/streamlit}/streamlit.py +2 -1
- snowflake/cli/api/sql_execution.py +6 -15
- {snowflake_cli_labs-3.0.0rc2.dist-info → snowflake_cli_labs-3.0.0rc3.dist-info}/METADATA +6 -6
- {snowflake_cli_labs-3.0.0rc2.dist-info → snowflake_cli_labs-3.0.0rc3.dist-info}/RECORD +72 -67
- snowflake/cli/api/project/schemas/streamlit/__init__.py +0 -13
- /snowflake/cli/{api/project/schemas/native_app → _plugins/helpers}/__init__.py +0 -0
- /snowflake/cli/api/project/schemas/{native_app → v1/native_app}/application.py +0 -0
- /snowflake/cli/api/project/schemas/{native_app → v1/native_app}/package.py +0 -0
- /snowflake/cli/api/project/schemas/{native_app → v1/native_app}/path_mapping.py +0 -0
- /snowflake/cli/api/project/schemas/{snowpark → v1/snowpark}/argument.py +0 -0
- {snowflake_cli_labs-3.0.0rc2.dist-info → snowflake_cli_labs-3.0.0rc3.dist-info}/WHEEL +0 -0
- {snowflake_cli_labs-3.0.0rc2.dist-info → snowflake_cli_labs-3.0.0rc3.dist-info}/entry_points.txt +0 -0
- {snowflake_cli_labs-3.0.0rc2.dist-info → snowflake_cli_labs-3.0.0rc3.dist-info}/licenses/LICENSE +0 -0
|
@@ -22,7 +22,8 @@ from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Tupl
|
|
|
22
22
|
|
|
23
23
|
from click.exceptions import ClickException
|
|
24
24
|
from snowflake.cli.api.constants import DEFAULT_SIZE_LIMIT_MB
|
|
25
|
-
from snowflake.cli.api.project.schemas.native_app.path_mapping import PathMapping
|
|
25
|
+
from snowflake.cli.api.project.schemas.v1.native_app.path_mapping import PathMapping
|
|
26
|
+
from snowflake.cli.api.project.util import to_identifier
|
|
26
27
|
from snowflake.cli.api.secure_path import SecurePath
|
|
27
28
|
from yaml import safe_load
|
|
28
29
|
|
|
@@ -734,23 +735,23 @@ def find_setup_script_file(deploy_root: Path) -> Path:
|
|
|
734
735
|
|
|
735
736
|
def find_version_info_in_manifest_file(
|
|
736
737
|
deploy_root: Path,
|
|
737
|
-
) -> Tuple[Optional[str], Optional[
|
|
738
|
+
) -> Tuple[Optional[str], Optional[int]]:
|
|
738
739
|
"""
|
|
739
740
|
Find version and patch, if available, in the manifest.yml file.
|
|
740
741
|
"""
|
|
741
|
-
version_field = "version"
|
|
742
742
|
name_field = "name"
|
|
743
743
|
patch_field = "patch"
|
|
744
744
|
|
|
745
745
|
manifest_content = find_and_read_manifest_file(deploy_root=deploy_root)
|
|
746
746
|
|
|
747
747
|
version_name: Optional[str] = None
|
|
748
|
-
|
|
748
|
+
patch_number: Optional[int] = None
|
|
749
749
|
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
750
|
+
version_info = manifest_content.get("version", None)
|
|
751
|
+
if version_info:
|
|
752
|
+
if name_field in version_info:
|
|
753
|
+
version_name = to_identifier(str(version_info[name_field]))
|
|
753
754
|
if patch_field in version_info:
|
|
754
|
-
|
|
755
|
+
patch_number = int(version_info[patch_field])
|
|
755
756
|
|
|
756
|
-
return version_name,
|
|
757
|
+
return version_name, patch_number
|
|
@@ -20,7 +20,7 @@ from typing import Optional
|
|
|
20
20
|
|
|
21
21
|
from click import ClickException
|
|
22
22
|
from snowflake.cli._plugins.nativeapp.bundle_context import BundleContext
|
|
23
|
-
from snowflake.cli.api.project.schemas.native_app.path_mapping import (
|
|
23
|
+
from snowflake.cli.api.project.schemas.v1.native_app.path_mapping import (
|
|
24
24
|
PathMapping,
|
|
25
25
|
ProcessorMapping,
|
|
26
26
|
)
|
|
@@ -35,7 +35,7 @@ from snowflake.cli._plugins.nativeapp.codegen.templates.templates_processor impo
|
|
|
35
35
|
)
|
|
36
36
|
from snowflake.cli._plugins.nativeapp.feature_flags import FeatureFlag
|
|
37
37
|
from snowflake.cli.api.console import cli_console as cc
|
|
38
|
-
from snowflake.cli.api.project.schemas.native_app.path_mapping import (
|
|
38
|
+
from snowflake.cli.api.project.schemas.v1.native_app.path_mapping import (
|
|
39
39
|
ProcessorMapping,
|
|
40
40
|
)
|
|
41
41
|
|
|
@@ -38,7 +38,7 @@ from snowflake.cli._plugins.nativeapp.codegen.sandbox import (
|
|
|
38
38
|
)
|
|
39
39
|
from snowflake.cli._plugins.stage.diff import to_stage_path
|
|
40
40
|
from snowflake.cli.api.console import cli_console as cc
|
|
41
|
-
from snowflake.cli.api.project.schemas.native_app.path_mapping import (
|
|
41
|
+
from snowflake.cli.api.project.schemas.v1.native_app.path_mapping import (
|
|
42
42
|
PathMapping,
|
|
43
43
|
ProcessorMapping,
|
|
44
44
|
)
|
|
@@ -27,7 +27,7 @@ from snowflake.cli._plugins.nativeapp.codegen.snowpark.models import (
|
|
|
27
27
|
ExtensionFunctionTypeEnum,
|
|
28
28
|
NativeAppExtensionFunction,
|
|
29
29
|
)
|
|
30
|
-
from snowflake.cli.api.project.schemas.snowpark.argument import Argument
|
|
30
|
+
from snowflake.cli.api.project.schemas.v1.snowpark.argument import Argument
|
|
31
31
|
from snowflake.cli.api.project.util import (
|
|
32
32
|
is_valid_identifier,
|
|
33
33
|
is_valid_string_literal,
|
|
@@ -18,8 +18,8 @@ from enum import Enum
|
|
|
18
18
|
from typing import List, Optional
|
|
19
19
|
|
|
20
20
|
from pydantic import Field
|
|
21
|
-
from snowflake.cli.api.project.schemas.snowpark.callable import _CallableBase
|
|
22
21
|
from snowflake.cli.api.project.schemas.updatable_model import IdentifierField
|
|
22
|
+
from snowflake.cli.api.project.schemas.v1.snowpark.callable import _CallableBase
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
class ExtensionFunctionTypeEnum(str, Enum):
|
|
@@ -49,7 +49,7 @@ from snowflake.cli._plugins.nativeapp.codegen.snowpark.models import (
|
|
|
49
49
|
)
|
|
50
50
|
from snowflake.cli._plugins.stage.diff import to_stage_path
|
|
51
51
|
from snowflake.cli.api.console import cli_console as cc
|
|
52
|
-
from snowflake.cli.api.project.schemas.native_app.path_mapping import (
|
|
52
|
+
from snowflake.cli.api.project.schemas.v1.native_app.path_mapping import (
|
|
53
53
|
PathMapping,
|
|
54
54
|
ProcessorMapping,
|
|
55
55
|
)
|
|
@@ -25,7 +25,7 @@ from snowflake.cli._plugins.nativeapp.codegen.artifact_processor import (
|
|
|
25
25
|
from snowflake.cli._plugins.nativeapp.exceptions import InvalidTemplateInFileError
|
|
26
26
|
from snowflake.cli.api.cli_global_context import get_cli_context
|
|
27
27
|
from snowflake.cli.api.console import cli_console as cc
|
|
28
|
-
from snowflake.cli.api.project.schemas.native_app.path_mapping import (
|
|
28
|
+
from snowflake.cli.api.project.schemas.v1.native_app.path_mapping import (
|
|
29
29
|
PathMapping,
|
|
30
30
|
ProcessorMapping,
|
|
31
31
|
)
|
|
@@ -22,6 +22,12 @@ from textwrap import dedent
|
|
|
22
22
|
from typing import Generator, Iterable, List, Optional, cast
|
|
23
23
|
|
|
24
24
|
import typer
|
|
25
|
+
from snowflake.cli._plugins.nativeapp.application_entity_model import (
|
|
26
|
+
ApplicationEntityModel,
|
|
27
|
+
)
|
|
28
|
+
from snowflake.cli._plugins.nativeapp.application_package_entity_model import (
|
|
29
|
+
ApplicationPackageEntityModel,
|
|
30
|
+
)
|
|
25
31
|
from snowflake.cli._plugins.nativeapp.common_flags import (
|
|
26
32
|
ForceOption,
|
|
27
33
|
InteractiveOption,
|
|
@@ -46,6 +52,7 @@ from snowflake.cli._plugins.nativeapp.utils import (
|
|
|
46
52
|
shallow_git_clone,
|
|
47
53
|
)
|
|
48
54
|
from snowflake.cli._plugins.nativeapp.v2_conversions.v2_to_v1_decorator import (
|
|
55
|
+
find_entity,
|
|
49
56
|
nativeapp_definition_v2_to_v1,
|
|
50
57
|
)
|
|
51
58
|
from snowflake.cli._plugins.nativeapp.version.commands import app as versions_app
|
|
@@ -54,11 +61,13 @@ from snowflake.cli._plugins.stage.diff import (
|
|
|
54
61
|
compute_stage_diff,
|
|
55
62
|
)
|
|
56
63
|
from snowflake.cli._plugins.stage.utils import print_diff_to_console
|
|
64
|
+
from snowflake.cli._plugins.workspace.manager import WorkspaceManager
|
|
57
65
|
from snowflake.cli.api.cli_global_context import get_cli_context
|
|
58
66
|
from snowflake.cli.api.commands.decorators import (
|
|
59
67
|
with_project_definition,
|
|
60
68
|
)
|
|
61
69
|
from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
|
|
70
|
+
from snowflake.cli.api.entities.common import EntityActions
|
|
62
71
|
from snowflake.cli.api.exceptions import IncompatibleParametersError
|
|
63
72
|
from snowflake.cli.api.output.formats import OutputFormat
|
|
64
73
|
from snowflake.cli.api.output.types import (
|
|
@@ -69,6 +78,7 @@ from snowflake.cli.api.output.types import (
|
|
|
69
78
|
StreamResult,
|
|
70
79
|
)
|
|
71
80
|
from snowflake.cli.api.project.project_verification import assert_project_type
|
|
81
|
+
from snowflake.cli.api.project.schemas.project_definition import ProjectDefinitionV1
|
|
72
82
|
from snowflake.cli.api.secure_path import SecurePath
|
|
73
83
|
from typing_extensions import Annotated
|
|
74
84
|
|
|
@@ -160,7 +170,7 @@ def app_list_templates(**options) -> CommandResult:
|
|
|
160
170
|
|
|
161
171
|
@app.command("bundle")
|
|
162
172
|
@with_project_definition()
|
|
163
|
-
@nativeapp_definition_v2_to_v1
|
|
173
|
+
@nativeapp_definition_v2_to_v1()
|
|
164
174
|
def app_bundle(
|
|
165
175
|
**options,
|
|
166
176
|
) -> CommandResult:
|
|
@@ -181,7 +191,7 @@ def app_bundle(
|
|
|
181
191
|
|
|
182
192
|
@app.command("diff", requires_connection=True, hidden=True)
|
|
183
193
|
@with_project_definition()
|
|
184
|
-
@nativeapp_definition_v2_to_v1
|
|
194
|
+
@nativeapp_definition_v2_to_v1()
|
|
185
195
|
def app_diff(
|
|
186
196
|
**options,
|
|
187
197
|
) -> CommandResult:
|
|
@@ -208,7 +218,7 @@ def app_diff(
|
|
|
208
218
|
|
|
209
219
|
@app.command("run", requires_connection=True)
|
|
210
220
|
@with_project_definition()
|
|
211
|
-
@nativeapp_definition_v2_to_v1
|
|
221
|
+
@nativeapp_definition_v2_to_v1(app_required=True)
|
|
212
222
|
def app_run(
|
|
213
223
|
version: Optional[str] = typer.Option(
|
|
214
224
|
None,
|
|
@@ -272,7 +282,7 @@ def app_run(
|
|
|
272
282
|
|
|
273
283
|
@app.command("open", requires_connection=True)
|
|
274
284
|
@with_project_definition()
|
|
275
|
-
@nativeapp_definition_v2_to_v1
|
|
285
|
+
@nativeapp_definition_v2_to_v1(app_required=True)
|
|
276
286
|
def app_open(
|
|
277
287
|
**options,
|
|
278
288
|
) -> CommandResult:
|
|
@@ -299,7 +309,9 @@ def app_open(
|
|
|
299
309
|
|
|
300
310
|
@app.command("teardown", requires_connection=True)
|
|
301
311
|
@with_project_definition()
|
|
302
|
-
@nativeapp_definition_v2_to_v1
|
|
312
|
+
# This command doesn't use @nativeapp_definition_v2_to_v1 because it needs to
|
|
313
|
+
# be aware of PDFv2 definitions that have multiple apps created from the same package,
|
|
314
|
+
# which all need to be torn down.
|
|
303
315
|
def app_teardown(
|
|
304
316
|
force: Optional[bool] = ForceOption,
|
|
305
317
|
cascade: Optional[bool] = typer.Option(
|
|
@@ -308,26 +320,70 @@ def app_teardown(
|
|
|
308
320
|
show_default=False,
|
|
309
321
|
),
|
|
310
322
|
interactive: bool = InteractiveOption,
|
|
323
|
+
# Same as the param auto-added by @nativeapp_definition_v2_to_v1
|
|
324
|
+
package_entity_id: Optional[str] = typer.Option(
|
|
325
|
+
default="",
|
|
326
|
+
help="The ID of the package entity on which to operate when definition_version is 2 or higher.",
|
|
327
|
+
),
|
|
311
328
|
**options,
|
|
312
329
|
) -> CommandResult:
|
|
313
330
|
"""
|
|
314
331
|
Attempts to drop both the application object and application package as defined in the project definition file.
|
|
315
332
|
"""
|
|
333
|
+
cli_context = get_cli_context()
|
|
334
|
+
project = cli_context.project_definition
|
|
335
|
+
if isinstance(project, ProjectDefinitionV1):
|
|
336
|
+
# Old behaviour, not multi-app aware so we can use the old processor
|
|
337
|
+
processor = NativeAppTeardownProcessor(
|
|
338
|
+
project_definition=cli_context.project_definition.native_app,
|
|
339
|
+
project_root=cli_context.project_root,
|
|
340
|
+
)
|
|
341
|
+
processor.process(interactive, force, cascade)
|
|
342
|
+
else:
|
|
343
|
+
# New behaviour, multi-app aware so teardown all the apps created from the package
|
|
344
|
+
|
|
345
|
+
# Determine the package entity to drop, there must be one
|
|
346
|
+
app_package_entity = find_entity(
|
|
347
|
+
project,
|
|
348
|
+
ApplicationPackageEntityModel,
|
|
349
|
+
package_entity_id,
|
|
350
|
+
disambiguation_option="--package-entity-id",
|
|
351
|
+
required=True,
|
|
352
|
+
)
|
|
353
|
+
assert app_package_entity is not None # satisfy mypy
|
|
316
354
|
|
|
317
|
-
|
|
355
|
+
# Same implementation as `snow ws drop`
|
|
356
|
+
ws = WorkspaceManager(
|
|
357
|
+
project_definition=cli_context.project_definition,
|
|
358
|
+
project_root=cli_context.project_root,
|
|
359
|
+
)
|
|
360
|
+
for app_entity in project.get_entities_by_type(
|
|
361
|
+
ApplicationEntityModel.get_type()
|
|
362
|
+
).values():
|
|
363
|
+
# Drop each app
|
|
364
|
+
if app_entity.from_.target == app_package_entity.entity_id:
|
|
365
|
+
ws.perform_action(
|
|
366
|
+
app_entity.entity_id,
|
|
367
|
+
EntityActions.DROP,
|
|
368
|
+
force_drop=force,
|
|
369
|
+
interactive=interactive,
|
|
370
|
+
cascade=cascade,
|
|
371
|
+
)
|
|
372
|
+
# Then drop the package
|
|
373
|
+
ws.perform_action(
|
|
374
|
+
app_package_entity.entity_id,
|
|
375
|
+
EntityActions.DROP,
|
|
376
|
+
force_drop=force,
|
|
377
|
+
interactive=interactive,
|
|
378
|
+
cascade=cascade,
|
|
379
|
+
)
|
|
318
380
|
|
|
319
|
-
cli_context = get_cli_context()
|
|
320
|
-
processor = NativeAppTeardownProcessor(
|
|
321
|
-
project_definition=cli_context.project_definition.native_app,
|
|
322
|
-
project_root=cli_context.project_root,
|
|
323
|
-
)
|
|
324
|
-
processor.process(interactive, force, cascade)
|
|
325
381
|
return MessageResult(f"Teardown is now complete.")
|
|
326
382
|
|
|
327
383
|
|
|
328
384
|
@app.command("deploy", requires_connection=True)
|
|
329
385
|
@with_project_definition()
|
|
330
|
-
@nativeapp_definition_v2_to_v1
|
|
386
|
+
@nativeapp_definition_v2_to_v1()
|
|
331
387
|
def app_deploy(
|
|
332
388
|
prune: Optional[bool] = typer.Option(
|
|
333
389
|
default=None,
|
|
@@ -350,6 +406,8 @@ def app_deploy(
|
|
|
350
406
|
unspecified, the command syncs all local changes to the stage."""
|
|
351
407
|
).strip(),
|
|
352
408
|
),
|
|
409
|
+
interactive: bool = InteractiveOption,
|
|
410
|
+
force: Optional[bool] = ForceOption,
|
|
353
411
|
validate: bool = ValidateOption,
|
|
354
412
|
**options,
|
|
355
413
|
) -> CommandResult:
|
|
@@ -360,6 +418,13 @@ def app_deploy(
|
|
|
360
418
|
|
|
361
419
|
assert_project_type("native_app")
|
|
362
420
|
|
|
421
|
+
if force:
|
|
422
|
+
policy = AllowAlwaysPolicy()
|
|
423
|
+
elif interactive:
|
|
424
|
+
policy = AskAlwaysPolicy()
|
|
425
|
+
else:
|
|
426
|
+
policy = DenyAlwaysPolicy()
|
|
427
|
+
|
|
363
428
|
has_paths = paths is not None and len(paths) > 0
|
|
364
429
|
if prune is None and recursive is None and not has_paths:
|
|
365
430
|
prune = True
|
|
@@ -386,6 +451,7 @@ def app_deploy(
|
|
|
386
451
|
recursive=recursive,
|
|
387
452
|
local_paths_to_sync=paths,
|
|
388
453
|
validate=validate,
|
|
454
|
+
policy=policy,
|
|
389
455
|
)
|
|
390
456
|
|
|
391
457
|
return MessageResult(
|
|
@@ -395,8 +461,10 @@ def app_deploy(
|
|
|
395
461
|
|
|
396
462
|
@app.command("validate", requires_connection=True)
|
|
397
463
|
@with_project_definition()
|
|
398
|
-
@nativeapp_definition_v2_to_v1
|
|
399
|
-
def app_validate(
|
|
464
|
+
@nativeapp_definition_v2_to_v1()
|
|
465
|
+
def app_validate(
|
|
466
|
+
**options,
|
|
467
|
+
):
|
|
400
468
|
"""
|
|
401
469
|
Validates a deployed Snowflake Native App's setup script.
|
|
402
470
|
"""
|
|
@@ -428,7 +496,7 @@ DEFAULT_EVENT_FOLLOW_LAST = 20
|
|
|
428
496
|
|
|
429
497
|
@app.command("events", requires_connection=True)
|
|
430
498
|
@with_project_definition()
|
|
431
|
-
@nativeapp_definition_v2_to_v1
|
|
499
|
+
@nativeapp_definition_v2_to_v1(app_required=True)
|
|
432
500
|
def app_events(
|
|
433
501
|
since: str = typer.Option(
|
|
434
502
|
default="",
|
|
@@ -48,15 +48,6 @@ class ApplicationCreatedExternallyError(ClickException):
|
|
|
48
48
|
)
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
class UnexpectedOwnerError(ClickException):
|
|
52
|
-
"""An operation is blocked because an object is owned by an unexpected role."""
|
|
53
|
-
|
|
54
|
-
def __init__(self, item: str, expected_owner: str, actual_owner: str):
|
|
55
|
-
super().__init__(
|
|
56
|
-
f"Cannot operate on {item}: owned by {actual_owner} (expected {expected_owner})"
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
|
|
60
51
|
class MissingScriptError(ClickException):
|
|
61
52
|
"""A referenced script was not found."""
|
|
62
53
|
|
|
@@ -23,12 +23,20 @@ from textwrap import dedent
|
|
|
23
23
|
from typing import Generator, List, Optional
|
|
24
24
|
|
|
25
25
|
from snowflake.cli._plugins.connection.util import make_snowsight_url
|
|
26
|
+
from snowflake.cli._plugins.nativeapp.application_entity import (
|
|
27
|
+
ApplicationEntity,
|
|
28
|
+
ApplicationOwnedObject,
|
|
29
|
+
)
|
|
30
|
+
from snowflake.cli._plugins.nativeapp.application_package_entity import (
|
|
31
|
+
ApplicationPackageEntity,
|
|
32
|
+
)
|
|
26
33
|
from snowflake.cli._plugins.nativeapp.artifacts import (
|
|
27
34
|
BundleMap,
|
|
28
35
|
)
|
|
29
36
|
from snowflake.cli._plugins.nativeapp.exceptions import (
|
|
30
37
|
NoEventTableForAccount,
|
|
31
38
|
)
|
|
39
|
+
from snowflake.cli._plugins.nativeapp.policy import AllowAlwaysPolicy, PolicyBase
|
|
32
40
|
from snowflake.cli._plugins.nativeapp.project_model import (
|
|
33
41
|
NativeAppProjectModel,
|
|
34
42
|
)
|
|
@@ -36,21 +44,14 @@ from snowflake.cli._plugins.stage.diff import (
|
|
|
36
44
|
DiffResult,
|
|
37
45
|
)
|
|
38
46
|
from snowflake.cli.api.console import cli_console as cc
|
|
39
|
-
from snowflake.cli.api.entities.application_entity import (
|
|
40
|
-
ApplicationEntity,
|
|
41
|
-
ApplicationOwnedObject,
|
|
42
|
-
)
|
|
43
|
-
from snowflake.cli.api.entities.application_package_entity import (
|
|
44
|
-
ApplicationPackageEntity,
|
|
45
|
-
)
|
|
46
47
|
from snowflake.cli.api.entities.utils import (
|
|
47
48
|
execute_post_deploy_hooks,
|
|
48
49
|
generic_sql_error_handler,
|
|
49
50
|
sync_deploy_root_with_stage,
|
|
50
51
|
)
|
|
51
52
|
from snowflake.cli.api.project.schemas.entities.common import PostDeployHook
|
|
52
|
-
from snowflake.cli.api.project.schemas.native_app.native_app import NativeApp
|
|
53
|
-
from snowflake.cli.api.project.schemas.native_app.path_mapping import PathMapping
|
|
53
|
+
from snowflake.cli.api.project.schemas.v1.native_app.native_app import NativeApp
|
|
54
|
+
from snowflake.cli.api.project.schemas.v1.native_app.path_mapping import PathMapping
|
|
54
55
|
from snowflake.cli.api.project.util import (
|
|
55
56
|
identifier_for_url,
|
|
56
57
|
unquote_identifier,
|
|
@@ -306,6 +307,7 @@ class NativeAppManager(SqlExecutionMixin):
|
|
|
306
307
|
bundle_map: BundleMap,
|
|
307
308
|
prune: bool,
|
|
308
309
|
recursive: bool,
|
|
310
|
+
policy: PolicyBase,
|
|
309
311
|
stage_fqn: Optional[str] = None,
|
|
310
312
|
local_paths_to_sync: List[Path] | None = None,
|
|
311
313
|
validate: bool = True,
|
|
@@ -318,6 +320,7 @@ class NativeAppManager(SqlExecutionMixin):
|
|
|
318
320
|
bundle_root=self.bundle_root,
|
|
319
321
|
generated_root=self.generated_root,
|
|
320
322
|
artifacts=self.artifacts,
|
|
323
|
+
bundle_map=bundle_map,
|
|
321
324
|
package_name=self.package_name,
|
|
322
325
|
package_role=self.package_role,
|
|
323
326
|
package_distribution=self.package_distribution,
|
|
@@ -330,6 +333,7 @@ class NativeAppManager(SqlExecutionMixin):
|
|
|
330
333
|
package_warehouse=self.package_warehouse,
|
|
331
334
|
post_deploy_hooks=self.package_post_deploy_hooks,
|
|
332
335
|
package_scripts=self.package_scripts,
|
|
336
|
+
policy=policy,
|
|
333
337
|
)
|
|
334
338
|
|
|
335
339
|
def deploy_to_scratch_stage_fn(self):
|
|
@@ -341,6 +345,7 @@ class NativeAppManager(SqlExecutionMixin):
|
|
|
341
345
|
stage_fqn=self.scratch_stage_fqn,
|
|
342
346
|
validate=False,
|
|
343
347
|
print_diff=False,
|
|
348
|
+
policy=AllowAlwaysPolicy(),
|
|
344
349
|
)
|
|
345
350
|
|
|
346
351
|
def validate(self, use_scratch_stage: bool = False):
|
|
@@ -27,6 +27,9 @@ class PolicyBase(ABC):
|
|
|
27
27
|
def should_proceed(self, user_prompt: Optional[str]) -> bool:
|
|
28
28
|
pass
|
|
29
29
|
|
|
30
|
+
def __eq__(self, value: object) -> bool:
|
|
31
|
+
return self.__class__ == value.__class__
|
|
32
|
+
|
|
30
33
|
|
|
31
34
|
class AllowAlwaysPolicy(PolicyBase):
|
|
32
35
|
"""Always allow a Snowflake CLI command to continue execution."""
|
|
@@ -28,8 +28,8 @@ from snowflake.cli.api.project.definition import (
|
|
|
28
28
|
default_role,
|
|
29
29
|
)
|
|
30
30
|
from snowflake.cli.api.project.schemas.entities.common import PostDeployHook
|
|
31
|
-
from snowflake.cli.api.project.schemas.native_app.native_app import NativeApp
|
|
32
|
-
from snowflake.cli.api.project.schemas.native_app.path_mapping import PathMapping
|
|
31
|
+
from snowflake.cli.api.project.schemas.v1.native_app.native_app import NativeApp
|
|
32
|
+
from snowflake.cli.api.project.schemas.v1.native_app.path_mapping import PathMapping
|
|
33
33
|
from snowflake.cli.api.project.util import (
|
|
34
34
|
append_test_resource_suffix,
|
|
35
35
|
extract_schema,
|
|
@@ -18,6 +18,12 @@ from pathlib import Path
|
|
|
18
18
|
from typing import Optional
|
|
19
19
|
|
|
20
20
|
import typer
|
|
21
|
+
from snowflake.cli._plugins.nativeapp.application_entity import (
|
|
22
|
+
ApplicationEntity,
|
|
23
|
+
)
|
|
24
|
+
from snowflake.cli._plugins.nativeapp.application_package_entity import (
|
|
25
|
+
ApplicationPackageEntity,
|
|
26
|
+
)
|
|
21
27
|
from snowflake.cli._plugins.nativeapp.artifacts import BundleMap
|
|
22
28
|
from snowflake.cli._plugins.nativeapp.manager import (
|
|
23
29
|
NativeAppCommandProcessor,
|
|
@@ -28,9 +34,6 @@ from snowflake.cli._plugins.nativeapp.same_account_install_method import (
|
|
|
28
34
|
SameAccountInstallMethod,
|
|
29
35
|
)
|
|
30
36
|
from snowflake.cli.api.console import cli_console as cc
|
|
31
|
-
from snowflake.cli.api.entities.application_entity import (
|
|
32
|
-
ApplicationEntity,
|
|
33
|
-
)
|
|
34
37
|
from snowflake.cli.api.entities.utils import (
|
|
35
38
|
generic_sql_error_handler,
|
|
36
39
|
)
|
|
@@ -38,8 +41,7 @@ from snowflake.cli.api.errno import (
|
|
|
38
41
|
APPLICATION_NO_LONGER_AVAILABLE,
|
|
39
42
|
APPLICATION_OWNS_EXTERNAL_OBJECTS,
|
|
40
43
|
)
|
|
41
|
-
from snowflake.cli.api.
|
|
42
|
-
from snowflake.cli.api.project.schemas.native_app.native_app import NativeApp
|
|
44
|
+
from snowflake.cli.api.project.schemas.v1.native_app.native_app import NativeApp
|
|
43
45
|
from snowflake.connector import ProgrammingError
|
|
44
46
|
from snowflake.connector.cursor import SnowflakeCursor
|
|
45
47
|
|
|
@@ -49,21 +51,12 @@ class NativeAppRunProcessor(NativeAppManager, NativeAppCommandProcessor):
|
|
|
49
51
|
super().__init__(project_definition, project_root)
|
|
50
52
|
|
|
51
53
|
def get_all_existing_versions(self) -> SnowflakeCursor:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"""
|
|
56
|
-
with self.use_role(self.package_role):
|
|
57
|
-
show_obj_query = f"show versions in application package {self.package_name}"
|
|
58
|
-
show_obj_cursor = self._execute_query(show_obj_query)
|
|
59
|
-
|
|
60
|
-
if show_obj_cursor.rowcount is None:
|
|
61
|
-
raise SnowflakeSQLExecutionError(show_obj_query)
|
|
62
|
-
|
|
63
|
-
return show_obj_cursor
|
|
54
|
+
return ApplicationPackageEntity.version_list(
|
|
55
|
+
self.package_name, self.package_role
|
|
56
|
+
)
|
|
64
57
|
|
|
65
58
|
def get_existing_version_info(self, version: str) -> Optional[dict]:
|
|
66
|
-
return
|
|
59
|
+
return ApplicationPackageEntity.get_existing_version_info(
|
|
67
60
|
version=version,
|
|
68
61
|
package_name=self.package_name,
|
|
69
62
|
package_role=self.package_role,
|
|
@@ -158,7 +151,11 @@ class NativeAppRunProcessor(NativeAppManager, NativeAppCommandProcessor):
|
|
|
158
151
|
):
|
|
159
152
|
def deploy_package():
|
|
160
153
|
self.deploy(
|
|
161
|
-
bundle_map=bundle_map,
|
|
154
|
+
bundle_map=bundle_map,
|
|
155
|
+
prune=True,
|
|
156
|
+
recursive=True,
|
|
157
|
+
validate=validate,
|
|
158
|
+
policy=policy,
|
|
162
159
|
)
|
|
163
160
|
|
|
164
161
|
def drop_app():
|
|
@@ -10,7 +10,6 @@ from snowflake.cli._plugins.nativeapp.exceptions import (
|
|
|
10
10
|
|
|
11
11
|
# from snowflake.cli._plugins.nativeapp.project_model import NativeAppProjectModel
|
|
12
12
|
from snowflake.cli._plugins.stage.manager import StageManager
|
|
13
|
-
from snowflake.cli.api.entities.utils import ensure_correct_owner
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
class SameAccountInstallMethod:
|
|
@@ -69,6 +68,3 @@ class SameAccountInstallMethod:
|
|
|
69
68
|
if show_app_row[COMMENT_COL] not in ALLOWED_SPECIAL_COMMENTS:
|
|
70
69
|
# this application object was not created by this tooling
|
|
71
70
|
raise ApplicationCreatedExternallyError(app_name)
|
|
72
|
-
|
|
73
|
-
# expected owner
|
|
74
|
-
ensure_correct_owner(row=show_app_row, role=app_role, obj_name=app_name)
|
|
@@ -17,17 +17,17 @@ from __future__ import annotations
|
|
|
17
17
|
from pathlib import Path
|
|
18
18
|
from typing import Dict, Optional
|
|
19
19
|
|
|
20
|
+
from snowflake.cli._plugins.nativeapp.application_entity import (
|
|
21
|
+
ApplicationEntity,
|
|
22
|
+
)
|
|
23
|
+
from snowflake.cli._plugins.nativeapp.application_package_entity import (
|
|
24
|
+
ApplicationPackageEntity,
|
|
25
|
+
)
|
|
20
26
|
from snowflake.cli._plugins.nativeapp.manager import (
|
|
21
27
|
NativeAppCommandProcessor,
|
|
22
28
|
NativeAppManager,
|
|
23
29
|
)
|
|
24
30
|
from snowflake.cli.api.console import cli_console as cc
|
|
25
|
-
from snowflake.cli.api.entities.application_entity import (
|
|
26
|
-
ApplicationEntity,
|
|
27
|
-
)
|
|
28
|
-
from snowflake.cli.api.entities.application_package_entity import (
|
|
29
|
-
ApplicationPackageEntity,
|
|
30
|
-
)
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
class NativeAppTeardownProcessor(NativeAppManager, NativeAppCommandProcessor):
|