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
|
@@ -21,6 +21,10 @@ from typing import Dict, List, Set
|
|
|
21
21
|
|
|
22
22
|
from click import UsageError
|
|
23
23
|
from snowflake.cli._plugins.snowpark.models import Requirement
|
|
24
|
+
from snowflake.cli._plugins.snowpark.snowpark_entity_model import (
|
|
25
|
+
ProcedureEntityModel,
|
|
26
|
+
SnowparkEntityModel,
|
|
27
|
+
)
|
|
24
28
|
from snowflake.cli._plugins.snowpark.snowpark_project_paths import Artefact
|
|
25
29
|
from snowflake.cli.api.console import cli_console
|
|
26
30
|
from snowflake.cli.api.constants import (
|
|
@@ -30,10 +34,6 @@ from snowflake.cli.api.constants import (
|
|
|
30
34
|
PROJECT_TEMPLATE_VARIABLE_OPENING,
|
|
31
35
|
ObjectType,
|
|
32
36
|
)
|
|
33
|
-
from snowflake.cli.api.project.schemas.entities.snowpark_entity import (
|
|
34
|
-
ProcedureEntityModel,
|
|
35
|
-
SnowparkEntityModel,
|
|
36
|
-
)
|
|
37
37
|
from snowflake.cli.api.sql_execution import SqlExecutionMixin
|
|
38
38
|
from snowflake.connector.cursor import SnowflakeCursor
|
|
39
39
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
from typing import Generic, TypeVar
|
|
2
2
|
|
|
3
|
-
from snowflake.cli.
|
|
4
|
-
from snowflake.cli.api.project.schemas.entities.snowpark_entity import (
|
|
3
|
+
from snowflake.cli._plugins.snowpark.snowpark_entity_model import (
|
|
5
4
|
FunctionEntityModel,
|
|
6
5
|
ProcedureEntityModel,
|
|
7
6
|
)
|
|
7
|
+
from snowflake.cli.api.entities.common import EntityBase
|
|
8
8
|
|
|
9
9
|
T = TypeVar("T")
|
|
10
10
|
|
|
@@ -22,12 +22,13 @@ from snowflake.cli.api.identifiers import FQN
|
|
|
22
22
|
from snowflake.cli.api.project.schemas.entities.common import (
|
|
23
23
|
EntityModelBase,
|
|
24
24
|
ExternalAccessBaseModel,
|
|
25
|
+
ImportsBaseModel,
|
|
25
26
|
)
|
|
26
|
-
from snowflake.cli.api.project.schemas.snowpark.argument import Argument
|
|
27
27
|
from snowflake.cli.api.project.schemas.updatable_model import (
|
|
28
28
|
DiscriminatorField,
|
|
29
29
|
UpdatableModel,
|
|
30
30
|
)
|
|
31
|
+
from snowflake.cli.api.project.schemas.v1.snowpark.argument import Argument
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
class PathMapping(UpdatableModel):
|
|
@@ -43,7 +44,7 @@ class PathMapping(UpdatableModel):
|
|
|
43
44
|
)
|
|
44
45
|
|
|
45
46
|
|
|
46
|
-
class SnowparkEntityModel(EntityModelBase, ExternalAccessBaseModel):
|
|
47
|
+
class SnowparkEntityModel(EntityModelBase, ExternalAccessBaseModel, ImportsBaseModel):
|
|
47
48
|
handler: str = Field(
|
|
48
49
|
title="Function’s or procedure’s implementation of the object inside source module",
|
|
49
50
|
examples=["functions.hello_function"],
|
|
@@ -57,10 +58,6 @@ class SnowparkEntityModel(EntityModelBase, ExternalAccessBaseModel):
|
|
|
57
58
|
runtime: Optional[Union[str, float]] = Field(
|
|
58
59
|
title="Python version to use when executing ", default=None
|
|
59
60
|
)
|
|
60
|
-
imports: Optional[List[str]] = Field(
|
|
61
|
-
title="Stage and path to previously uploaded files you want to import",
|
|
62
|
-
default=[],
|
|
63
|
-
)
|
|
64
61
|
stage: str = Field(title="Stage in which artifacts will be stored")
|
|
65
62
|
artifacts: List[Union[PathMapping, str]] = Field(title="List of required sources")
|
|
66
63
|
|
|
@@ -16,11 +16,11 @@ from __future__ import annotations
|
|
|
16
16
|
from dataclasses import dataclass
|
|
17
17
|
from pathlib import Path, PurePosixPath
|
|
18
18
|
|
|
19
|
+
from snowflake.cli._plugins.snowpark.snowpark_entity_model import PathMapping
|
|
19
20
|
from snowflake.cli._plugins.snowpark.zipper import zip_dir
|
|
20
21
|
from snowflake.cli.api.console import cli_console
|
|
21
22
|
from snowflake.cli.api.constants import DEPLOYMENT_STAGE
|
|
22
23
|
from snowflake.cli.api.identifiers import FQN
|
|
23
|
-
from snowflake.cli.api.project.schemas.entities.snowpark_entity import PathMapping
|
|
24
24
|
from snowflake.cli.api.secure_path import SecurePath
|
|
25
25
|
|
|
26
26
|
|
|
@@ -57,6 +57,9 @@ EXECUTE_SUPPORTED_FILES_FORMATS = (
|
|
|
57
57
|
".py",
|
|
58
58
|
) # tuple to preserve order but it's a set
|
|
59
59
|
|
|
60
|
+
# Replace magic numbers with constants
|
|
61
|
+
OMIT_FIRST = slice(1, None)
|
|
62
|
+
|
|
60
63
|
|
|
61
64
|
@dataclass
|
|
62
65
|
class StagePathParts:
|
|
@@ -67,7 +70,7 @@ class StagePathParts:
|
|
|
67
70
|
|
|
68
71
|
@classmethod
|
|
69
72
|
def get_directory(cls, stage_path: str) -> str:
|
|
70
|
-
return "/".join(Path(stage_path).parts[
|
|
73
|
+
return "/".join(Path(stage_path).parts[OMIT_FIRST])
|
|
71
74
|
|
|
72
75
|
@property
|
|
73
76
|
def path(self) -> str:
|
|
@@ -119,7 +122,9 @@ class DefaultStagePathParts(StagePathParts):
|
|
|
119
122
|
self.directory = self.get_directory(stage_path)
|
|
120
123
|
self.stage = StageManager.get_stage_from_path(stage_path)
|
|
121
124
|
stage_name = self.stage.split(".")[-1]
|
|
122
|
-
stage_name =
|
|
125
|
+
stage_name = (
|
|
126
|
+
stage_name[OMIT_FIRST] if stage_name.startswith("@") else stage_name
|
|
127
|
+
)
|
|
123
128
|
self.stage_name = stage_name
|
|
124
129
|
self.is_directory = True if stage_path.endswith("/") else False
|
|
125
130
|
|
|
@@ -133,7 +138,7 @@ class DefaultStagePathParts(StagePathParts):
|
|
|
133
138
|
|
|
134
139
|
def replace_stage_prefix(self, file_path: str) -> str:
|
|
135
140
|
stage = Path(self.stage).parts[0]
|
|
136
|
-
file_path_without_prefix = Path(file_path).parts[
|
|
141
|
+
file_path_without_prefix = Path(file_path).parts[OMIT_FIRST]
|
|
137
142
|
return f"{stage}/{'/'.join(file_path_without_prefix)}"
|
|
138
143
|
|
|
139
144
|
def add_stage_prefix(self, file_path: str) -> str:
|
|
@@ -461,7 +466,7 @@ class StageManager(SqlExecutionMixin):
|
|
|
461
466
|
on_error: OnErrorType,
|
|
462
467
|
) -> Dict:
|
|
463
468
|
try:
|
|
464
|
-
query = f"execute immediate from {file_stage_path}"
|
|
469
|
+
query = f"execute immediate from {self.quote_stage_name(file_stage_path)}"
|
|
465
470
|
if variables:
|
|
466
471
|
query += variables
|
|
467
472
|
self._execute_query(query)
|
|
@@ -26,6 +26,9 @@ from snowflake.cli._plugins.object.command_aliases import (
|
|
|
26
26
|
scope_option,
|
|
27
27
|
)
|
|
28
28
|
from snowflake.cli._plugins.streamlit.manager import StreamlitManager
|
|
29
|
+
from snowflake.cli._plugins.streamlit.streamlit_entity_model import (
|
|
30
|
+
StreamlitEntityModel,
|
|
31
|
+
)
|
|
29
32
|
from snowflake.cli.api.cli_global_context import get_cli_context
|
|
30
33
|
from snowflake.cli.api.commands.decorators import (
|
|
31
34
|
with_experimental_behaviour,
|
|
@@ -49,9 +52,6 @@ from snowflake.cli.api.output.types import (
|
|
|
49
52
|
from snowflake.cli.api.project.definition_conversion import (
|
|
50
53
|
convert_project_definition_to_v2,
|
|
51
54
|
)
|
|
52
|
-
from snowflake.cli.api.project.schemas.entities.streamlit_entity_model import (
|
|
53
|
-
StreamlitEntityModel,
|
|
54
|
-
)
|
|
55
55
|
|
|
56
56
|
app = SnowTyperFactory(
|
|
57
57
|
name="streamlit",
|
|
@@ -26,15 +26,15 @@ from snowflake.cli._plugins.connection.util import (
|
|
|
26
26
|
)
|
|
27
27
|
from snowflake.cli._plugins.object.manager import ObjectManager
|
|
28
28
|
from snowflake.cli._plugins.stage.manager import StageManager
|
|
29
|
+
from snowflake.cli._plugins.streamlit.streamlit_entity_model import (
|
|
30
|
+
StreamlitEntityModel,
|
|
31
|
+
)
|
|
29
32
|
from snowflake.cli.api.commands.experimental_behaviour import (
|
|
30
33
|
experimental_behaviour_enabled,
|
|
31
34
|
)
|
|
32
35
|
from snowflake.cli.api.console import cli_console
|
|
33
36
|
from snowflake.cli.api.feature_flags import FeatureFlag
|
|
34
37
|
from snowflake.cli.api.identifiers import FQN
|
|
35
|
-
from snowflake.cli.api.project.schemas.entities.streamlit_entity_model import (
|
|
36
|
-
StreamlitEntityModel,
|
|
37
|
-
)
|
|
38
38
|
from snowflake.cli.api.sql_execution import SqlExecutionMixin
|
|
39
39
|
from snowflake.connector.cursor import SnowflakeCursor
|
|
40
40
|
from snowflake.connector.errors import ProgrammingError
|
|
@@ -98,12 +98,16 @@ class StreamlitManager(SqlExecutionMixin):
|
|
|
98
98
|
query.append(f"ROOT_LOCATION = '{from_stage_name}'")
|
|
99
99
|
|
|
100
100
|
query.append(f"MAIN_FILE = '{streamlit.main_file}'")
|
|
101
|
-
|
|
101
|
+
if streamlit.imports:
|
|
102
|
+
query.append(streamlit.get_imports_sql())
|
|
102
103
|
if streamlit.query_warehouse:
|
|
103
104
|
query.append(f"QUERY_WAREHOUSE = {streamlit.query_warehouse}")
|
|
104
105
|
if streamlit.title:
|
|
105
106
|
query.append(f"TITLE = '{streamlit.title}'")
|
|
106
107
|
|
|
108
|
+
if streamlit.comment:
|
|
109
|
+
query.append(f"COMMENT = '{streamlit.comment}'")
|
|
110
|
+
|
|
107
111
|
if streamlit.external_access_integrations:
|
|
108
112
|
query.append(streamlit.get_external_access_integrations_sql())
|
|
109
113
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
from snowflake.cli.
|
|
2
|
-
from snowflake.cli.api.project.schemas.entities.streamlit_entity_model import (
|
|
1
|
+
from snowflake.cli._plugins.streamlit.streamlit_entity_model import (
|
|
3
2
|
StreamlitEntityModel,
|
|
4
3
|
)
|
|
4
|
+
from snowflake.cli.api.entities.common import EntityBase
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class StreamlitEntity(EntityBase[StreamlitEntityModel]):
|
|
@@ -20,17 +20,19 @@ from pydantic import Field, model_validator
|
|
|
20
20
|
from snowflake.cli.api.project.schemas.entities.common import (
|
|
21
21
|
EntityModelBase,
|
|
22
22
|
ExternalAccessBaseModel,
|
|
23
|
+
ImportsBaseModel,
|
|
23
24
|
)
|
|
24
25
|
from snowflake.cli.api.project.schemas.updatable_model import (
|
|
25
26
|
DiscriminatorField,
|
|
26
27
|
)
|
|
27
28
|
|
|
28
29
|
|
|
29
|
-
class StreamlitEntityModel(EntityModelBase, ExternalAccessBaseModel):
|
|
30
|
+
class StreamlitEntityModel(EntityModelBase, ExternalAccessBaseModel, ImportsBaseModel):
|
|
30
31
|
type: Literal["streamlit"] = DiscriminatorField() # noqa: A003
|
|
31
32
|
title: Optional[str] = Field(
|
|
32
33
|
title="Human-readable title for the Streamlit dashboard", default=None
|
|
33
34
|
)
|
|
35
|
+
comment: Optional[str] = Field(title="Comment for the Streamlit app", default=None)
|
|
34
36
|
query_warehouse: str = Field(
|
|
35
37
|
title="Snowflake warehouse to host the app", default=None
|
|
36
38
|
)
|
|
@@ -48,23 +50,14 @@ class StreamlitEntityModel(EntityModelBase, ExternalAccessBaseModel):
|
|
|
48
50
|
default=None,
|
|
49
51
|
)
|
|
50
52
|
|
|
51
|
-
@model_validator(mode="after")
|
|
52
|
-
def main_file_must_be_in_artifacts(self):
|
|
53
|
-
if not self.artifacts:
|
|
54
|
-
return self
|
|
55
|
-
|
|
56
|
-
if Path(self.main_file) not in self.artifacts:
|
|
57
|
-
raise ValueError(
|
|
58
|
-
f"Specified main file {self.main_file} is not included in artifacts."
|
|
59
|
-
)
|
|
60
|
-
return self
|
|
61
|
-
|
|
62
53
|
@model_validator(mode="after")
|
|
63
54
|
def artifacts_must_exists(self):
|
|
64
55
|
if not self.artifacts:
|
|
65
56
|
return self
|
|
66
57
|
|
|
67
58
|
for artifact in self.artifacts:
|
|
59
|
+
if "*" in artifact.name:
|
|
60
|
+
continue
|
|
68
61
|
if not artifact.exists():
|
|
69
62
|
raise ValueError(
|
|
70
63
|
f"Specified artifact {artifact} does not exist locally."
|
|
@@ -20,7 +20,7 @@ from textwrap import dedent
|
|
|
20
20
|
from typing import List, Optional
|
|
21
21
|
|
|
22
22
|
import typer
|
|
23
|
-
import
|
|
23
|
+
from click import MissingParameter
|
|
24
24
|
from snowflake.cli._plugins.nativeapp.artifacts import BundleMap
|
|
25
25
|
from snowflake.cli._plugins.nativeapp.common_flags import (
|
|
26
26
|
ForceOption,
|
|
@@ -30,50 +30,19 @@ from snowflake.cli._plugins.nativeapp.common_flags import (
|
|
|
30
30
|
from snowflake.cli._plugins.workspace.manager import WorkspaceManager
|
|
31
31
|
from snowflake.cli.api.cli_global_context import get_cli_context
|
|
32
32
|
from snowflake.cli.api.commands.decorators import with_project_definition
|
|
33
|
-
from snowflake.cli.api.commands.snow_typer import
|
|
33
|
+
from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
|
|
34
34
|
from snowflake.cli.api.entities.common import EntityActions
|
|
35
35
|
from snowflake.cli.api.exceptions import IncompatibleParametersError
|
|
36
|
-
from snowflake.cli.api.output.types import MessageResult
|
|
37
|
-
from snowflake.cli.api.project.definition_conversion import (
|
|
38
|
-
convert_project_definition_to_v2,
|
|
39
|
-
)
|
|
40
|
-
from snowflake.cli.api.project.definition_manager import DefinitionManager
|
|
41
|
-
from snowflake.cli.api.secure_path import SecurePath
|
|
36
|
+
from snowflake.cli.api.output.types import MessageResult, QueryResult
|
|
42
37
|
|
|
43
|
-
ws =
|
|
38
|
+
ws = SnowTyperFactory(
|
|
44
39
|
name="ws",
|
|
45
40
|
help="Deploy and interact with snowflake.yml-based entities.",
|
|
41
|
+
is_hidden=lambda: True,
|
|
46
42
|
)
|
|
47
43
|
log = logging.getLogger(__name__)
|
|
48
44
|
|
|
49
45
|
|
|
50
|
-
@ws.command()
|
|
51
|
-
def migrate(
|
|
52
|
-
accept_templates: bool = typer.Option(
|
|
53
|
-
False, "-t", "--accept-templates", help="Allows the migration of templates."
|
|
54
|
-
),
|
|
55
|
-
**options,
|
|
56
|
-
):
|
|
57
|
-
"""Migrates the Snowpark, Streamlit, and Native App project definition files from V1 to V2."""
|
|
58
|
-
manager = DefinitionManager()
|
|
59
|
-
pd = manager.unrendered_project_definition
|
|
60
|
-
|
|
61
|
-
if pd.meets_version_requirement("2"):
|
|
62
|
-
return MessageResult("Project definition is already at version 2.")
|
|
63
|
-
|
|
64
|
-
pd_v2 = convert_project_definition_to_v2(manager.project_root, pd, accept_templates)
|
|
65
|
-
|
|
66
|
-
SecurePath("snowflake.yml").rename("snowflake_V1.yml")
|
|
67
|
-
with open("snowflake.yml", "w") as file:
|
|
68
|
-
yaml.dump(
|
|
69
|
-
pd_v2.model_dump(
|
|
70
|
-
exclude_unset=True, exclude_none=True, mode="json", by_alias=True
|
|
71
|
-
),
|
|
72
|
-
file,
|
|
73
|
-
)
|
|
74
|
-
return MessageResult("Project definition migrated to version 2.")
|
|
75
|
-
|
|
76
|
-
|
|
77
46
|
@ws.command(requires_connection=True, hidden=True)
|
|
78
47
|
@with_project_definition()
|
|
79
48
|
def bundle(
|
|
@@ -211,6 +180,8 @@ def validate(
|
|
|
211
180
|
entity_id: str = typer.Option(
|
|
212
181
|
help=f"""The ID of the entity you want to validate.""",
|
|
213
182
|
),
|
|
183
|
+
interactive: bool = InteractiveOption,
|
|
184
|
+
force: Optional[bool] = ForceOption,
|
|
214
185
|
**options,
|
|
215
186
|
):
|
|
216
187
|
"""Validates the specified entity."""
|
|
@@ -223,4 +194,80 @@ def validate(
|
|
|
223
194
|
ws.perform_action(
|
|
224
195
|
entity_id,
|
|
225
196
|
EntityActions.VALIDATE,
|
|
197
|
+
interactive=interactive,
|
|
198
|
+
force=force,
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
version = SnowTyperFactory(
|
|
203
|
+
name="version",
|
|
204
|
+
help="Manages versions for project entities.",
|
|
205
|
+
)
|
|
206
|
+
ws.add_typer(version)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
@version.command(name="list", requires_connection=True, hidden=True)
|
|
210
|
+
@with_project_definition()
|
|
211
|
+
def version_list(
|
|
212
|
+
entity_id: str = typer.Option(
|
|
213
|
+
help="The ID of the entity you want to list versions for.",
|
|
214
|
+
),
|
|
215
|
+
**options,
|
|
216
|
+
):
|
|
217
|
+
"""Lists the versions of the specified entity."""
|
|
218
|
+
cli_context = get_cli_context()
|
|
219
|
+
ws = WorkspaceManager(
|
|
220
|
+
project_definition=cli_context.project_definition,
|
|
221
|
+
project_root=cli_context.project_root,
|
|
222
|
+
)
|
|
223
|
+
cursor = ws.perform_action(
|
|
224
|
+
entity_id,
|
|
225
|
+
EntityActions.VERSION_LIST,
|
|
226
|
+
)
|
|
227
|
+
return QueryResult(cursor)
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
@version.command(name="create", requires_connection=True, hidden=True)
|
|
231
|
+
@with_project_definition()
|
|
232
|
+
def version_create(
|
|
233
|
+
entity_id: str = typer.Option(
|
|
234
|
+
help="The ID of the entity you want to create a version for.",
|
|
235
|
+
),
|
|
236
|
+
version: Optional[str] = typer.Argument(
|
|
237
|
+
None,
|
|
238
|
+
help=f"""Version to define in your application package. If the version already exists, an auto-incremented patch is added to the version instead. Defaults to the version specified in the `manifest.yml` file.""",
|
|
239
|
+
),
|
|
240
|
+
patch: Optional[int] = typer.Option(
|
|
241
|
+
None,
|
|
242
|
+
"--patch",
|
|
243
|
+
help=f"""The patch number you want to create for an existing version.
|
|
244
|
+
Defaults to undefined if it is not set, which means the Snowflake CLI either uses the patch specified in the `manifest.yml` file or automatically generates a new patch number.""",
|
|
245
|
+
),
|
|
246
|
+
skip_git_check: Optional[bool] = typer.Option(
|
|
247
|
+
False,
|
|
248
|
+
"--skip-git-check",
|
|
249
|
+
help="When enabled, the Snowflake CLI skips checking if your project has any untracked or stages files in git. Default: unset.",
|
|
250
|
+
is_flag=True,
|
|
251
|
+
),
|
|
252
|
+
interactive: bool = InteractiveOption,
|
|
253
|
+
force: Optional[bool] = ForceOption,
|
|
254
|
+
**options,
|
|
255
|
+
):
|
|
256
|
+
"""Creates a new version for the specified entity."""
|
|
257
|
+
if version is None and patch is not None:
|
|
258
|
+
raise MissingParameter("Cannot provide a patch without version!")
|
|
259
|
+
|
|
260
|
+
cli_context = get_cli_context()
|
|
261
|
+
ws = WorkspaceManager(
|
|
262
|
+
project_definition=cli_context.project_definition,
|
|
263
|
+
project_root=cli_context.project_root,
|
|
264
|
+
)
|
|
265
|
+
ws.perform_action(
|
|
266
|
+
entity_id,
|
|
267
|
+
EntityActions.VERSION_CREATE,
|
|
268
|
+
version=version,
|
|
269
|
+
patch=patch,
|
|
270
|
+
skip_git_check=skip_git_check,
|
|
271
|
+
interactive=interactive,
|
|
272
|
+
force=force,
|
|
226
273
|
)
|
|
@@ -105,7 +105,7 @@ class SnowTyper(typer.Typer):
|
|
|
105
105
|
result = command_callable(*args, **kw)
|
|
106
106
|
self.process_result(result)
|
|
107
107
|
execution.complete(ExecutionStatus.SUCCESS)
|
|
108
|
-
except
|
|
108
|
+
except BaseException as err:
|
|
109
109
|
execution.complete(ExecutionStatus.FAILURE)
|
|
110
110
|
exception = self.exception_handler(err, execution)
|
|
111
111
|
raise exception
|
|
@@ -9,11 +9,9 @@ from snowflake.cli._plugins.nativeapp.artifacts import (
|
|
|
9
9
|
BundleMap,
|
|
10
10
|
resolve_without_follow,
|
|
11
11
|
)
|
|
12
|
-
from snowflake.cli._plugins.nativeapp.constants import OWNER_COL
|
|
13
12
|
from snowflake.cli._plugins.nativeapp.exceptions import (
|
|
14
13
|
InvalidTemplateInFileError,
|
|
15
14
|
MissingScriptError,
|
|
16
|
-
UnexpectedOwnerError,
|
|
17
15
|
)
|
|
18
16
|
from snowflake.cli._plugins.nativeapp.utils import verify_exists, verify_no_directories
|
|
19
17
|
from snowflake.cli._plugins.stage.diff import (
|
|
@@ -34,7 +32,6 @@ from snowflake.cli.api.errno import (
|
|
|
34
32
|
)
|
|
35
33
|
from snowflake.cli.api.exceptions import SnowflakeSQLExecutionError
|
|
36
34
|
from snowflake.cli.api.project.schemas.entities.common import PostDeployHook
|
|
37
|
-
from snowflake.cli.api.project.util import unquote_identifier
|
|
38
35
|
from snowflake.cli.api.rendering.sql_templates import (
|
|
39
36
|
choose_sql_jinja_env_based_on_template_syntax,
|
|
40
37
|
)
|
|
@@ -80,17 +77,6 @@ def generic_sql_error_handler(
|
|
|
80
77
|
raise err
|
|
81
78
|
|
|
82
79
|
|
|
83
|
-
def ensure_correct_owner(row: dict, role: str, obj_name: str) -> None:
|
|
84
|
-
"""
|
|
85
|
-
Check if an object has the right owner role
|
|
86
|
-
"""
|
|
87
|
-
actual_owner = row[
|
|
88
|
-
OWNER_COL
|
|
89
|
-
].upper() # Because unquote_identifier() always returns uppercase str
|
|
90
|
-
if actual_owner != unquote_identifier(role):
|
|
91
|
-
raise UnexpectedOwnerError(obj_name, role, actual_owner)
|
|
92
|
-
|
|
93
|
-
|
|
94
80
|
def _get_stage_paths_to_sync(
|
|
95
81
|
local_paths_to_sync: List[Path], deploy_root: Path
|
|
96
82
|
) -> List[StagePath]:
|
snowflake/cli/api/errno.py
CHANGED
snowflake/cli/api/identifiers.py
CHANGED
|
@@ -18,8 +18,7 @@ import re
|
|
|
18
18
|
|
|
19
19
|
from click import ClickException
|
|
20
20
|
from snowflake.cli.api.exceptions import FQNInconsistencyError, FQNNameError
|
|
21
|
-
from snowflake.cli.api.project.schemas.identifier_model import (
|
|
22
|
-
Identifier,
|
|
21
|
+
from snowflake.cli.api.project.schemas.v1.identifier_model import (
|
|
23
22
|
ObjectIdentifierBaseModel,
|
|
24
23
|
)
|
|
25
24
|
from snowflake.cli.api.project.util import VALID_IDENTIFIER_REGEX, identifier_for_url
|
|
@@ -142,8 +141,10 @@ class FQN:
|
|
|
142
141
|
return fqn.set_database(model.database).set_schema(model.schema_name)
|
|
143
142
|
|
|
144
143
|
@classmethod
|
|
145
|
-
def from_identifier_model_v2(cls, model
|
|
144
|
+
def from_identifier_model_v2(cls, model) -> "FQN":
|
|
146
145
|
"""Create an instance from object model."""
|
|
146
|
+
from snowflake.cli.api.project.schemas.entities.common import Identifier
|
|
147
|
+
|
|
147
148
|
if not isinstance(model, Identifier):
|
|
148
149
|
raise ClickException(f"Expected {type(Identifier).__name__}, got {model}.")
|
|
149
150
|
|
|
@@ -20,22 +20,22 @@ from snowflake.cli.api.entities.utils import render_script_template
|
|
|
20
20
|
from snowflake.cli.api.project.schemas.entities.common import (
|
|
21
21
|
SqlScriptHookType,
|
|
22
22
|
)
|
|
23
|
-
from snowflake.cli.api.project.schemas.native_app.application import (
|
|
24
|
-
Application,
|
|
25
|
-
ApplicationV11,
|
|
26
|
-
)
|
|
27
|
-
from snowflake.cli.api.project.schemas.native_app.native_app import NativeApp
|
|
28
|
-
from snowflake.cli.api.project.schemas.native_app.package import Package, PackageV11
|
|
29
23
|
from snowflake.cli.api.project.schemas.project_definition import (
|
|
30
24
|
ProjectDefinition,
|
|
31
25
|
ProjectDefinitionV2,
|
|
32
26
|
)
|
|
33
|
-
from snowflake.cli.api.project.schemas.
|
|
27
|
+
from snowflake.cli.api.project.schemas.v1.native_app.application import (
|
|
28
|
+
Application,
|
|
29
|
+
ApplicationV11,
|
|
30
|
+
)
|
|
31
|
+
from snowflake.cli.api.project.schemas.v1.native_app.native_app import NativeApp
|
|
32
|
+
from snowflake.cli.api.project.schemas.v1.native_app.package import Package, PackageV11
|
|
33
|
+
from snowflake.cli.api.project.schemas.v1.snowpark.callable import (
|
|
34
34
|
FunctionSchema,
|
|
35
35
|
ProcedureSchema,
|
|
36
36
|
)
|
|
37
|
-
from snowflake.cli.api.project.schemas.snowpark.snowpark import Snowpark
|
|
38
|
-
from snowflake.cli.api.project.schemas.streamlit.streamlit import Streamlit
|
|
37
|
+
from snowflake.cli.api.project.schemas.v1.snowpark.snowpark import Snowpark
|
|
38
|
+
from snowflake.cli.api.project.schemas.v1.streamlit.streamlit import Streamlit
|
|
39
39
|
from snowflake.cli.api.rendering.jinja import get_basic_jinja_env
|
|
40
40
|
|
|
41
41
|
log = logging.getLogger(__name__)
|
|
@@ -157,6 +157,7 @@ def convert_streamlit_to_v2_data(streamlit: Streamlit) -> Dict[str, Any]:
|
|
|
157
157
|
"type": "streamlit",
|
|
158
158
|
"identifier": identifier,
|
|
159
159
|
"title": streamlit.title,
|
|
160
|
+
"comment": streamlit.comment,
|
|
160
161
|
"query_warehouse": streamlit.query_warehouse,
|
|
161
162
|
"main_file": str(streamlit.main_file),
|
|
162
163
|
"pages_dir": str(streamlit.pages_dir),
|
|
@@ -15,11 +15,10 @@
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
17
|
from abc import ABC
|
|
18
|
-
from typing import Generic, List, Optional, TypeVar, Union
|
|
18
|
+
from typing import Dict, Generic, List, Optional, TypeVar, Union
|
|
19
19
|
|
|
20
20
|
from pydantic import Field, PrivateAttr, field_validator
|
|
21
21
|
from snowflake.cli.api.identifiers import FQN
|
|
22
|
-
from snowflake.cli.api.project.schemas.identifier_model import Identifier
|
|
23
22
|
from snowflake.cli.api.project.schemas.updatable_model import (
|
|
24
23
|
IdentifierField,
|
|
25
24
|
UpdatableModel,
|
|
@@ -61,6 +60,12 @@ class MetaField(UpdatableModel):
|
|
|
61
60
|
return mixins
|
|
62
61
|
|
|
63
62
|
|
|
63
|
+
class Identifier(UpdatableModel):
|
|
64
|
+
name: str = Field(title="Entity name")
|
|
65
|
+
schema_: Optional[str] = Field(title="Entity schema", alias="schema", default=None)
|
|
66
|
+
database: Optional[str] = Field(title="Entity database", default=None)
|
|
67
|
+
|
|
68
|
+
|
|
64
69
|
class EntityModelBase(ABC, UpdatableModel):
|
|
65
70
|
@classmethod
|
|
66
71
|
def get_type(cls) -> str:
|
|
@@ -112,9 +117,17 @@ class TargetField(UpdatableModel, Generic[TargetType]):
|
|
|
112
117
|
return self.__pydantic_generic_metadata__["args"][0]
|
|
113
118
|
|
|
114
119
|
|
|
115
|
-
|
|
120
|
+
class ImportsBaseModel:
|
|
121
|
+
imports: Optional[List[str]] = Field(
|
|
122
|
+
title="Stage and path to previously uploaded files you want to import",
|
|
123
|
+
default=[],
|
|
124
|
+
)
|
|
116
125
|
|
|
117
|
-
|
|
126
|
+
def get_imports_sql(self) -> str | None:
|
|
127
|
+
if not self.imports:
|
|
128
|
+
return None
|
|
129
|
+
imports = ", ".join(f"'{i}'" for i in self.imports)
|
|
130
|
+
return f"IMPORTS = ({imports})"
|
|
118
131
|
|
|
119
132
|
|
|
120
133
|
class ExternalAccessBaseModel:
|
|
@@ -16,23 +16,26 @@ from __future__ import annotations
|
|
|
16
16
|
|
|
17
17
|
from typing import Dict, List, Union, get_args
|
|
18
18
|
|
|
19
|
-
from snowflake.cli.
|
|
20
|
-
from snowflake.cli.
|
|
21
|
-
ApplicationPackageEntity,
|
|
22
|
-
)
|
|
23
|
-
from snowflake.cli.api.entities.snowpark_entity import FunctionEntity, ProcedureEntity
|
|
24
|
-
from snowflake.cli.api.entities.streamlit_entity import StreamlitEntity
|
|
25
|
-
from snowflake.cli.api.project.schemas.entities.application_entity_model import (
|
|
19
|
+
from snowflake.cli._plugins.nativeapp.application_entity import ApplicationEntity
|
|
20
|
+
from snowflake.cli._plugins.nativeapp.application_entity_model import (
|
|
26
21
|
ApplicationEntityModel,
|
|
27
22
|
)
|
|
28
|
-
from snowflake.cli.
|
|
23
|
+
from snowflake.cli._plugins.nativeapp.application_package_entity import (
|
|
24
|
+
ApplicationPackageEntity,
|
|
25
|
+
)
|
|
26
|
+
from snowflake.cli._plugins.nativeapp.application_package_entity_model import (
|
|
29
27
|
ApplicationPackageEntityModel,
|
|
30
28
|
)
|
|
31
|
-
from snowflake.cli.
|
|
29
|
+
from snowflake.cli._plugins.snowpark.snowpark_entity import (
|
|
30
|
+
FunctionEntity,
|
|
31
|
+
ProcedureEntity,
|
|
32
|
+
)
|
|
33
|
+
from snowflake.cli._plugins.snowpark.snowpark_entity_model import (
|
|
32
34
|
FunctionEntityModel,
|
|
33
35
|
ProcedureEntityModel,
|
|
34
36
|
)
|
|
35
|
-
from snowflake.cli.
|
|
37
|
+
from snowflake.cli._plugins.streamlit.streamlit_entity import StreamlitEntity
|
|
38
|
+
from snowflake.cli._plugins.streamlit.streamlit_entity_model import (
|
|
36
39
|
StreamlitEntityModel,
|
|
37
40
|
)
|
|
38
41
|
|
|
@@ -19,10 +19,10 @@ from typing import Any, Dict, List, Optional, Union
|
|
|
19
19
|
|
|
20
20
|
from packaging.version import Version
|
|
21
21
|
from pydantic import Field, ValidationError, field_validator, model_validator
|
|
22
|
-
from snowflake.cli.
|
|
23
|
-
from snowflake.cli.api.project.schemas.entities.application_entity_model import (
|
|
22
|
+
from snowflake.cli._plugins.nativeapp.application_entity_model import (
|
|
24
23
|
ApplicationEntityModel,
|
|
25
24
|
)
|
|
25
|
+
from snowflake.cli.api.project.errors import SchemaValidationError
|
|
26
26
|
from snowflake.cli.api.project.schemas.entities.common import (
|
|
27
27
|
TargetField,
|
|
28
28
|
)
|
|
@@ -30,13 +30,13 @@ from snowflake.cli.api.project.schemas.entities.entities import (
|
|
|
30
30
|
EntityModel,
|
|
31
31
|
v2_entity_model_types_map,
|
|
32
32
|
)
|
|
33
|
-
from snowflake.cli.api.project.schemas.
|
|
33
|
+
from snowflake.cli.api.project.schemas.updatable_model import UpdatableModel
|
|
34
|
+
from snowflake.cli.api.project.schemas.v1.native_app.native_app import (
|
|
34
35
|
NativeApp,
|
|
35
36
|
NativeAppV11,
|
|
36
37
|
)
|
|
37
|
-
from snowflake.cli.api.project.schemas.snowpark.snowpark import Snowpark
|
|
38
|
-
from snowflake.cli.api.project.schemas.streamlit.streamlit import Streamlit
|
|
39
|
-
from snowflake.cli.api.project.schemas.updatable_model import UpdatableModel
|
|
38
|
+
from snowflake.cli.api.project.schemas.v1.snowpark.snowpark import Snowpark
|
|
39
|
+
from snowflake.cli.api.project.schemas.v1.streamlit.streamlit import Streamlit
|
|
40
40
|
from snowflake.cli.api.utils.types import Context
|
|
41
41
|
from typing_extensions import Annotated
|
|
42
42
|
|
|
File without changes
|