snowflake-cli-labs 3.0.0rc1__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.
Files changed (92) hide show
  1. snowflake/cli/__about__.py +1 -1
  2. snowflake/cli/_app/cli_app.py +10 -1
  3. snowflake/cli/_app/commands_registration/builtin_plugins.py +2 -0
  4. snowflake/cli/_app/secret.py +9 -0
  5. snowflake/cli/_app/snow_connector.py +110 -51
  6. snowflake/cli/_app/telemetry.py +8 -4
  7. snowflake/cli/_app/version_check.py +74 -0
  8. snowflake/cli/_plugins/git/commands.py +55 -14
  9. snowflake/cli/_plugins/git/manager.py +53 -7
  10. snowflake/cli/_plugins/helpers/commands.py +57 -0
  11. snowflake/cli/{api/commands/typer_pre_execute.py → _plugins/helpers/plugin_spec.py} +14 -10
  12. snowflake/cli/_plugins/nativeapp/application_entity.py +651 -0
  13. snowflake/cli/{api/project/schemas/entities → _plugins/nativeapp}/application_entity_model.py +2 -2
  14. snowflake/cli/_plugins/nativeapp/application_package_entity.py +1107 -0
  15. snowflake/cli/{api/project/schemas/entities → _plugins/nativeapp}/application_package_entity_model.py +3 -3
  16. snowflake/cli/_plugins/nativeapp/artifacts.py +10 -9
  17. snowflake/cli/_plugins/nativeapp/bundle_context.py +1 -1
  18. snowflake/cli/_plugins/nativeapp/codegen/artifact_processor.py +1 -1
  19. snowflake/cli/_plugins/nativeapp/codegen/compiler.py +1 -1
  20. snowflake/cli/_plugins/nativeapp/codegen/setup/native_app_setup_processor.py +1 -1
  21. snowflake/cli/_plugins/nativeapp/codegen/snowpark/extension_function_utils.py +1 -1
  22. snowflake/cli/_plugins/nativeapp/codegen/snowpark/models.py +1 -1
  23. snowflake/cli/_plugins/nativeapp/codegen/snowpark/python_processor.py +3 -6
  24. snowflake/cli/_plugins/nativeapp/codegen/templates/templates_processor.py +50 -32
  25. snowflake/cli/_plugins/nativeapp/commands.py +84 -16
  26. snowflake/cli/_plugins/nativeapp/exceptions.py +0 -9
  27. snowflake/cli/_plugins/nativeapp/manager.py +56 -92
  28. snowflake/cli/_plugins/nativeapp/policy.py +3 -0
  29. snowflake/cli/_plugins/nativeapp/project_model.py +2 -2
  30. snowflake/cli/_plugins/nativeapp/run_processor.py +65 -272
  31. snowflake/cli/_plugins/nativeapp/same_account_install_method.py +70 -0
  32. snowflake/cli/_plugins/nativeapp/teardown_processor.py +11 -154
  33. snowflake/cli/_plugins/nativeapp/v2_conversions/v2_to_v1_decorator.py +150 -40
  34. snowflake/cli/_plugins/nativeapp/version/commands.py +6 -24
  35. snowflake/cli/_plugins/nativeapp/version/version_processor.py +35 -235
  36. snowflake/cli/_plugins/snowpark/commands.py +5 -5
  37. snowflake/cli/_plugins/snowpark/common.py +4 -4
  38. snowflake/cli/_plugins/snowpark/models.py +2 -1
  39. snowflake/cli/{api/entities → _plugins/snowpark}/snowpark_entity.py +2 -2
  40. snowflake/cli/{api/project/schemas/entities/snowpark_entity.py → _plugins/snowpark/snowpark_entity_model.py} +3 -6
  41. snowflake/cli/_plugins/snowpark/snowpark_project_paths.py +1 -1
  42. snowflake/cli/_plugins/stage/manager.py +9 -4
  43. snowflake/cli/_plugins/streamlit/commands.py +4 -4
  44. snowflake/cli/_plugins/streamlit/manager.py +17 -4
  45. snowflake/cli/{api/entities → _plugins/streamlit}/streamlit_entity.py +2 -2
  46. snowflake/cli/{api/project/schemas/entities → _plugins/streamlit}/streamlit_entity_model.py +5 -12
  47. snowflake/cli/_plugins/workspace/action_context.py +2 -1
  48. snowflake/cli/_plugins/workspace/commands.py +127 -48
  49. snowflake/cli/_plugins/workspace/manager.py +1 -0
  50. snowflake/cli/_plugins/workspace/plugin_spec.py +1 -1
  51. snowflake/cli/api/cli_global_context.py +136 -313
  52. snowflake/cli/api/commands/flags.py +76 -91
  53. snowflake/cli/api/commands/snow_typer.py +7 -5
  54. snowflake/cli/api/config.py +1 -1
  55. snowflake/cli/api/connections.py +214 -0
  56. snowflake/cli/api/console/abc.py +4 -2
  57. snowflake/cli/api/entities/common.py +4 -0
  58. snowflake/cli/api/entities/utils.py +41 -31
  59. snowflake/cli/api/errno.py +1 -0
  60. snowflake/cli/api/identifiers.py +7 -3
  61. snowflake/cli/api/project/definition.py +11 -0
  62. snowflake/cli/api/project/definition_conversion.py +175 -16
  63. snowflake/cli/api/project/schemas/entities/common.py +15 -14
  64. snowflake/cli/api/project/schemas/entities/entities.py +13 -10
  65. snowflake/cli/api/project/schemas/project_definition.py +107 -45
  66. snowflake/cli/api/project/schemas/v1/__init__.py +0 -0
  67. snowflake/cli/api/project/schemas/{identifier_model.py → v1/identifier_model.py} +0 -7
  68. snowflake/cli/api/project/schemas/v1/native_app/__init__.py +0 -0
  69. snowflake/cli/api/project/schemas/{native_app → v1/native_app}/native_app.py +4 -4
  70. snowflake/cli/api/project/schemas/v1/snowpark/__init__.py +0 -0
  71. snowflake/cli/api/project/schemas/{snowpark → v1/snowpark}/callable.py +2 -2
  72. snowflake/cli/api/project/schemas/{snowpark → v1/snowpark}/snowpark.py +2 -2
  73. snowflake/cli/api/project/schemas/v1/streamlit/__init__.py +0 -0
  74. snowflake/cli/api/project/schemas/{streamlit → v1/streamlit}/streamlit.py +2 -1
  75. snowflake/cli/api/rendering/project_definition_templates.py +4 -0
  76. snowflake/cli/api/rendering/sql_templates.py +7 -0
  77. snowflake/cli/api/sql_execution.py +6 -15
  78. snowflake/cli/api/utils/definition_rendering.py +3 -1
  79. {snowflake_cli_labs-3.0.0rc1.dist-info → snowflake_cli_labs-3.0.0rc3.dist-info}/METADATA +9 -9
  80. {snowflake_cli_labs-3.0.0rc1.dist-info → snowflake_cli_labs-3.0.0rc3.dist-info}/RECORD +88 -81
  81. snowflake/cli/api/entities/application_entity.py +0 -12
  82. snowflake/cli/api/entities/application_package_entity.py +0 -553
  83. snowflake/cli/api/project/schemas/snowpark/__init__.py +0 -13
  84. snowflake/cli/api/project/schemas/streamlit/__init__.py +0 -13
  85. /snowflake/cli/{api/project/schemas/native_app → _plugins/helpers}/__init__.py +0 -0
  86. /snowflake/cli/api/project/schemas/{native_app → v1/native_app}/application.py +0 -0
  87. /snowflake/cli/api/project/schemas/{native_app → v1/native_app}/package.py +0 -0
  88. /snowflake/cli/api/project/schemas/{native_app → v1/native_app}/path_mapping.py +0 -0
  89. /snowflake/cli/api/project/schemas/{snowpark → v1/snowpark}/argument.py +0 -0
  90. {snowflake_cli_labs-3.0.0rc1.dist-info → snowflake_cli_labs-3.0.0rc3.dist-info}/WHEEL +0 -0
  91. {snowflake_cli_labs-3.0.0rc1.dist-info → snowflake_cli_labs-3.0.0rc3.dist-info}/entry_points.txt +0 -0
  92. {snowflake_cli_labs-3.0.0rc1.dist-info → snowflake_cli_labs-3.0.0rc3.dist-info}/licenses/LICENSE +0 -0
