snowflake-cli-labs 3.0.0rc4__py3-none-any.whl → 3.0.0rc5__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.
@@ -14,4 +14,4 @@
14
14
 
15
15
  from __future__ import annotations
16
16
 
17
- VERSION = "3.0.0rc4"
17
+ VERSION = "3.0.0rc5"
@@ -16,6 +16,7 @@ from __future__ import annotations
16
16
 
17
17
  import typer
18
18
  import yaml
19
+ from click import ClickException
19
20
  from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
20
21
  from snowflake.cli.api.output.types import MessageResult
21
22
  from snowflake.cli.api.project.definition_conversion import (
@@ -35,10 +36,36 @@ def v1_to_v2(
35
36
  accept_templates: bool = typer.Option(
36
37
  False, "-t", "--accept-templates", help="Allows the migration of templates."
37
38
  ),
39
+ migrate_local_yml: (bool | None) = typer.Option(
40
+ None,
41
+ "-l",
42
+ "--migrate-local-overrides/--no-migrate-local-overrides",
43
+ help=(
44
+ "Merge values in snowflake.local.yml into the main project definition. "
45
+ "The snowflake.local.yml file will not be migrated, "
46
+ "instead its values will be reflected in the output snowflake.yml file. "
47
+ "If unset and snowflake.local.yml is present, an error will be raised."
48
+ ),
49
+ show_default=False,
50
+ ),
38
51
  **options,
39
52
  ):
40
53
  """Migrates the Snowpark, Streamlit, and Native App project definition files from V1 to V2."""
41
54
  manager = DefinitionManager()
55
+ local_yml_path = manager.project_root / "snowflake.local.yml"
56
+ has_local_yml = local_yml_path in manager.project_config_paths
57
+ if has_local_yml:
58
+ if migrate_local_yml is None:
59
+ raise ClickException(
60
+ "snowflake.local.yml file detected, "
61
+ "please specify --migrate-local-overrides to include "
62
+ "or --no-migrate-local-overrides to exclude its values."
63
+ )
64
+ if not migrate_local_yml:
65
+ # If we don't want the local file,
66
+ # remove it from the list of paths to load
67
+ manager.project_config_paths.remove(local_yml_path)
68
+
42
69
  pd = manager.unrendered_project_definition
43
70
 
44
71
  if pd.meets_version_requirement("2"):
@@ -49,6 +76,8 @@ def v1_to_v2(
49
76
  )
50
77
 
51
78
  SecurePath("snowflake.yml").rename("snowflake_V1.yml")
79
+ if has_local_yml:
80
+ SecurePath("snowflake.local.yml").rename("snowflake_V1.local.yml")
52
81
  with open("snowflake.yml", "w") as file:
53
82
  yaml.dump(
54
83
  pd_v2.model_dump(
@@ -6,7 +6,7 @@ from typing import Any, Dict, Literal, Optional
6
6
 
7
7
  from click import ClickException
8
8
  from snowflake.cli._plugins.nativeapp.artifacts import (
9
- build_bundle,
9
+ BundleMap,
10
10
  )
11
11
  from snowflake.cli._plugins.snowpark.common import is_name_a_templated_one
12
12
  from snowflake.cli.api.constants import (
@@ -216,17 +216,22 @@ def convert_native_app_to_v2_data(
216
216
  # glob patterns. The simplest solution is to bundle the app and find the
217
217
  # manifest file from the resultant BundleMap, since the bundle process ensures
218
218
  # that only a single source path can map to the corresponding destination path
219
- try:
220
- bundle_map = build_bundle(
221
- project_root, Path(native_app.deploy_root), native_app.artifacts
222
- )
223
- except Exception as e:
224
- # The manifest field is required, so we can't gracefully handle bundle failures
225
- raise ClickException(
226
- f"{e}\nCould not bundle Native App artifacts, unable to perform migration"
227
- ) from e
228
-
229
- manifest_path = bundle_map.to_project_path(Path("manifest.yml"))
219
+ bundle_map = BundleMap(
220
+ project_root=project_root, deploy_root=Path(native_app.deploy_root)
221
+ )
222
+ for artifact in native_app.artifacts:
223
+ bundle_map.add(artifact)
224
+
225
+ manifest_path = next(
226
+ (
227
+ src
228
+ for src, dest in bundle_map.all_mappings(
229
+ absolute=True, expand_directories=True
230
+ )
231
+ if dest.name == "manifest.yml"
232
+ ),
233
+ None,
234
+ )
230
235
  if not manifest_path:
231
236
  # The manifest field is required, so we can't gracefully handle it being missing
232
237
  raise ClickException(
@@ -236,7 +241,7 @@ def convert_native_app_to_v2_data(
236
241
 
237
242
  # Use a POSIX path to be consistent with other migrated fields
238
243
  # which use POSIX paths as default values
239
- return manifest_path.as_posix()
244
+ return manifest_path.relative_to(project_root).as_posix()
240
245
 
241
246
  def _make_template(template: str) -> str:
242
247
  return f"{PROJECT_TEMPLATE_VARIABLE_OPENING} {template} {PROJECT_TEMPLATE_VARIABLE_CLOSING}"
@@ -41,7 +41,7 @@ class DefinitionManager:
41
41
  USER_DEFINITION_FILENAME = "snowflake.local.yml"
42
42
 
43
43
  project_root: Path
44
- _project_config_paths: List[Path]
44
+ project_config_paths: List[Path]
45
45
 
46
46
  def __init__(
47
47
  self,
@@ -53,12 +53,12 @@ class DefinitionManager:
53
53
  )
54
54
 
55
55
  self.project_root = project_root
56
- self._project_config_paths = self._find_definition_files(self.project_root)
56
+ self.project_config_paths = self._find_definition_files(self.project_root)
57
57
  self._context_overrides = context_overrides
58
58
 
59
59
  @functools.cached_property
60
60
  def has_definition_file(self):
61
- return len(self._project_config_paths) > 0
61
+ return len(self.project_config_paths) > 0
62
62
 
63
63
  @staticmethod
64
64
  def _find_definition_files(project_root: Path) -> List[Path]:
@@ -126,11 +126,11 @@ class DefinitionManager:
126
126
 
127
127
  @functools.cached_property
128
128
  def _project_properties(self) -> ProjectProperties:
129
- return load_project(self._project_config_paths, self._context_overrides)
129
+ return load_project(self.project_config_paths, self._context_overrides)
130
130
 
131
131
  @functools.cached_property
132
132
  def _raw_project_data(self) -> ProjectProperties:
133
- return load_project(self._project_config_paths, {}, False)
133
+ return load_project(self.project_config_paths, {}, False)
134
134
 
135
135
  @functools.cached_property
136
136
  def project_definition(self) -> ProjectDefinitionV1:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: snowflake-cli-labs
3
- Version: 3.0.0rc4
3
+ Version: 3.0.0rc5
4
4
  Summary: Snowflake CLI
5
5
  Project-URL: Source code, https://github.com/snowflakedb/snowflake-cli
6
6
  Project-URL: Bug Tracker, https://github.com/snowflakedb/snowflake-cli/issues
@@ -1,4 +1,4 @@
1
- snowflake/cli/__about__.py,sha256=s5AEYygcF4ZrDzYhUa_o6V7tqbbgW4aJv1Qu4jwQYk0,636
1
+ snowflake/cli/__about__.py,sha256=Y9QU0FSitn67LLzreNuyZanWICcn5RXROW0vJNPtMDM,636
2
2
  snowflake/cli/__init__.py,sha256=uGA_QRGW3iGwaegpFsLgOhup0zBliBSXh9ou8J439uU,578
3
3
  snowflake/cli/_app/__init__.py,sha256=CR_uTgoqHnU1XdyRhm5iQsS86yWXGVx5Ht7aGSDNFmc,765
4
4
  snowflake/cli/_app/__main__.py,sha256=mHaHr0OsE2H_kUzNE3pu1znAr_stjXTZ4LAp7Hi2_po,834
@@ -49,7 +49,7 @@ snowflake/cli/_plugins/git/commands.py,sha256=4NghBGIhxnETtr7aiy9dsQR7YD-8FR2SWp
49
49
  snowflake/cli/_plugins/git/manager.py,sha256=4Sh5ZCN4ED3Rlegc3bW7apUwGcIfEOfXcKvP-Q-arIM,5534
50
50
  snowflake/cli/_plugins/git/plugin_spec.py,sha256=aadJK8d9Aanwpmktd_eRYwf8OJvN-V8iCHIpjL7AM44,992
51
51
  snowflake/cli/_plugins/helpers/__init__.py,sha256=uGA_QRGW3iGwaegpFsLgOhup0zBliBSXh9ou8J439uU,578
52
- snowflake/cli/_plugins/helpers/commands.py,sha256=EUTsnlHfooMFzqE3kHvoqntNnzZQ1Nqfe55NfoDRJ-s,2114
52
+ snowflake/cli/_plugins/helpers/commands.py,sha256=Xg_Aaof2mcGqIOOo0Hfr1Af0xs8ZexJ-1aE_ew2xLdg,3413
53
53
  snowflake/cli/_plugins/helpers/plugin_spec.py,sha256=FTdWSNWj36-d83iM2PP2jwCGZhYNKQcOIAlm4Uo3qrA,996
54
54
  snowflake/cli/_plugins/init/__init__.py,sha256=uGA_QRGW3iGwaegpFsLgOhup0zBliBSXh9ou8J439uU,578
55
55
  snowflake/cli/_plugins/init/commands.py,sha256=veBJpbMmHFUyIBiNn1umpy763I-TKeGhHHe5pCaJ58I,8904
@@ -194,8 +194,8 @@ snowflake/cli/api/plugins/command/__init__.py,sha256=qCzBzpq8__2OUN0PcruIKgQXI2V
194
194
  snowflake/cli/api/plugins/command/plugin_hook_specs.py,sha256=AHJGk6j3NRzalIe4llM3Mt0-opHui1sLdbILoEMhpuA,714
195
195
  snowflake/cli/api/project/__init__.py,sha256=uGA_QRGW3iGwaegpFsLgOhup0zBliBSXh9ou8J439uU,578
196
196
  snowflake/cli/api/project/definition.py,sha256=5vhSH97v48rWyk7vWGxWngpsEcgJ9-8IX1SYzGYwrUg,4333
197
- snowflake/cli/api/project/definition_conversion.py,sha256=CqQWtJB4aUSSUw_zTtD5jiI1-Tskxnyf5hq1JzBgE7E,14888
198
- snowflake/cli/api/project/definition_manager.py,sha256=mquz4lDFUtlrlSTpmMVesX3nrJouDdO0slRgCLDeQrU,4985
197
+ snowflake/cli/api/project/definition_conversion.py,sha256=fAX3CdC0IgvC3oNwZ1Am3Yls2Yfsq4a73Coym_DUsNQ,14916
198
+ snowflake/cli/api/project/definition_manager.py,sha256=YEqyxL_meH94YIJD4Lv4d3By_NwEh9scYKhJJUPEprI,4980
199
199
  snowflake/cli/api/project/errors.py,sha256=9TGN2ezqSCHmSGy1U7AByaJm5Xf47zN-7N3i6R6fyBg,2136
200
200
  snowflake/cli/api/project/project_verification.py,sha256=smprjxJZlqqIPYuyf6a3OJitRpn8Ru6tAoZB-DdEz1s,990
201
201
  snowflake/cli/api/project/util.py,sha256=eOJbXx4CZ7DfmHI4-CJT0cV7lP8DH0gI9JTBic7-xNs,9639
@@ -235,8 +235,8 @@ snowflake/cli/api/utils/naming_utils.py,sha256=uGA_QRGW3iGwaegpFsLgOhup0zBliBSXh
235
235
  snowflake/cli/api/utils/path_utils.py,sha256=ru0jgw6Ur5zhqpHhj_eAqcaJdrgEgr3bC7Z02FnQV18,1218
236
236
  snowflake/cli/api/utils/templating_functions.py,sha256=DlmpGAEY6OBArtIap6kN1aaILPwx2ynqKflPwjj7BbU,4935
237
237
  snowflake/cli/api/utils/types.py,sha256=fVKuls8axKSsBzPqWwrkwkwoXXmedqxNJKqfXrrGyBM,1190
238
- snowflake_cli_labs-3.0.0rc4.dist-info/METADATA,sha256=cS-ClSglu6IDbtt5y26UWv7umS-EJeCyOhXcaOK3I68,17998
239
- snowflake_cli_labs-3.0.0rc4.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
240
- snowflake_cli_labs-3.0.0rc4.dist-info/entry_points.txt,sha256=6QmSI0wUX6p7f-dGvrPdswlQyVAVGi1AtOUbE8X6bho,58
241
- snowflake_cli_labs-3.0.0rc4.dist-info/licenses/LICENSE,sha256=mJMA3Uz2AbjU_kVggo1CAx01XhBsI7BSi2H7ggUg_-c,11344
242
- snowflake_cli_labs-3.0.0rc4.dist-info/RECORD,,
238
+ snowflake_cli_labs-3.0.0rc5.dist-info/METADATA,sha256=1VRaJowjwIKUKOqHFoSE7Ek-0xnjYt1_S1xEjRiu3H8,17998
239
+ snowflake_cli_labs-3.0.0rc5.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
240
+ snowflake_cli_labs-3.0.0rc5.dist-info/entry_points.txt,sha256=6QmSI0wUX6p7f-dGvrPdswlQyVAVGi1AtOUbE8X6bho,58
241
+ snowflake_cli_labs-3.0.0rc5.dist-info/licenses/LICENSE,sha256=mJMA3Uz2AbjU_kVggo1CAx01XhBsI7BSi2H7ggUg_-c,11344
242
+ snowflake_cli_labs-3.0.0rc5.dist-info/RECORD,,