snowflake-cli 3.0.2__py3-none-any.whl → 3.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. snowflake/cli/__about__.py +1 -1
  2. snowflake/cli/_app/cli_app.py +3 -0
  3. snowflake/cli/_app/dev/docs/templates/overview.rst.jinja2 +1 -1
  4. snowflake/cli/_app/dev/docs/templates/usage.rst.jinja2 +2 -2
  5. snowflake/cli/_app/telemetry.py +69 -4
  6. snowflake/cli/_plugins/connection/commands.py +152 -99
  7. snowflake/cli/_plugins/connection/util.py +54 -9
  8. snowflake/cli/_plugins/cortex/manager.py +1 -1
  9. snowflake/cli/_plugins/git/commands.py +6 -3
  10. snowflake/cli/_plugins/git/manager.py +9 -4
  11. snowflake/cli/_plugins/nativeapp/artifacts.py +77 -13
  12. snowflake/cli/_plugins/nativeapp/codegen/artifact_processor.py +1 -1
  13. snowflake/cli/_plugins/nativeapp/codegen/compiler.py +7 -0
  14. snowflake/cli/_plugins/nativeapp/codegen/sandbox.py +10 -10
  15. snowflake/cli/_plugins/nativeapp/codegen/setup/native_app_setup_processor.py +2 -2
  16. snowflake/cli/_plugins/nativeapp/codegen/snowpark/extension_function_utils.py +1 -1
  17. snowflake/cli/_plugins/nativeapp/codegen/snowpark/python_processor.py +8 -8
  18. snowflake/cli/_plugins/nativeapp/codegen/templates/templates_processor.py +5 -3
  19. snowflake/cli/_plugins/nativeapp/commands.py +144 -188
  20. snowflake/cli/_plugins/nativeapp/constants.py +1 -0
  21. snowflake/cli/_plugins/nativeapp/entities/application.py +564 -351
  22. snowflake/cli/_plugins/nativeapp/entities/application_package.py +583 -929
  23. snowflake/cli/_plugins/nativeapp/entities/models/event_sharing_telemetry.py +58 -0
  24. snowflake/cli/_plugins/nativeapp/exceptions.py +12 -0
  25. snowflake/cli/_plugins/nativeapp/same_account_install_method.py +0 -2
  26. snowflake/cli/_plugins/nativeapp/sf_facade.py +30 -0
  27. snowflake/cli/_plugins/nativeapp/sf_facade_constants.py +25 -0
  28. snowflake/cli/_plugins/nativeapp/sf_facade_exceptions.py +117 -0
  29. snowflake/cli/_plugins/nativeapp/sf_sql_facade.py +525 -0
  30. snowflake/cli/_plugins/nativeapp/v2_conversions/{v2_to_v1_decorator.py → compat.py} +88 -117
  31. snowflake/cli/_plugins/nativeapp/version/commands.py +36 -32
  32. snowflake/cli/_plugins/notebook/manager.py +2 -2
  33. snowflake/cli/_plugins/object/commands.py +10 -1
  34. snowflake/cli/_plugins/object/manager.py +13 -5
  35. snowflake/cli/_plugins/snowpark/common.py +63 -21
  36. snowflake/cli/_plugins/snowpark/package/anaconda_packages.py +3 -3
  37. snowflake/cli/_plugins/spcs/common.py +29 -0
  38. snowflake/cli/_plugins/spcs/compute_pool/manager.py +7 -9
  39. snowflake/cli/_plugins/spcs/image_registry/manager.py +2 -2
  40. snowflake/cli/_plugins/spcs/image_repository/commands.py +4 -37
  41. snowflake/cli/_plugins/spcs/image_repository/manager.py +4 -1
  42. snowflake/cli/_plugins/spcs/services/commands.py +100 -17
  43. snowflake/cli/_plugins/spcs/services/manager.py +108 -16
  44. snowflake/cli/_plugins/sql/commands.py +9 -1
  45. snowflake/cli/_plugins/sql/manager.py +9 -4
  46. snowflake/cli/_plugins/stage/commands.py +28 -19
  47. snowflake/cli/_plugins/stage/diff.py +17 -17
  48. snowflake/cli/_plugins/stage/manager.py +304 -84
  49. snowflake/cli/_plugins/stage/md5.py +1 -1
  50. snowflake/cli/_plugins/streamlit/manager.py +5 -5
  51. snowflake/cli/_plugins/workspace/commands.py +27 -4
  52. snowflake/cli/_plugins/workspace/context.py +38 -0
  53. snowflake/cli/_plugins/workspace/manager.py +23 -13
  54. snowflake/cli/api/cli_global_context.py +4 -3
  55. snowflake/cli/api/commands/flags.py +23 -7
  56. snowflake/cli/api/config.py +30 -9
  57. snowflake/cli/api/connections.py +12 -1
  58. snowflake/cli/api/console/console.py +4 -19
  59. snowflake/cli/api/entities/common.py +4 -2
  60. snowflake/cli/api/entities/utils.py +36 -69
  61. snowflake/cli/api/errno.py +2 -0
  62. snowflake/cli/api/exceptions.py +41 -0
  63. snowflake/cli/api/identifiers.py +8 -0
  64. snowflake/cli/api/metrics.py +223 -7
  65. snowflake/cli/api/output/types.py +1 -1
  66. snowflake/cli/api/project/definition_conversion.py +293 -77
  67. snowflake/cli/api/project/schemas/entities/common.py +11 -0
  68. snowflake/cli/api/project/schemas/project_definition.py +30 -25
  69. snowflake/cli/api/rest_api.py +26 -4
  70. snowflake/cli/api/secure_utils.py +1 -1
  71. snowflake/cli/api/sql_execution.py +40 -29
  72. snowflake/cli/api/stage_path.py +244 -0
  73. snowflake/cli/api/utils/definition_rendering.py +3 -5
  74. {snowflake_cli-3.0.2.dist-info → snowflake_cli-3.2.0.dist-info}/METADATA +14 -15
  75. {snowflake_cli-3.0.2.dist-info → snowflake_cli-3.2.0.dist-info}/RECORD +78 -77
  76. {snowflake_cli-3.0.2.dist-info → snowflake_cli-3.2.0.dist-info}/WHEEL +1 -1
  77. snowflake/cli/_plugins/nativeapp/manager.py +0 -415
  78. snowflake/cli/_plugins/nativeapp/project_model.py +0 -211
  79. snowflake/cli/_plugins/nativeapp/run_processor.py +0 -184
  80. snowflake/cli/_plugins/nativeapp/teardown_processor.py +0 -70
  81. snowflake/cli/_plugins/nativeapp/version/version_processor.py +0 -98
  82. snowflake/cli/_plugins/workspace/action_context.py +0 -18
  83. {snowflake_cli-3.0.2.dist-info → snowflake_cli-3.2.0.dist-info}/entry_points.txt +0 -0
  84. {snowflake_cli-3.0.2.dist-info → snowflake_cli-3.2.0.dist-info}/licenses/LICENSE +0 -0
