snowflake-cli 3.2.2__py3-none-any.whl → 3.4.1__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 (97) hide show
  1. snowflake/cli/__about__.py +1 -1
  2. snowflake/cli/_app/__main__.py +2 -2
  3. snowflake/cli/_app/cli_app.py +224 -192
  4. snowflake/cli/_app/commands_registration/commands_registration_with_callbacks.py +1 -27
  5. snowflake/cli/_app/constants.py +4 -0
  6. snowflake/cli/_app/snow_connector.py +12 -0
  7. snowflake/cli/_app/telemetry.py +10 -3
  8. snowflake/cli/_plugins/connection/util.py +12 -19
  9. snowflake/cli/_plugins/cortex/commands.py +2 -4
  10. snowflake/cli/_plugins/git/manager.py +1 -1
  11. snowflake/cli/_plugins/helpers/commands.py +207 -1
  12. snowflake/cli/_plugins/nativeapp/artifacts.py +16 -628
  13. snowflake/cli/_plugins/nativeapp/bundle_context.py +1 -1
  14. snowflake/cli/_plugins/nativeapp/codegen/artifact_processor.py +1 -1
  15. snowflake/cli/_plugins/nativeapp/codegen/compiler.py +42 -20
  16. snowflake/cli/_plugins/nativeapp/codegen/setup/native_app_setup_processor.py +9 -2
  17. snowflake/cli/_plugins/nativeapp/codegen/snowpark/python_processor.py +6 -3
  18. snowflake/cli/_plugins/nativeapp/codegen/templates/templates_processor.py +44 -34
  19. snowflake/cli/_plugins/nativeapp/commands.py +113 -21
  20. snowflake/cli/_plugins/nativeapp/constants.py +5 -0
  21. snowflake/cli/_plugins/nativeapp/entities/application.py +226 -296
  22. snowflake/cli/_plugins/nativeapp/entities/application_package.py +911 -141
  23. snowflake/cli/_plugins/nativeapp/entities/application_package_child_interface.py +43 -0
  24. snowflake/cli/_plugins/nativeapp/feature_flags.py +5 -1
  25. snowflake/cli/_plugins/nativeapp/release_channel/__init__.py +13 -0
  26. snowflake/cli/_plugins/nativeapp/release_channel/commands.py +246 -0
  27. snowflake/cli/_plugins/nativeapp/release_directive/__init__.py +13 -0
  28. snowflake/cli/_plugins/nativeapp/release_directive/commands.py +243 -0
  29. snowflake/cli/_plugins/nativeapp/same_account_install_method.py +9 -17
  30. snowflake/cli/_plugins/nativeapp/sf_facade_exceptions.py +80 -0
  31. snowflake/cli/_plugins/nativeapp/sf_sql_facade.py +1184 -80
  32. snowflake/cli/_plugins/nativeapp/utils.py +11 -0
  33. snowflake/cli/_plugins/nativeapp/v2_conversions/compat.py +7 -3
  34. snowflake/cli/_plugins/nativeapp/version/commands.py +32 -5
  35. snowflake/cli/_plugins/notebook/commands.py +55 -2
  36. snowflake/cli/_plugins/notebook/exceptions.py +1 -1
  37. snowflake/cli/_plugins/notebook/manager.py +7 -5
  38. snowflake/cli/_plugins/notebook/notebook_entity.py +120 -0
  39. snowflake/cli/_plugins/notebook/notebook_entity_model.py +42 -0
  40. snowflake/cli/_plugins/notebook/notebook_project_paths.py +15 -0
  41. snowflake/cli/_plugins/notebook/types.py +3 -0
  42. snowflake/cli/_plugins/snowpark/commands.py +48 -30
  43. snowflake/cli/_plugins/snowpark/common.py +47 -2
  44. snowflake/cli/_plugins/snowpark/snowpark_entity.py +247 -4
  45. snowflake/cli/_plugins/snowpark/snowpark_entity_model.py +18 -30
  46. snowflake/cli/_plugins/snowpark/snowpark_project_paths.py +156 -23
  47. snowflake/cli/_plugins/snowpark/zipper.py +33 -1
  48. snowflake/cli/_plugins/spcs/common.py +129 -0
  49. snowflake/cli/_plugins/spcs/services/commands.py +131 -14
  50. snowflake/cli/_plugins/spcs/services/manager.py +169 -1
  51. snowflake/cli/_plugins/stage/commands.py +2 -1
  52. snowflake/cli/_plugins/stage/diff.py +60 -39
  53. snowflake/cli/_plugins/stage/manager.py +34 -13
  54. snowflake/cli/_plugins/stage/utils.py +1 -1
  55. snowflake/cli/_plugins/streamlit/commands.py +10 -1
  56. snowflake/cli/_plugins/streamlit/manager.py +70 -22
  57. snowflake/cli/_plugins/streamlit/streamlit_entity.py +131 -1
  58. snowflake/cli/_plugins/streamlit/streamlit_entity_model.py +14 -24
  59. snowflake/cli/_plugins/streamlit/streamlit_project_paths.py +30 -0
  60. snowflake/cli/_plugins/workspace/commands.py +6 -5
  61. snowflake/cli/_plugins/workspace/manager.py +9 -5
  62. snowflake/cli/api/artifacts/__init__.py +13 -0
  63. snowflake/cli/api/artifacts/bundle_map.py +500 -0
  64. snowflake/cli/api/artifacts/common.py +78 -0
  65. snowflake/cli/api/artifacts/utils.py +82 -0
  66. snowflake/cli/api/cli_global_context.py +36 -2
  67. snowflake/cli/api/commands/flags.py +10 -4
  68. snowflake/cli/api/commands/utils.py +28 -2
  69. snowflake/cli/api/config.py +6 -2
  70. snowflake/cli/api/connections.py +12 -1
  71. snowflake/cli/api/constants.py +10 -1
  72. snowflake/cli/api/entities/common.py +81 -14
  73. snowflake/cli/api/entities/resolver.py +160 -0
  74. snowflake/cli/api/entities/utils.py +65 -23
  75. snowflake/cli/api/errno.py +63 -3
  76. snowflake/cli/api/feature_flags.py +19 -4
  77. snowflake/cli/api/metrics.py +21 -27
  78. snowflake/cli/api/project/definition_conversion.py +4 -4
  79. snowflake/cli/api/project/project_paths.py +28 -0
  80. snowflake/cli/api/project/schemas/entities/common.py +130 -1
  81. snowflake/cli/api/project/schemas/entities/entities.py +4 -0
  82. snowflake/cli/api/project/schemas/project_definition.py +54 -6
  83. snowflake/cli/api/project/schemas/updatable_model.py +2 -2
  84. snowflake/cli/api/project/schemas/v1/native_app/native_app.py +5 -7
  85. snowflake/cli/api/project/schemas/v1/streamlit/streamlit.py +1 -1
  86. snowflake/cli/api/project/util.py +45 -0
  87. snowflake/cli/api/secure_path.py +6 -0
  88. snowflake/cli/api/sql_execution.py +5 -1
  89. snowflake/cli/api/stage_path.py +7 -2
  90. snowflake/cli/api/utils/graph.py +3 -0
  91. snowflake/cli/api/utils/path_utils.py +24 -0
  92. {snowflake_cli-3.2.2.dist-info → snowflake_cli-3.4.1.dist-info}/METADATA +14 -15
  93. {snowflake_cli-3.2.2.dist-info → snowflake_cli-3.4.1.dist-info}/RECORD +96 -82
  94. {snowflake_cli-3.2.2.dist-info → snowflake_cli-3.4.1.dist-info}/WHEEL +1 -1
  95. snowflake/cli/api/project/schemas/v1/native_app/path_mapping.py +0 -65
  96. {snowflake_cli-3.2.2.dist-info → snowflake_cli-3.4.1.dist-info}/entry_points.txt +0 -0
  97. {snowflake_cli-3.2.2.dist-info → snowflake_cli-3.4.1.dist-info}/licenses/LICENSE +0 -0
