snowflake-cli-labs 3.0.0rc4__py3-none-any.whl → 3.0.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.
- README.md +21 -0
- {snowflake_cli_labs-3.0.0rc4.dist-info → snowflake_cli_labs-3.0.1.dist-info}/METADATA +6 -96
- snowflake_cli_labs-3.0.1.dist-info/RECORD +5 -0
- snowflake/cli/__about__.py +0 -17
- snowflake/cli/__init__.py +0 -13
- snowflake/cli/_app/__init__.py +0 -22
- snowflake/cli/_app/__main__.py +0 -31
- snowflake/cli/_app/api_impl/__init__.py +0 -13
- snowflake/cli/_app/api_impl/plugin/__init__.py +0 -13
- snowflake/cli/_app/api_impl/plugin/plugin_config_provider_impl.py +0 -66
- snowflake/cli/_app/cli_app.py +0 -252
- snowflake/cli/_app/commands_registration/__init__.py +0 -33
- snowflake/cli/_app/commands_registration/builtin_plugins.py +0 -50
- snowflake/cli/_app/commands_registration/command_plugins_loader.py +0 -169
- snowflake/cli/_app/commands_registration/commands_registration_with_callbacks.py +0 -105
- snowflake/cli/_app/commands_registration/exception_logging.py +0 -26
- snowflake/cli/_app/commands_registration/threadsafe.py +0 -48
- snowflake/cli/_app/commands_registration/typer_registration.py +0 -153
- snowflake/cli/_app/constants.py +0 -19
- snowflake/cli/_app/dev/__init__.py +0 -13
- snowflake/cli/_app/dev/commands_structure.py +0 -48
- snowflake/cli/_app/dev/docs/__init__.py +0 -13
- snowflake/cli/_app/dev/docs/commands_docs_generator.py +0 -118
- snowflake/cli/_app/dev/docs/generator.py +0 -35
- snowflake/cli/_app/dev/docs/project_definition_docs_generator.py +0 -58
- snowflake/cli/_app/dev/docs/project_definition_generate_json_schema.py +0 -227
- snowflake/cli/_app/dev/docs/template_utils.py +0 -23
- snowflake/cli/_app/dev/docs/templates/definition_description.rst.jinja2 +0 -38
- snowflake/cli/_app/dev/docs/templates/overview.rst.jinja2 +0 -9
- snowflake/cli/_app/dev/docs/templates/usage.rst.jinja2 +0 -67
- snowflake/cli/_app/dev/pycharm_remote_debug.py +0 -46
- snowflake/cli/_app/loggers.py +0 -199
- snowflake/cli/_app/main_typer.py +0 -62
- snowflake/cli/_app/printing.py +0 -181
- snowflake/cli/_app/secret.py +0 -9
- snowflake/cli/_app/snow_connector.py +0 -309
- snowflake/cli/_app/telemetry.py +0 -220
- snowflake/cli/_app/version_check.py +0 -74
- snowflake/cli/_plugins/__init__.py +0 -13
- snowflake/cli/_plugins/connection/__init__.py +0 -13
- snowflake/cli/_plugins/connection/commands.py +0 -353
- snowflake/cli/_plugins/connection/plugin_spec.py +0 -30
- snowflake/cli/_plugins/connection/util.py +0 -195
- snowflake/cli/_plugins/cortex/__init__.py +0 -13
- snowflake/cli/_plugins/cortex/commands.py +0 -332
- snowflake/cli/_plugins/cortex/constants.py +0 -17
- snowflake/cli/_plugins/cortex/manager.py +0 -189
- snowflake/cli/_plugins/cortex/plugin_spec.py +0 -30
- snowflake/cli/_plugins/cortex/types.py +0 -22
- snowflake/cli/_plugins/git/__init__.py +0 -13
- snowflake/cli/_plugins/git/commands.py +0 -358
- snowflake/cli/_plugins/git/manager.py +0 -151
- snowflake/cli/_plugins/git/plugin_spec.py +0 -30
- snowflake/cli/_plugins/helpers/__init__.py +0 -13
- snowflake/cli/_plugins/helpers/commands.py +0 -61
- snowflake/cli/_plugins/helpers/plugin_spec.py +0 -30
- snowflake/cli/_plugins/init/__init__.py +0 -13
- snowflake/cli/_plugins/init/commands.py +0 -248
- snowflake/cli/_plugins/init/plugin_spec.py +0 -30
- snowflake/cli/_plugins/nativeapp/__init__.py +0 -13
- snowflake/cli/_plugins/nativeapp/artifacts.py +0 -757
- snowflake/cli/_plugins/nativeapp/bundle_context.py +0 -31
- snowflake/cli/_plugins/nativeapp/codegen/__init__.py +0 -13
- snowflake/cli/_plugins/nativeapp/codegen/artifact_processor.py +0 -91
- snowflake/cli/_plugins/nativeapp/codegen/compiler.py +0 -149
- snowflake/cli/_plugins/nativeapp/codegen/sandbox.py +0 -306
- snowflake/cli/_plugins/nativeapp/codegen/setup/native_app_setup_processor.py +0 -249
- snowflake/cli/_plugins/nativeapp/codegen/setup/setup_driver.py.source +0 -59
- snowflake/cli/_plugins/nativeapp/codegen/snowpark/callback_source.py.jinja +0 -181
- snowflake/cli/_plugins/nativeapp/codegen/snowpark/extension_function_utils.py +0 -217
- snowflake/cli/_plugins/nativeapp/codegen/snowpark/models.py +0 -61
- snowflake/cli/_plugins/nativeapp/codegen/snowpark/python_processor.py +0 -523
- snowflake/cli/_plugins/nativeapp/codegen/templates/templates_processor.py +0 -114
- snowflake/cli/_plugins/nativeapp/commands.py +0 -559
- snowflake/cli/_plugins/nativeapp/common_flags.py +0 -44
- snowflake/cli/_plugins/nativeapp/constants.py +0 -27
- snowflake/cli/_plugins/nativeapp/entities/__init__.py +0 -0
- snowflake/cli/_plugins/nativeapp/entities/application.py +0 -878
- snowflake/cli/_plugins/nativeapp/entities/application_package.py +0 -1392
- snowflake/cli/_plugins/nativeapp/exceptions.py +0 -113
- snowflake/cli/_plugins/nativeapp/feature_flags.py +0 -24
- snowflake/cli/_plugins/nativeapp/manager.py +0 -415
- snowflake/cli/_plugins/nativeapp/plugin_spec.py +0 -30
- snowflake/cli/_plugins/nativeapp/policy.py +0 -53
- snowflake/cli/_plugins/nativeapp/project_model.py +0 -211
- snowflake/cli/_plugins/nativeapp/run_processor.py +0 -184
- snowflake/cli/_plugins/nativeapp/same_account_install_method.py +0 -70
- snowflake/cli/_plugins/nativeapp/teardown_processor.py +0 -70
- snowflake/cli/_plugins/nativeapp/utils.py +0 -98
- snowflake/cli/_plugins/nativeapp/v2_conversions/v2_to_v1_decorator.py +0 -262
- snowflake/cli/_plugins/nativeapp/version/__init__.py +0 -13
- snowflake/cli/_plugins/nativeapp/version/commands.py +0 -141
- snowflake/cli/_plugins/nativeapp/version/version_processor.py +0 -98
- snowflake/cli/_plugins/notebook/__init__.py +0 -13
- snowflake/cli/_plugins/notebook/commands.py +0 -86
- snowflake/cli/_plugins/notebook/exceptions.py +0 -20
- snowflake/cli/_plugins/notebook/manager.py +0 -71
- snowflake/cli/_plugins/notebook/plugin_spec.py +0 -30
- snowflake/cli/_plugins/notebook/types.py +0 -15
- snowflake/cli/_plugins/object/__init__.py +0 -13
- snowflake/cli/_plugins/object/command_aliases.py +0 -95
- snowflake/cli/_plugins/object/commands.py +0 -180
- snowflake/cli/_plugins/object/common.py +0 -85
- snowflake/cli/_plugins/object/manager.py +0 -118
- snowflake/cli/_plugins/object/plugin_spec.py +0 -30
- snowflake/cli/_plugins/snowpark/__init__.py +0 -13
- snowflake/cli/_plugins/snowpark/commands.py +0 -450
- snowflake/cli/_plugins/snowpark/common.py +0 -268
- snowflake/cli/_plugins/snowpark/models.py +0 -150
- snowflake/cli/_plugins/snowpark/package/__init__.py +0 -13
- snowflake/cli/_plugins/snowpark/package/anaconda_packages.py +0 -199
- snowflake/cli/_plugins/snowpark/package/commands.py +0 -195
- snowflake/cli/_plugins/snowpark/package/manager.py +0 -44
- snowflake/cli/_plugins/snowpark/package/utils.py +0 -26
- snowflake/cli/_plugins/snowpark/package_utils.py +0 -354
- snowflake/cli/_plugins/snowpark/plugin_spec.py +0 -30
- snowflake/cli/_plugins/snowpark/snowpark_entity.py +0 -29
- snowflake/cli/_plugins/snowpark/snowpark_entity_model.py +0 -173
- snowflake/cli/_plugins/snowpark/snowpark_project_paths.py +0 -109
- snowflake/cli/_plugins/snowpark/snowpark_shared.py +0 -59
- snowflake/cli/_plugins/snowpark/zipper.py +0 -89
- snowflake/cli/_plugins/spcs/__init__.py +0 -33
- snowflake/cli/_plugins/spcs/common.py +0 -99
- snowflake/cli/_plugins/spcs/compute_pool/__init__.py +0 -13
- snowflake/cli/_plugins/spcs/compute_pool/commands.py +0 -241
- snowflake/cli/_plugins/spcs/compute_pool/manager.py +0 -121
- snowflake/cli/_plugins/spcs/image_registry/__init__.py +0 -13
- snowflake/cli/_plugins/spcs/image_registry/commands.py +0 -65
- snowflake/cli/_plugins/spcs/image_registry/manager.py +0 -105
- snowflake/cli/_plugins/spcs/image_repository/__init__.py +0 -13
- snowflake/cli/_plugins/spcs/image_repository/commands.py +0 -202
- snowflake/cli/_plugins/spcs/image_repository/manager.py +0 -84
- snowflake/cli/_plugins/spcs/plugin_spec.py +0 -30
- snowflake/cli/_plugins/spcs/services/__init__.py +0 -13
- snowflake/cli/_plugins/spcs/services/commands.py +0 -345
- snowflake/cli/_plugins/spcs/services/manager.py +0 -208
- snowflake/cli/_plugins/sql/__init__.py +0 -13
- snowflake/cli/_plugins/sql/commands.py +0 -86
- snowflake/cli/_plugins/sql/manager.py +0 -92
- snowflake/cli/_plugins/sql/plugin_spec.py +0 -30
- snowflake/cli/_plugins/sql/snowsql_templating.py +0 -28
- snowflake/cli/_plugins/stage/__init__.py +0 -13
- snowflake/cli/_plugins/stage/commands.py +0 -264
- snowflake/cli/_plugins/stage/diff.py +0 -280
- snowflake/cli/_plugins/stage/manager.py +0 -582
- snowflake/cli/_plugins/stage/md5.py +0 -160
- snowflake/cli/_plugins/stage/plugin_spec.py +0 -30
- snowflake/cli/_plugins/stage/utils.py +0 -54
- snowflake/cli/_plugins/streamlit/__init__.py +0 -13
- snowflake/cli/_plugins/streamlit/commands.py +0 -195
- snowflake/cli/_plugins/streamlit/manager.py +0 -220
- snowflake/cli/_plugins/streamlit/plugin_spec.py +0 -30
- snowflake/cli/_plugins/streamlit/streamlit_entity.py +0 -12
- snowflake/cli/_plugins/streamlit/streamlit_entity_model.py +0 -66
- snowflake/cli/_plugins/workspace/__init__.py +0 -13
- snowflake/cli/_plugins/workspace/action_context.py +0 -18
- snowflake/cli/_plugins/workspace/commands.py +0 -306
- snowflake/cli/_plugins/workspace/manager.py +0 -74
- snowflake/cli/_plugins/workspace/plugin_spec.py +0 -30
- snowflake/cli/api/__init__.py +0 -48
- snowflake/cli/api/cli_global_context.py +0 -247
- snowflake/cli/api/commands/__init__.py +0 -13
- snowflake/cli/api/commands/alias.py +0 -23
- snowflake/cli/api/commands/common.py +0 -25
- snowflake/cli/api/commands/decorators.py +0 -369
- snowflake/cli/api/commands/execution_metadata.py +0 -40
- snowflake/cli/api/commands/experimental_behaviour.py +0 -18
- snowflake/cli/api/commands/flags.py +0 -561
- snowflake/cli/api/commands/overrideable_parameter.py +0 -143
- snowflake/cli/api/commands/snow_typer.py +0 -247
- snowflake/cli/api/commands/utils.py +0 -18
- snowflake/cli/api/config.py +0 -380
- snowflake/cli/api/connections.py +0 -216
- snowflake/cli/api/console/__init__.py +0 -17
- snowflake/cli/api/console/abc.py +0 -94
- snowflake/cli/api/console/console.py +0 -134
- snowflake/cli/api/console/enum.py +0 -17
- snowflake/cli/api/constants.py +0 -90
- snowflake/cli/api/entities/common.py +0 -56
- snowflake/cli/api/entities/utils.py +0 -370
- snowflake/cli/api/errno.py +0 -28
- snowflake/cli/api/exceptions.py +0 -190
- snowflake/cli/api/feature_flags.py +0 -54
- snowflake/cli/api/identifiers.py +0 -190
- snowflake/cli/api/metrics.py +0 -92
- snowflake/cli/api/output/__init__.py +0 -13
- snowflake/cli/api/output/formats.py +0 -20
- snowflake/cli/api/output/types.py +0 -118
- snowflake/cli/api/plugins/__init__.py +0 -13
- snowflake/cli/api/plugins/command/__init__.py +0 -72
- snowflake/cli/api/plugins/command/plugin_hook_specs.py +0 -21
- snowflake/cli/api/plugins/plugin_config.py +0 -32
- snowflake/cli/api/project/__init__.py +0 -13
- snowflake/cli/api/project/definition.py +0 -126
- snowflake/cli/api/project/definition_conversion.py +0 -395
- snowflake/cli/api/project/definition_manager.py +0 -145
- snowflake/cli/api/project/errors.py +0 -56
- snowflake/cli/api/project/project_verification.py +0 -23
- snowflake/cli/api/project/schemas/__init__.py +0 -13
- snowflake/cli/api/project/schemas/entities/__init__.py +0 -13
- snowflake/cli/api/project/schemas/entities/common.py +0 -153
- snowflake/cli/api/project/schemas/entities/entities.py +0 -61
- snowflake/cli/api/project/schemas/project_definition.py +0 -330
- snowflake/cli/api/project/schemas/template.py +0 -77
- snowflake/cli/api/project/schemas/updatable_model.py +0 -202
- snowflake/cli/api/project/schemas/v1/__init__.py +0 -0
- snowflake/cli/api/project/schemas/v1/identifier_model.py +0 -51
- snowflake/cli/api/project/schemas/v1/native_app/__init__.py +0 -0
- snowflake/cli/api/project/schemas/v1/native_app/application.py +0 -61
- snowflake/cli/api/project/schemas/v1/native_app/native_app.py +0 -93
- snowflake/cli/api/project/schemas/v1/native_app/package.py +0 -84
- snowflake/cli/api/project/schemas/v1/native_app/path_mapping.py +0 -65
- snowflake/cli/api/project/schemas/v1/snowpark/__init__.py +0 -0
- snowflake/cli/api/project/schemas/v1/snowpark/argument.py +0 -28
- snowflake/cli/api/project/schemas/v1/snowpark/callable.py +0 -69
- snowflake/cli/api/project/schemas/v1/snowpark/snowpark.py +0 -36
- snowflake/cli/api/project/schemas/v1/streamlit/__init__.py +0 -0
- snowflake/cli/api/project/schemas/v1/streamlit/streamlit.py +0 -47
- snowflake/cli/api/project/util.py +0 -278
- snowflake/cli/api/rendering/__init__.py +0 -13
- snowflake/cli/api/rendering/jinja.py +0 -118
- snowflake/cli/api/rendering/project_definition_templates.py +0 -43
- snowflake/cli/api/rendering/project_templates.py +0 -98
- snowflake/cli/api/rendering/sql_templates.py +0 -105
- snowflake/cli/api/rest_api.py +0 -178
- snowflake/cli/api/sanitizers.py +0 -43
- snowflake/cli/api/secure_path.py +0 -360
- snowflake/cli/api/secure_utils.py +0 -118
- snowflake/cli/api/sql_execution.py +0 -280
- snowflake/cli/api/utils/__init__.py +0 -13
- snowflake/cli/api/utils/cursor.py +0 -34
- snowflake/cli/api/utils/definition_rendering.py +0 -415
- snowflake/cli/api/utils/dict_utils.py +0 -73
- snowflake/cli/api/utils/error_handling.py +0 -23
- snowflake/cli/api/utils/graph.py +0 -97
- snowflake/cli/api/utils/models.py +0 -63
- snowflake/cli/api/utils/naming_utils.py +0 -13
- snowflake/cli/api/utils/path_utils.py +0 -36
- snowflake/cli/api/utils/templating_functions.py +0 -144
- snowflake/cli/api/utils/types.py +0 -35
- snowflake_cli_labs-3.0.0rc4.dist-info/RECORD +0 -242
- snowflake_cli_labs-3.0.0rc4.dist-info/entry_points.txt +0 -2
- {snowflake_cli_labs-3.0.0rc4.dist-info → snowflake_cli_labs-3.0.1.dist-info}/WHEEL +0 -0
- {snowflake_cli_labs-3.0.0rc4.dist-info → snowflake_cli_labs-3.0.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,145 +0,0 @@
|
|
|
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
|
-
|
|
15
|
-
from __future__ import annotations
|
|
16
|
-
|
|
17
|
-
import functools
|
|
18
|
-
import os
|
|
19
|
-
from pathlib import Path
|
|
20
|
-
from typing import List, Optional
|
|
21
|
-
|
|
22
|
-
from snowflake.cli.api.project.definition import ProjectProperties, load_project
|
|
23
|
-
from snowflake.cli.api.project.schemas.project_definition import (
|
|
24
|
-
ProjectDefinition,
|
|
25
|
-
ProjectDefinitionV1,
|
|
26
|
-
)
|
|
27
|
-
from snowflake.cli.api.utils.types import Context
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def _compat_is_mount(path: Path):
|
|
31
|
-
try:
|
|
32
|
-
return path.is_mount()
|
|
33
|
-
except NotImplementedError:
|
|
34
|
-
# If we can't figure out if path is mount then let's assume it is
|
|
35
|
-
# Windows support added in Python 3.12
|
|
36
|
-
return True
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
class DefinitionManager:
|
|
40
|
-
BASE_DEFINITION_FILENAME = "snowflake.yml"
|
|
41
|
-
USER_DEFINITION_FILENAME = "snowflake.local.yml"
|
|
42
|
-
|
|
43
|
-
project_root: Path
|
|
44
|
-
_project_config_paths: List[Path]
|
|
45
|
-
|
|
46
|
-
def __init__(
|
|
47
|
-
self,
|
|
48
|
-
project_arg: Optional[str] = None,
|
|
49
|
-
context_overrides: Optional[Context] = None,
|
|
50
|
-
) -> None:
|
|
51
|
-
project_root = Path(
|
|
52
|
-
os.path.abspath(project_arg) if project_arg else os.getcwd()
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
self.project_root = project_root
|
|
56
|
-
self._project_config_paths = self._find_definition_files(self.project_root)
|
|
57
|
-
self._context_overrides = context_overrides
|
|
58
|
-
|
|
59
|
-
@functools.cached_property
|
|
60
|
-
def has_definition_file(self):
|
|
61
|
-
return len(self._project_config_paths) > 0
|
|
62
|
-
|
|
63
|
-
@staticmethod
|
|
64
|
-
def _find_definition_files(project_root: Path) -> List[Path]:
|
|
65
|
-
base_config_file_path = DefinitionManager._base_definition_file_if_available(
|
|
66
|
-
project_root
|
|
67
|
-
)
|
|
68
|
-
user_config_file_path = DefinitionManager._user_definition_file_if_available(
|
|
69
|
-
project_root
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
definition_files: List[Path] = []
|
|
73
|
-
if base_config_file_path:
|
|
74
|
-
definition_files.append(base_config_file_path)
|
|
75
|
-
if user_config_file_path:
|
|
76
|
-
definition_files.append(user_config_file_path)
|
|
77
|
-
|
|
78
|
-
return definition_files
|
|
79
|
-
|
|
80
|
-
@staticmethod
|
|
81
|
-
def find_project_root(search_path: Path) -> Optional[Path]:
|
|
82
|
-
"""
|
|
83
|
-
Recurse up the directory tree from the given search path until we find
|
|
84
|
-
a directory that contains a snowflake.yml file. We'll stop if we cross
|
|
85
|
-
a filesystem boundary or hit the user's HOME directory.
|
|
86
|
-
"""
|
|
87
|
-
current_path = search_path
|
|
88
|
-
starting_mount = _compat_is_mount(search_path)
|
|
89
|
-
while current_path:
|
|
90
|
-
if (
|
|
91
|
-
_compat_is_mount(current_path) != starting_mount
|
|
92
|
-
or current_path.parent == current_path
|
|
93
|
-
or current_path == Path.home()
|
|
94
|
-
):
|
|
95
|
-
return None
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
DefinitionManager._base_definition_file_if_available(current_path)
|
|
99
|
-
is not None
|
|
100
|
-
):
|
|
101
|
-
# found snowflake.yml, end the search here
|
|
102
|
-
return current_path
|
|
103
|
-
|
|
104
|
-
current_path = current_path.parent
|
|
105
|
-
|
|
106
|
-
return None
|
|
107
|
-
|
|
108
|
-
@staticmethod
|
|
109
|
-
def _definition_if_available(filename, project_path: Path) -> Optional[Path]:
|
|
110
|
-
file_path = Path(project_path) / filename
|
|
111
|
-
if file_path.is_file():
|
|
112
|
-
return file_path
|
|
113
|
-
return None
|
|
114
|
-
|
|
115
|
-
@staticmethod
|
|
116
|
-
def _base_definition_file_if_available(project_path: Path) -> Optional[Path]:
|
|
117
|
-
return DefinitionManager._definition_if_available(
|
|
118
|
-
DefinitionManager.BASE_DEFINITION_FILENAME, project_path
|
|
119
|
-
)
|
|
120
|
-
|
|
121
|
-
@staticmethod
|
|
122
|
-
def _user_definition_file_if_available(project_path: Path) -> Optional[Path]:
|
|
123
|
-
return DefinitionManager._definition_if_available(
|
|
124
|
-
DefinitionManager.USER_DEFINITION_FILENAME, project_path
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
@functools.cached_property
|
|
128
|
-
def _project_properties(self) -> ProjectProperties:
|
|
129
|
-
return load_project(self._project_config_paths, self._context_overrides)
|
|
130
|
-
|
|
131
|
-
@functools.cached_property
|
|
132
|
-
def _raw_project_data(self) -> ProjectProperties:
|
|
133
|
-
return load_project(self._project_config_paths, {}, False)
|
|
134
|
-
|
|
135
|
-
@functools.cached_property
|
|
136
|
-
def project_definition(self) -> ProjectDefinitionV1:
|
|
137
|
-
return self._project_properties.project_definition
|
|
138
|
-
|
|
139
|
-
@functools.cached_property
|
|
140
|
-
def unrendered_project_definition(self) -> ProjectDefinition:
|
|
141
|
-
return self._raw_project_data.project_definition
|
|
142
|
-
|
|
143
|
-
@functools.cached_property
|
|
144
|
-
def template_context(self) -> Context:
|
|
145
|
-
return self._project_properties.project_context
|
|
@@ -1,56 +0,0 @@
|
|
|
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
|
-
|
|
15
|
-
from textwrap import dedent
|
|
16
|
-
|
|
17
|
-
from click import ClickException
|
|
18
|
-
from pydantic import ValidationError
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class SchemaValidationError(ClickException):
|
|
22
|
-
generic_message = "For field {location} you provided '{input}'. This caused: {msg}"
|
|
23
|
-
message_templates = {
|
|
24
|
-
"string_type": "{msg} for field '{location}', you provided '{input}'.",
|
|
25
|
-
"extra_forbidden": "{msg}. You provided field '{location}' with value '{input}' that is not supported in given version.",
|
|
26
|
-
"missing": "Your project definition is missing the following field: '{location}'",
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
def __init__(self, error: ValidationError):
|
|
30
|
-
errors = error.errors()
|
|
31
|
-
message = f"During evaluation of {error.title} in project definition following errors were encountered:\n"
|
|
32
|
-
|
|
33
|
-
def calculate_location(e):
|
|
34
|
-
if e["loc"] is None:
|
|
35
|
-
return None
|
|
36
|
-
|
|
37
|
-
# show numbers as list indexes and strings as dictionary keys. Example: key1[0].key2
|
|
38
|
-
result = "".join(
|
|
39
|
-
f"[{item}]" if isinstance(item, int) else f".{item}"
|
|
40
|
-
for item in e["loc"]
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
# remove leading dot from the string if any:
|
|
44
|
-
return result[1:] if result.startswith(".") else result
|
|
45
|
-
|
|
46
|
-
message += "\n".join(
|
|
47
|
-
[
|
|
48
|
-
self.message_templates.get(e["type"], self.generic_message).format(
|
|
49
|
-
**e,
|
|
50
|
-
location=calculate_location(e),
|
|
51
|
-
)
|
|
52
|
-
for e in errors
|
|
53
|
-
]
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
super().__init__(dedent(message))
|
|
@@ -1,23 +0,0 @@
|
|
|
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 snowflake.cli.api.cli_global_context import get_cli_context
|
|
15
|
-
from snowflake.cli.api.exceptions import NoProjectDefinitionError
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def assert_project_type(project_type: str):
|
|
19
|
-
cli_context = get_cli_context()
|
|
20
|
-
if not getattr(cli_context.project_definition, project_type, None):
|
|
21
|
-
raise NoProjectDefinitionError(
|
|
22
|
-
project_type=project_type, project_root=cli_context.project_root
|
|
23
|
-
)
|
|
@@ -1,13 +0,0 @@
|
|
|
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.
|
|
@@ -1,13 +0,0 @@
|
|
|
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.
|
|
@@ -1,153 +0,0 @@
|
|
|
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
|
-
|
|
15
|
-
from __future__ import annotations
|
|
16
|
-
|
|
17
|
-
from abc import ABC
|
|
18
|
-
from typing import Dict, Generic, List, Optional, TypeVar, Union
|
|
19
|
-
|
|
20
|
-
from pydantic import Field, PrivateAttr, field_validator
|
|
21
|
-
from snowflake.cli.api.identifiers import FQN
|
|
22
|
-
from snowflake.cli.api.project.schemas.updatable_model import (
|
|
23
|
-
IdentifierField,
|
|
24
|
-
UpdatableModel,
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
class SqlScriptHookType(UpdatableModel):
|
|
29
|
-
sql_script: str = Field(title="SQL file path relative to the project root")
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
# Currently sql_script is the only supported hook type. Change to a Union once other hook types are added
|
|
33
|
-
PostDeployHook = SqlScriptHookType
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
class MetaField(UpdatableModel):
|
|
37
|
-
warehouse: Optional[str] = IdentifierField(
|
|
38
|
-
title="Warehouse used to run the scripts", default=None
|
|
39
|
-
)
|
|
40
|
-
role: Optional[str] = IdentifierField(
|
|
41
|
-
title="Role to use when creating the entity object",
|
|
42
|
-
default=None,
|
|
43
|
-
)
|
|
44
|
-
post_deploy: Optional[List[PostDeployHook]] = Field(
|
|
45
|
-
title="Actions that will be executed after the application object is created/upgraded",
|
|
46
|
-
default=None,
|
|
47
|
-
)
|
|
48
|
-
use_mixins: Optional[List[str]] = Field(
|
|
49
|
-
title="Name of the mixin used to fill the entity fields",
|
|
50
|
-
default=None,
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
@field_validator("use_mixins", mode="before")
|
|
54
|
-
@classmethod
|
|
55
|
-
def ensure_use_mixins_is_a_list(
|
|
56
|
-
cls, mixins: Optional[str | List[str]]
|
|
57
|
-
) -> Optional[List[str]]:
|
|
58
|
-
if isinstance(mixins, str):
|
|
59
|
-
return [mixins]
|
|
60
|
-
return mixins
|
|
61
|
-
|
|
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
|
-
|
|
69
|
-
class EntityModelBase(ABC, UpdatableModel):
|
|
70
|
-
@classmethod
|
|
71
|
-
def get_type(cls) -> str:
|
|
72
|
-
return cls.model_fields["type"].annotation.__args__[0]
|
|
73
|
-
|
|
74
|
-
meta: Optional[MetaField] = Field(title="Meta fields", default=None)
|
|
75
|
-
identifier: Optional[Union[Identifier | str]] = Field(
|
|
76
|
-
title="Entity identifier", default=None
|
|
77
|
-
)
|
|
78
|
-
# Set by parent model in post validation. To reference it use `entity_id`.
|
|
79
|
-
_entity_id: str = PrivateAttr(default=None)
|
|
80
|
-
|
|
81
|
-
@property
|
|
82
|
-
def entity_id(self):
|
|
83
|
-
return self._entity_id
|
|
84
|
-
|
|
85
|
-
def set_entity_id(self, value: str):
|
|
86
|
-
self._entity_id = value
|
|
87
|
-
|
|
88
|
-
def validate_identifier(self):
|
|
89
|
-
"""Helper that's used by ProjectDefinition validator."""
|
|
90
|
-
if not self._entity_id and not self.identifier:
|
|
91
|
-
raise ValueError("Missing entity identifier")
|
|
92
|
-
|
|
93
|
-
@property
|
|
94
|
-
def fqn(self) -> FQN:
|
|
95
|
-
if isinstance(self.identifier, str):
|
|
96
|
-
return FQN.from_string(self.identifier)
|
|
97
|
-
if isinstance(self.identifier, Identifier):
|
|
98
|
-
return FQN.from_identifier_model_v2(self.identifier)
|
|
99
|
-
if self.entity_id:
|
|
100
|
-
return FQN.from_string(self.entity_id)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
TargetType = TypeVar("TargetType")
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
class TargetField(UpdatableModel, Generic[TargetType]):
|
|
107
|
-
target: str = Field(
|
|
108
|
-
title="Reference to a target entity",
|
|
109
|
-
)
|
|
110
|
-
|
|
111
|
-
def get_type(self) -> type:
|
|
112
|
-
"""
|
|
113
|
-
Returns the generic type of this class, indicating the entity type.
|
|
114
|
-
Pydantic extracts Generic annotations, and populates
|
|
115
|
-
them in __pydantic_generic_metadata__
|
|
116
|
-
"""
|
|
117
|
-
return self.__pydantic_generic_metadata__["args"][0]
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
)
|
|
125
|
-
|
|
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})"
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
class ExternalAccessBaseModel:
|
|
134
|
-
external_access_integrations: Optional[List[str]] = Field(
|
|
135
|
-
title="Names of external access integrations needed for this entity to access external networks",
|
|
136
|
-
default=[],
|
|
137
|
-
)
|
|
138
|
-
secrets: Optional[Dict[str, str]] = Field(
|
|
139
|
-
title="Assigns the names of secrets to variables so that you can use the variables to reference the secrets",
|
|
140
|
-
default={},
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
def get_external_access_integrations_sql(self) -> str | None:
|
|
144
|
-
if not self.external_access_integrations:
|
|
145
|
-
return None
|
|
146
|
-
external_access_integration_name = ", ".join(self.external_access_integrations)
|
|
147
|
-
return f"external_access_integrations=({external_access_integration_name})"
|
|
148
|
-
|
|
149
|
-
def get_secrets_sql(self) -> str | None:
|
|
150
|
-
if not self.secrets:
|
|
151
|
-
return None
|
|
152
|
-
secrets = ", ".join(f"'{key}'={value}" for key, value in self.secrets.items())
|
|
153
|
-
return f"secrets=({secrets})"
|
|
@@ -1,61 +0,0 @@
|
|
|
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
|
-
|
|
15
|
-
from __future__ import annotations
|
|
16
|
-
|
|
17
|
-
from typing import Dict, List, Union, get_args
|
|
18
|
-
|
|
19
|
-
from snowflake.cli._plugins.nativeapp.entities.application import (
|
|
20
|
-
ApplicationEntity,
|
|
21
|
-
ApplicationEntityModel,
|
|
22
|
-
)
|
|
23
|
-
from snowflake.cli._plugins.nativeapp.entities.application_package import (
|
|
24
|
-
ApplicationPackageEntity,
|
|
25
|
-
ApplicationPackageEntityModel,
|
|
26
|
-
)
|
|
27
|
-
from snowflake.cli._plugins.snowpark.snowpark_entity import (
|
|
28
|
-
FunctionEntity,
|
|
29
|
-
ProcedureEntity,
|
|
30
|
-
)
|
|
31
|
-
from snowflake.cli._plugins.snowpark.snowpark_entity_model import (
|
|
32
|
-
FunctionEntityModel,
|
|
33
|
-
ProcedureEntityModel,
|
|
34
|
-
)
|
|
35
|
-
from snowflake.cli._plugins.streamlit.streamlit_entity import StreamlitEntity
|
|
36
|
-
from snowflake.cli._plugins.streamlit.streamlit_entity_model import (
|
|
37
|
-
StreamlitEntityModel,
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
Entity = Union[
|
|
41
|
-
ApplicationEntity,
|
|
42
|
-
ApplicationPackageEntity,
|
|
43
|
-
StreamlitEntity,
|
|
44
|
-
ProcedureEntity,
|
|
45
|
-
FunctionEntity,
|
|
46
|
-
]
|
|
47
|
-
EntityModel = Union[
|
|
48
|
-
ApplicationEntityModel,
|
|
49
|
-
ApplicationPackageEntityModel,
|
|
50
|
-
StreamlitEntityModel,
|
|
51
|
-
FunctionEntityModel,
|
|
52
|
-
ProcedureEntityModel,
|
|
53
|
-
]
|
|
54
|
-
|
|
55
|
-
ALL_ENTITIES: List[Entity] = [*get_args(Entity)]
|
|
56
|
-
ALL_ENTITY_MODELS: List[EntityModel] = [*get_args(EntityModel)]
|
|
57
|
-
|
|
58
|
-
v2_entity_model_types_map = {e.get_type(): e for e in ALL_ENTITY_MODELS}
|
|
59
|
-
v2_entity_model_to_entity_map: Dict[EntityModel, Entity] = {
|
|
60
|
-
e.get_entity_model_type(): e for e in ALL_ENTITIES
|
|
61
|
-
}
|