@@ -38,6 +38,7 @@ from snowflake.cli.api.commands.flags import (
38
38
  OnErrorOption,
39
39
  PatternOption,
40
40
  identifier_stage_argument,
41
+ identifier_stage_path_argument,
41
42
  like_option,
42
43
  )
43
44
  from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
@@ -60,6 +61,10 @@ app = SnowTyperFactory(
60
61
  )
61
62
 
62
63
  StageNameArgument = identifier_stage_argument(sf_object="stage", example="@my_stage")
64
+ StagePathArgument = identifier_stage_path_argument(
65
+ sf_object="stage", example="@my_stage/path"
66
+ )
67
+
63
68
 
64
69
  add_object_command_aliases(
65
70
  app=app,
@@ -74,7 +79,7 @@ add_object_command_aliases(
74
79
 
75
80
  @app.command("list-files", requires_connection=True)
76
81
  def stage_list_files(
77
- stage_name: str = StageNameArgument, pattern=PatternOption, **options
82
+ stage_name: str = StagePathArgument, pattern=PatternOption, **options
78
83
  ) -> CommandResult:
79
84
  """
80
85
  Lists the stage contents.
@@ -136,7 +141,7 @@ def copy(
136
141
  )
137
142
  return _put(
138
143
  recursive=recursive,
139
- source_path=source_path,
144
+ source_path=Path(source_path),
140
145
  destination_path=destination_path,
141
146
  parallel=parallel,
142
147
  overwrite=overwrite,
@@ -208,11 +213,11 @@ def execute(
208
213
  **options,
209
214
  ):
210
215
  """
211
- Execute immediate all files from the stage path. Files can be filtered with glob like pattern,
216
+ Execute immediate all files from the stage path. Files can be filtered with a glob-like pattern,
212
217
  e.g. `@stage/*.sql`, `@stage/dev/*`. Only files with `.sql` extension will be executed.
213
218
  """
214
219
  results = StageManager().execute(
215
- stage_path=stage_path, on_error=on_error, variables=variables
220
+ stage_path_str=stage_path, on_error=on_error, variables=variables
216
221
  )
217
222
  return CollectionResult(results)
218
223
 
@@ -242,23 +247,27 @@ def get(recursive: bool, source_path: str, destination_path: str, parallel: int)
242
247
 
243
248
  def _put(
244
249
  recursive: bool,
245
- source_path: str,
250
+ source_path: Path,
246
251
  destination_path: str,
247
252
  parallel: int,
248
253
  overwrite: bool,
249
254
  auto_compress: bool,
250
255
  ):
251
- if recursive:
252
- raise click.ClickException("Recursive flag for upload is not supported.")
253
-
254
- source = Path(source_path).resolve()
255
- local_path = str(source) + "/*" if source.is_dir() else str(source)
256
-
257
- cursor = StageManager().put(
258
- local_path=local_path,
259
- stage_path=destination_path,
260
- overwrite=overwrite,
261
- parallel=parallel,
262
- auto_compress=auto_compress,
263
- )
264
- return QueryResult(cursor)
256
+ if recursive and not source_path.is_file():
257
+ cursor_generator = StageManager().put_recursive(
258
+ local_path=source_path,
259
+ stage_path=destination_path,
260
+ overwrite=overwrite,
261
+ parallel=parallel,
262
+ auto_compress=auto_compress,
263
+ )
264
+ return CollectionResult(cursor_generator)
265
+ else:
266
+ cursor = StageManager().put(
267
+ local_path=source_path.resolve(),
268
+ stage_path=destination_path,
269
+ overwrite=overwrite,
270
+ parallel=parallel,
271
+ auto_compress=auto_compress,
272
+ )
273
+ return QueryResult(cursor)
@@ -30,7 +30,7 @@ from .md5 import UnknownMD5FormatError, file_matches_md5sum
30
30
 
31
31
  log = logging.getLogger(__name__)
32
32
 
33
- StagePath = PurePosixPath # alias PurePosixPath as StagePath for clarity
33
+ StagePathType = PurePosixPath # alias PurePosixPath as StagePath for clarity
34
34
 
35
35
 
36
36
  @dataclass
@@ -39,16 +39,16 @@ class DiffResult:
39
39
  Each collection is a list of stage paths ('/'-separated, regardless of the platform), relative to the stage root.
40
40
  """
41
41
 
42
- identical: List[StagePath] = field(default_factory=list)
42
+ identical: List[StagePathType] = field(default_factory=list)
43
43
  "Files with matching md5sums"
44
44
 
45
- different: List[StagePath] = field(default_factory=list)
45
+ different: List[StagePathType] = field(default_factory=list)
46
46
  "Files that may be different between the stage and the local directory"
47
47
 
48
- only_local: List[StagePath] = field(default_factory=list)
48
+ only_local: List[StagePathType] = field(default_factory=list)
49
49
  "Files that only exist in the local directory"
50
50
 
51
- only_on_stage: List[StagePath] = field(default_factory=list)
51
+ only_on_stage: List[StagePathType] = field(default_factory=list)
52
52
  "Files that only exist on the stage"
53
53
 
54
54
  def has_changes(self) -> bool:
@@ -83,12 +83,12 @@ def enumerate_files(path: Path) -> List[Path]:
83
83
  return paths
84
84
 
85
85
 
86
- def strip_stage_name(path: str) -> StagePath:
86
+ def strip_stage_name(path: str) -> StagePathType:
87
87
  """Returns the given stage path without the stage name as the first part."""
88
- return StagePath(*path.split("/")[1:])
88
+ return StagePathType(*path.split("/")[1:])
89
89
 
90
90
 
91
- def build_md5_map(list_stage_cursor: DictCursor) -> Dict[StagePath, Optional[str]]:
91
+ def build_md5_map(list_stage_cursor: DictCursor) -> Dict[StagePathType, Optional[str]]:
92
92
  """
93
93
  Returns a mapping of relative stage paths to their md5sums.
94
94
  """
@@ -99,7 +99,7 @@ def build_md5_map(list_stage_cursor: DictCursor) -> Dict[StagePath, Optional[str
99
99
 
100
100
 
101
101
  def preserve_from_diff(
102
- diff: DiffResult, stage_paths_to_sync: Collection[StagePath]
102
+ diff: DiffResult, stage_paths_to_sync: Collection[StagePathType]
103
103
  ) -> DiffResult:
104
104
  """
105
105
  Returns a filtered version of the provided diff, keeping only the provided stage paths.
@@ -163,7 +163,7 @@ def compute_stage_diff(
163
163
  return result
164
164
 
165
165
 
166
- def get_stage_subpath(stage_path: StagePath) -> str:
166
+ def get_stage_subpath(stage_path: StagePathType) -> str:
167
167
  """
168
168
  Returns the parent portion of a stage path, as a string, for inclusion in the fully qualified stage path. Note that
169
169
  '.' treated specially here, and so the return value of this call is not a `StagePath` instance.
@@ -172,21 +172,21 @@ def get_stage_subpath(stage_path: StagePath) -> str:
172
172
  return "" if parent == "." else parent
173
173
 
174
174
 
175
- def to_stage_path(filename: Path) -> StagePath:
175
+ def to_stage_path(filename: Path) -> StagePathType:
176
176
  """
177
177
  Returns the stage file name, with the path separator suitably transformed if needed.
178
178
  """
179
- return StagePath(*filename.parts)
179
+ return StagePathType(*filename.parts)
180
180
 
181
181
 
182
- def to_local_path(stage_path: StagePath) -> Path:
182
+ def to_local_path(stage_path: StagePathType) -> Path:
183
183
  return Path(*stage_path.parts)
184
184
 
185
185
 
186
186
  def delete_only_on_stage_files(
187
187
  stage_manager: StageManager,
188
188
  stage_fqn: str,
189
- only_on_stage: List[StagePath],
189
+ only_on_stage: List[StagePathType],
190
190
  role: Optional[str] = None,
191
191
  ):
192
192
  """
@@ -200,7 +200,7 @@ def put_files_on_stage(
200
200
  stage_manager: StageManager,
201
201
  stage_fqn: str,
202
202
  deploy_root_path: Path,
203
- stage_paths: List[StagePath],
203
+ stage_paths: List[StagePathType],
204
204
  role: Optional[str] = None,
205
205
  overwrite: bool = False,
206
206
  ):
@@ -221,7 +221,7 @@ def put_files_on_stage(
221
221
 
222
222
 
223
223
  def sync_local_diff_with_stage(
224
- role: str, deploy_root_path: Path, diff_result: DiffResult, stage_fqn: str
224
+ role: str | None, deploy_root_path: Path, diff_result: DiffResult, stage_fqn: str
225
225
  ):
226
226
  """
227
227
  Syncs a given local directory's contents with a Snowflake stage, including removing old files, and re-uploading modified and new files.
@@ -254,7 +254,7 @@ def sync_local_diff_with_stage(
254
254
 
255
255
 
256
256
  def _to_src_dest_pair(
257
- stage_path: StagePath, bundle_map: Optional[BundleMap]
257
+ stage_path: StagePathType, bundle_map: Optional[BundleMap]
258
258
  ) -> Tuple[Optional[str], str]:
259
259
  if not bundle_map:
260
260
  return None, str(stage_path)