@@ -20,68 +20,29 @@ from textwrap import dedent
20
20
  from typing import List, Optional
21
21
 
22
22
  import typer
23
- import yaml
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,
27
+ InteractiveOption,
27
28
  ValidateOption,
28
29
  )
29
30
  from snowflake.cli._plugins.workspace.manager import WorkspaceManager
30
31
  from snowflake.cli.api.cli_global_context import get_cli_context
31
32
  from snowflake.cli.api.commands.decorators import with_project_definition
32
- from snowflake.cli.api.commands.snow_typer import SnowTyper
33
+ from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
33
34
  from snowflake.cli.api.entities.common import EntityActions
34
35
  from snowflake.cli.api.exceptions import IncompatibleParametersError
35
- from snowflake.cli.api.output.types import MessageResult
36
- from snowflake.cli.api.project.definition_conversion import (
37
- convert_project_definition_to_v2,
38
- )
39
- from snowflake.cli.api.project.definition_manager import DefinitionManager
40
- from snowflake.cli.api.secure_path import SecurePath
36
+ from snowflake.cli.api.output.types import MessageResult, QueryResult
41
37
 
42
- ws = SnowTyper(
38
+ ws = SnowTyperFactory(
43
39
  name="ws",
44
40
  help="Deploy and interact with snowflake.yml-based entities.",
41
+ is_hidden=lambda: True,
45
42
  )
46
43
  log = logging.getLogger(__name__)
47
44
 
48
45
 
49
- @ws.command()
50
- def migrate(
51
- accept_templates: bool = typer.Option(
52
- False, "-t", "--accept-templates", help="Allows the migration of templates."
53
- ),
54
- **options,
55
- ):
56
- """Migrates the Snowpark and Streamlit project definition files from V1 to V2."""
57
- pd = DefinitionManager().unrendered_project_definition
58
-
59
- if pd.meets_version_requirement("2"):
60
- return MessageResult("Project definition is already at version 2.")
61
-
62
- pd_v2 = convert_project_definition_to_v2(pd, accept_templates)
63
-
64
- SecurePath("snowflake.yml").rename("snowflake_V1.yml")
65
- with open("snowflake.yml", "w") as file:
66
- yaml.dump(
67
- pd_v2.model_dump(
68
- exclude_unset=True, exclude_none=True, mode="json", by_alias=True
69
- ),
70
- file,
71
- )
72
- return MessageResult("Project definition migrated to version 2.")
73
-
74
-
75
- @ws.command(requires_connection=True, hidden=True)
76
- @with_project_definition()
77
- def validate(
78
- **options,
79
- ):
80
- """Validates the project definition file."""
81
- # If we get to this point, @with_project_definition() has already validated the PDF schema
82
- return MessageResult("Project definition is valid.")
83
-
84
-
85
46
  @ws.command(requires_connection=True, hidden=True)
86
47
  @with_project_definition()
87
48
  def bundle(
@@ -104,7 +65,7 @@ def bundle(
104
65
  return MessageResult(f"Bundle generated at {bundle_map.deploy_root()}")
105
66
 
106
67
 
107
- @ws.command(requires_connection=True)
68
+ @ws.command(requires_connection=True, hidden=True)
108
69
  @with_project_definition()
109
70
  def deploy(
110
71
  entity_id: str = typer.Option(
@@ -132,6 +93,15 @@ def deploy(
132
93
  unspecified, the command syncs all local changes to the stage."""
133
94
  ).strip(),
134
95
  ),
96
+ from_release_directive: Optional[bool] = typer.Option(
97
+ False,
98
+ "--from-release-directive",
99
+ help=f"""Creates or upgrades an application object to the version and patch specified by the release directive applicable to your Snowflake account.
100
+ The command fails if no release directive exists for your Snowflake account for a given application package, which is determined from the project definition file. Default: unset.""",
101
+ is_flag=True,
102
+ ),
103
+ interactive: bool = InteractiveOption,
104
+ force: Optional[bool] = ForceOption,
135
105
  validate: bool = ValidateOption,
136
106
  **options,
137
107
  ):
@@ -163,24 +133,32 @@ def deploy(
163
133
  recursive=recursive,
164
134
  paths=paths,
165
135
  validate=validate,
136
+ from_release_directive=from_release_directive,
137
+ interactive=interactive,
138
+ force=force,
166
139
  )
167
140
  return MessageResult("Deployed successfully.")
168
141
 
169
142
 
170
- @ws.command(requires_connection=True)
143
+ @ws.command(requires_connection=True, hidden=True)
171
144
  @with_project_definition()
172
145
  def drop(
173
146
  entity_id: str = typer.Option(
174
147
  help=f"""The ID of the entity you want to drop.""",
175
148
  ),
176
149
  # TODO The following options should be generated automatically, depending on the specified entity type
150
+ interactive: bool = InteractiveOption,
177
151
  force: Optional[bool] = ForceOption,
152
+ cascade: Optional[bool] = typer.Option(
153
+ None,
154
+ help=f"""Whether to drop all application objects owned by the application within the account. Default: false.""",
155
+ show_default=False,
156
+ ),
178
157
  **options,
179
158
  ):
180
159
  """
181
160
  Drops the specified entity.
182
161
  """
183
-
184
162
  cli_context = get_cli_context()
185
163
  ws = WorkspaceManager(
186
164
  project_definition=cli_context.project_definition,
@@ -191,4 +169,105 @@ def drop(
191
169
  entity_id,
192
170
  EntityActions.DROP,
193
171
  force_drop=force,
172
+ interactive=interactive,
173
+ cascade=cascade,
174
+ )
175
+
176
+
177
+ @ws.command(requires_connection=True, hidden=True)
178
+ @with_project_definition()
179
+ def validate(
180
+ entity_id: str = typer.Option(
181
+ help=f"""The ID of the entity you want to validate.""",
182
+ ),
183
+ interactive: bool = InteractiveOption,
184
+ force: Optional[bool] = ForceOption,
185
+ **options,
186
+ ):
187
+ """Validates the specified entity."""
188
+ cli_context = get_cli_context()
189
+ ws = WorkspaceManager(
190
+ project_definition=cli_context.project_definition,
191
+ project_root=cli_context.project_root,
192
+ )
193
+
194
+ ws.perform_action(
195
+ entity_id,
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,
194
273
  )
@@ -64,6 +64,7 @@ class WorkspaceManager:
64
64
  project_root=self.project_root(),
65
65
  default_role=self._default_role,
66
66
  default_warehouse=self.default_warehouse,
67
+ get_entity=self.get_entity,
67
68
  )
68
69
  return entity.perform(action, action_ctx, *args, **kwargs)
69
70
  else:
@@ -26,5 +26,5 @@ def command_spec():
26
26
  return CommandSpec(
27
27
  parent_command_path=SNOWCLI_ROOT_COMMAND_PATH,
28
28
  command_type=CommandType.COMMAND_GROUP,
29
- typer_instance=commands.ws,
29
+ typer_instance=commands.ws.create_instance(),
30
30
  )