@@ -13,13 +13,14 @@
13
13
  # limitations under the License.
14
14
  from __future__ import annotations
15
15
 
16
- from pathlib import Path
17
- from typing import List, Literal, Optional
16
+ from typing import Literal, Optional
18
17
 
19
- from pydantic import Field, model_validator
18
+ from pydantic import Field
20
19
  from snowflake.cli.api.project.schemas.entities.common import (
21
- EntityModelBase,
20
+ Artifacts,
21
+ EntityModelBaseWithArtifacts,
22
22
  ExternalAccessBaseModel,
23
+ GrantBaseModel,
23
24
  ImportsBaseModel,
24
25
  )
25
26
  from snowflake.cli.api.project.schemas.updatable_model import (
@@ -27,7 +28,12 @@ from snowflake.cli.api.project.schemas.updatable_model import (
27
28
  )
28
29
 
29
30
 
30
- class StreamlitEntityModel(EntityModelBase, ExternalAccessBaseModel, ImportsBaseModel):
31
+ class StreamlitEntityModel(
32
+ EntityModelBaseWithArtifacts,
33
+ ExternalAccessBaseModel,
34
+ ImportsBaseModel,
35
+ GrantBaseModel,
36
+ ):
31
37
  type: Literal["streamlit"] = DiscriminatorField() # noqa: A003
32
38
  title: Optional[str] = Field(
33
39
  title="Human-readable title for the Streamlit dashboard", default=None
@@ -43,24 +49,8 @@ class StreamlitEntityModel(EntityModelBase, ExternalAccessBaseModel, ImportsBase
43
49
  stage: Optional[str] = Field(
44
50
  title="Stage in which the app’s artifacts will be stored", default="streamlit"
45
51
  )
46
- # Possibly can be PathMapping
47
- artifacts: Optional[List[Path]] = Field(
48
- title="List of files which should be deployed. Each file needs to exist locally. "
49
- "Main file needs to be included in the artifacts.",
52
+ # Artifacts were optional, so to avoid BCR, we need to make them optional here as well
53
+ artifacts: Optional[Artifacts] = Field(
54
+ title="List of paths or file source/destination pairs to add to the deploy root",
50
55
  default=None,
51
56
  )
52
-
53
- @model_validator(mode="after")
54
- def artifacts_must_exists(self):
55
- if not self.artifacts:
56
- return self
57
-
58
- for artifact in self.artifacts:
59
- if "*" in artifact.name:
60
- continue
61
- if not artifact.exists():
62
- raise ValueError(
63
- f"Specified artifact {artifact} does not exist locally."
64
- )
65
-
66
- return self
@@ -0,0 +1,30 @@
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
+ from __future__ import annotations
15
+
16
+ from dataclasses import dataclass
17
+ from pathlib import Path
18
+
19
+ from snowflake.cli.api.project.project_paths import ProjectPaths, bundle_root
20
+
21
+
22
+ @dataclass
23
+ class StreamlitProjectPaths(ProjectPaths):
24
+ """
25
+ This class allows you to manage files paths related to given project.
26
+ """
27
+
28
+ @property
29
+ def bundle_root(self) -> Path:
30
+ return bundle_root(self.project_root, "streamlit")
@@ -22,19 +22,19 @@ from typing import List, Optional
22
22
 
23
23
  import typer
24
24
  import yaml
25
- from snowflake.cli._plugins.nativeapp.artifacts import BundleMap
26
25
  from snowflake.cli._plugins.nativeapp.common_flags import (
27
26
  ForceOption,
28
27
  InteractiveOption,
29
28
  ValidateOption,
30
29
  )
31
30
  from snowflake.cli._plugins.workspace.manager import WorkspaceManager
31
+ from snowflake.cli.api.artifacts.bundle_map import BundleMap
32
32
  from snowflake.cli.api.cli_global_context import get_cli_context
33
33
  from snowflake.cli.api.commands.decorators import with_project_definition
34
34
  from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
35
- from snowflake.cli.api.entities.common import EntityActions
35
+ from snowflake.cli.api.entities.utils import EntityActions
36
36
  from snowflake.cli.api.exceptions import IncompatibleParametersError
37
- from snowflake.cli.api.output.types import MessageResult, QueryResult
37
+ from snowflake.cli.api.output.types import CollectionResult, MessageResult
38
38
 
39
39
  ws = SnowTyperFactory(
40
40
  name="ws",
@@ -106,7 +106,7 @@ def deploy(
106
106
  show_default=False,
107
107
  help=dedent(
108
108
  f"""
109
- Paths, relative to the the project root, of files or directories you want to upload to a stage. If a file is
109
+ Paths, relative to the project root, of files or directories you want to upload to a stage. If a file is
110
110
  specified, it must match one of the artifacts src pattern entries in snowflake.yml. If a directory is
111
111
  specified, it will be searched for subfolders or files to deploy based on artifacts src pattern entries. If
112
112
  unspecified, the command syncs all local changes to the stage."""
@@ -243,7 +243,7 @@ def version_list(
243
243
  entity_id,
244
244
  EntityActions.VERSION_LIST,
245
245
  )
246
- return QueryResult(cursor)
246
+ return CollectionResult(cursor)
247
247
 
248
248
 
249
249
  @version.command(name="create", requires_connection=True, hidden=True)
@@ -293,6 +293,7 @@ def version_create(
293
293
  skip_git_check=skip_git_check,
294
294
  interactive=interactive,
295
295
  force=force,
296
+ from_stage=False,
296
297
  )
297
298
 
298
299
 
@@ -1,10 +1,11 @@
1
+ from functools import cached_property
1
2
  from pathlib import Path
2
3
  from typing import Dict
3
4
 
4
5
  from snowflake.cli._plugins.workspace.context import ActionContext, WorkspaceContext
5
6
  from snowflake.cli.api.cli_global_context import get_cli_context
6
7
  from snowflake.cli.api.console import cli_console as cc
7
- from snowflake.cli.api.entities.common import EntityActions, get_sql_executor
8
+ from snowflake.cli.api.entities.utils import EntityActions, get_sql_executor
8
9
  from snowflake.cli.api.exceptions import InvalidProjectDefinitionVersionError
9
10
  from snowflake.cli.api.project.definition import default_role
10
11
  from snowflake.cli.api.project.schemas.entities.entities import (
@@ -58,10 +59,7 @@ class WorkspaceManager:
58
59
  """
59
60
  entity = self.get_entity(entity_id)
60
61
  if entity.supports(action):
61
- action_ctx = ActionContext(
62
- get_entity=self.get_entity,
63
- )
64
- return entity.perform(action, action_ctx, *args, **kwargs)
62
+ return entity.perform(action, self.action_ctx, *args, **kwargs)
65
63
  else:
66
64
  raise ValueError(f'This entity type does not support "{action.value}"')
67
65
 
@@ -69,6 +67,12 @@ class WorkspaceManager:
69
67
  def project_root(self) -> Path:
70
68
  return self._project_root
71
69
 
70
+ @cached_property
71
+ def action_ctx(self) -> ActionContext:
72
+ return ActionContext(
73
+ get_entity=self.get_entity,
74
+ )
75
+
72
76
 
73
77
  def _get_default_role() -> str:
74
78
  role = default_role()
@@ -0,0 +1,13 @@
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.