snowflake-cli-labs 2.4.1__py3-none-any.whl → 2.5.0rc1__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.
- snowflake/cli/__about__.py +15 -1
- snowflake/cli/__init__.py +13 -0
- snowflake/cli/api/__init__.py +14 -0
- snowflake/cli/api/cli_global_context.py +26 -0
- snowflake/cli/api/commands/__init__.py +13 -0
- snowflake/cli/api/commands/alias.py +14 -0
- snowflake/cli/api/commands/decorators.py +14 -0
- snowflake/cli/api/commands/experimental_behaviour.py +14 -0
- snowflake/cli/api/commands/flags.py +21 -1
- snowflake/cli/api/commands/project_initialisation.py +19 -2
- snowflake/cli/api/commands/snow_typer.py +90 -1
- snowflake/cli/api/config.py +14 -0
- snowflake/cli/api/console/__init__.py +14 -0
- snowflake/cli/api/console/abc.py +14 -0
- snowflake/cli/api/console/console.py +14 -0
- snowflake/cli/api/console/enum.py +14 -0
- snowflake/cli/api/constants.py +14 -0
- snowflake/cli/api/exceptions.py +22 -0
- snowflake/cli/api/feature_flags.py +14 -1
- snowflake/cli/api/identifiers.py +16 -2
- snowflake/cli/api/output/__init__.py +13 -0
- snowflake/cli/api/output/formats.py +14 -0
- snowflake/cli/api/output/types.py +14 -0
- snowflake/cli/api/plugins/__init__.py +13 -0
- snowflake/cli/api/plugins/command/__init__.py +14 -0
- snowflake/cli/api/plugins/command/plugin_hook_specs.py +14 -0
- snowflake/cli/api/plugins/plugin_config.py +14 -0
- snowflake/cli/api/project/__init__.py +13 -0
- snowflake/cli/api/project/definition.py +54 -8
- snowflake/cli/api/project/definition_manager.py +28 -2
- snowflake/cli/api/project/errors.py +14 -0
- snowflake/cli/api/project/schemas/__init__.py +13 -0
- snowflake/cli/api/project/schemas/identifier_model.py +14 -0
- snowflake/cli/api/project/schemas/native_app/__init__.py +13 -0
- snowflake/cli/api/project/schemas/native_app/application.py +14 -0
- snowflake/cli/api/project/schemas/native_app/native_app.py +35 -0
- snowflake/cli/api/project/schemas/native_app/package.py +14 -0
- snowflake/cli/api/project/schemas/native_app/path_mapping.py +15 -1
- snowflake/cli/api/project/schemas/project_definition.py +14 -0
- snowflake/cli/api/project/schemas/snowpark/__init__.py +13 -0
- snowflake/cli/api/project/schemas/snowpark/argument.py +14 -0
- snowflake/cli/api/project/schemas/snowpark/callable.py +14 -0
- snowflake/cli/api/project/schemas/snowpark/snowpark.py +14 -0
- snowflake/cli/api/project/schemas/streamlit/__init__.py +13 -0
- snowflake/cli/api/project/schemas/streamlit/streamlit.py +14 -0
- snowflake/cli/api/project/schemas/updatable_model.py +14 -0
- snowflake/cli/api/project/util.py +32 -3
- snowflake/cli/api/secure_path.py +59 -7
- snowflake/cli/api/secure_utils.py +14 -0
- snowflake/cli/api/sql_execution.py +14 -0
- snowflake/cli/api/utils/__init__.py +13 -0
- snowflake/cli/api/utils/cursor.py +14 -0
- snowflake/cli/api/utils/definition_rendering.py +268 -0
- snowflake/cli/api/utils/dict_utils.py +73 -0
- snowflake/cli/api/utils/error_handling.py +14 -0
- snowflake/cli/api/utils/graph.py +97 -0
- snowflake/cli/api/utils/models.py +14 -0
- snowflake/cli/api/utils/naming_utils.py +13 -0
- snowflake/cli/api/utils/path_utils.py +14 -0
- snowflake/cli/api/utils/rendering.py +21 -152
- snowflake/cli/api/utils/types.py +18 -1
- snowflake/cli/app/__init__.py +14 -0
- snowflake/cli/app/__main__.py +14 -0
- snowflake/cli/app/api_impl/__init__.py +13 -0
- snowflake/cli/app/api_impl/plugin/__init__.py +13 -0
- snowflake/cli/app/api_impl/plugin/plugin_config_provider_impl.py +14 -0
- snowflake/cli/app/cli_app.py +14 -0
- snowflake/cli/app/commands_registration/__init__.py +14 -0
- snowflake/cli/app/commands_registration/builtin_plugins.py +14 -0
- snowflake/cli/app/commands_registration/command_plugins_loader.py +14 -0
- snowflake/cli/app/commands_registration/commands_registration_with_callbacks.py +14 -0
- snowflake/cli/app/commands_registration/exception_logging.py +14 -0
- snowflake/cli/app/commands_registration/threadsafe.py +14 -0
- snowflake/cli/app/commands_registration/typer_registration.py +14 -0
- snowflake/cli/app/constants.py +14 -0
- snowflake/cli/app/dev/__init__.py +13 -0
- snowflake/cli/app/dev/commands_structure.py +14 -0
- snowflake/cli/app/dev/docs/__init__.py +13 -0
- snowflake/cli/app/dev/docs/generator.py +14 -0
- snowflake/cli/app/dev/pycharm_remote_debug.py +14 -0
- snowflake/cli/app/loggers.py +14 -0
- snowflake/cli/app/main_typer.py +14 -0
- snowflake/cli/app/printing.py +14 -0
- snowflake/cli/app/snow_connector.py +14 -0
- snowflake/cli/app/telemetry.py +14 -0
- snowflake/cli/plugins/__init__.py +13 -0
- snowflake/cli/plugins/connection/__init__.py +13 -0
- snowflake/cli/plugins/connection/commands.py +27 -2
- snowflake/cli/plugins/connection/plugin_spec.py +15 -1
- snowflake/cli/plugins/connection/util.py +21 -1
- snowflake/cli/plugins/cortex/__init__.py +13 -0
- snowflake/cli/plugins/cortex/commands.py +16 -2
- snowflake/cli/plugins/cortex/constants.py +14 -0
- snowflake/cli/plugins/cortex/manager.py +14 -0
- snowflake/cli/plugins/cortex/plugin_spec.py +15 -1
- snowflake/cli/plugins/cortex/types.py +14 -0
- snowflake/cli/plugins/git/__init__.py +13 -0
- snowflake/cli/plugins/git/commands.py +16 -2
- snowflake/cli/plugins/git/manager.py +14 -0
- snowflake/cli/plugins/git/plugin_spec.py +15 -1
- snowflake/cli/plugins/nativeapp/__init__.py +13 -0
- snowflake/cli/plugins/nativeapp/artifacts.py +202 -98
- snowflake/cli/plugins/nativeapp/codegen/__init__.py +13 -0
- snowflake/cli/plugins/nativeapp/codegen/artifact_processor.py +14 -0
- snowflake/cli/plugins/nativeapp/codegen/compiler.py +14 -0
- snowflake/cli/plugins/nativeapp/codegen/sandbox.py +14 -0
- snowflake/cli/plugins/nativeapp/codegen/snowpark/callback_source.py.jinja +5 -5
- snowflake/cli/plugins/nativeapp/codegen/snowpark/extension_function_utils.py +34 -13
- snowflake/cli/plugins/nativeapp/codegen/snowpark/models.py +14 -0
- snowflake/cli/plugins/nativeapp/codegen/snowpark/python_processor.py +52 -13
- snowflake/cli/plugins/nativeapp/commands.py +63 -10
- snowflake/cli/plugins/nativeapp/common_flags.py +20 -0
- snowflake/cli/plugins/nativeapp/constants.py +15 -0
- snowflake/cli/plugins/nativeapp/exceptions.py +23 -2
- snowflake/cli/plugins/nativeapp/init.py +14 -0
- snowflake/cli/plugins/nativeapp/manager.py +118 -25
- snowflake/cli/plugins/nativeapp/plugin_spec.py +15 -1
- snowflake/cli/plugins/nativeapp/policy.py +14 -0
- snowflake/cli/plugins/nativeapp/run_processor.py +22 -3
- snowflake/cli/plugins/nativeapp/teardown_processor.py +14 -0
- snowflake/cli/plugins/nativeapp/utils.py +14 -0
- snowflake/cli/plugins/nativeapp/version/__init__.py +13 -0
- snowflake/cli/plugins/nativeapp/version/commands.py +19 -4
- snowflake/cli/plugins/nativeapp/version/version_processor.py +26 -4
- snowflake/cli/plugins/notebook/__init__.py +13 -0
- snowflake/cli/plugins/notebook/commands.py +16 -4
- snowflake/cli/plugins/notebook/exceptions.py +14 -0
- snowflake/cli/plugins/notebook/manager.py +14 -0
- snowflake/cli/plugins/notebook/plugin_spec.py +15 -1
- snowflake/cli/plugins/notebook/types.py +14 -0
- snowflake/cli/plugins/object/__init__.py +13 -11
- snowflake/cli/plugins/object/command_aliases.py +20 -6
- snowflake/cli/plugins/object/commands.py +16 -2
- snowflake/cli/plugins/object/common.py +14 -0
- snowflake/cli/plugins/object/manager.py +14 -0
- snowflake/cli/plugins/object/plugin_spec.py +16 -2
- snowflake/cli/plugins/object_stage_deprecated/__init__.py +14 -0
- snowflake/cli/plugins/object_stage_deprecated/commands.py +16 -2
- snowflake/cli/plugins/object_stage_deprecated/plugin_spec.py +16 -4
- snowflake/cli/plugins/snowpark/__init__.py +13 -4
- snowflake/cli/plugins/snowpark/commands.py +18 -2
- snowflake/cli/plugins/snowpark/common.py +15 -0
- snowflake/cli/plugins/snowpark/manager.py +14 -0
- snowflake/cli/plugins/snowpark/models.py +15 -1
- snowflake/cli/plugins/snowpark/package/__init__.py +13 -0
- snowflake/cli/plugins/snowpark/package/anaconda_packages.py +14 -0
- snowflake/cli/plugins/snowpark/package/commands.py +16 -2
- snowflake/cli/plugins/snowpark/package/manager.py +14 -0
- snowflake/cli/plugins/snowpark/package/utils.py +14 -0
- snowflake/cli/plugins/snowpark/package_utils.py +15 -1
- snowflake/cli/plugins/snowpark/plugin_spec.py +16 -2
- snowflake/cli/plugins/snowpark/snowpark_package_paths.py +14 -0
- snowflake/cli/plugins/snowpark/snowpark_shared.py +14 -0
- snowflake/cli/plugins/snowpark/zipper.py +20 -3
- snowflake/cli/plugins/spcs/__init__.py +16 -2
- snowflake/cli/plugins/spcs/common.py +14 -0
- snowflake/cli/plugins/spcs/compute_pool/__init__.py +13 -0
- snowflake/cli/plugins/spcs/compute_pool/commands.py +16 -2
- snowflake/cli/plugins/spcs/compute_pool/manager.py +14 -0
- snowflake/cli/plugins/spcs/image_registry/__init__.py +13 -0
- snowflake/cli/plugins/spcs/image_registry/commands.py +16 -2
- snowflake/cli/plugins/spcs/image_registry/manager.py +16 -0
- snowflake/cli/plugins/spcs/image_repository/__init__.py +13 -0
- snowflake/cli/plugins/spcs/image_repository/commands.py +16 -2
- snowflake/cli/plugins/spcs/image_repository/manager.py +14 -0
- snowflake/cli/plugins/spcs/jobs/__init__.py +13 -0
- snowflake/cli/plugins/spcs/jobs/commands.py +17 -3
- snowflake/cli/plugins/spcs/jobs/manager.py +14 -0
- snowflake/cli/plugins/spcs/plugin_spec.py +15 -1
- snowflake/cli/plugins/spcs/services/__init__.py +13 -0
- snowflake/cli/plugins/spcs/services/commands.py +16 -2
- snowflake/cli/plugins/spcs/services/manager.py +14 -0
- snowflake/cli/plugins/sql/__init__.py +13 -0
- snowflake/cli/plugins/sql/commands.py +16 -2
- snowflake/cli/plugins/sql/manager.py +14 -0
- snowflake/cli/plugins/sql/plugin_spec.py +15 -1
- snowflake/cli/plugins/sql/snowsql_templating.py +14 -0
- snowflake/cli/plugins/stage/__init__.py +13 -0
- snowflake/cli/plugins/stage/commands.py +17 -3
- snowflake/cli/plugins/stage/diff.py +14 -0
- snowflake/cli/plugins/stage/manager.py +16 -5
- snowflake/cli/plugins/stage/plugin_spec.py +16 -2
- snowflake/cli/plugins/streamlit/__init__.py +13 -0
- snowflake/cli/plugins/streamlit/commands.py +16 -2
- snowflake/cli/plugins/streamlit/manager.py +14 -0
- snowflake/cli/plugins/streamlit/plugin_spec.py +15 -1
- snowflake/cli/templates/default_snowpark/app/__init__.py +13 -0
- snowflake/cli/templates/default_snowpark/app/common.py +15 -0
- snowflake/cli/templates/default_snowpark/app/functions.py +14 -0
- snowflake/cli/templates/default_snowpark/app/procedures.py +14 -0
- snowflake/cli/templates/default_snowpark/snowflake.yml +1 -1
- snowflake/cli/templates/default_streamlit/common/hello.py +15 -0
- snowflake/cli/templates/default_streamlit/pages/my_page.py +14 -0
- snowflake/cli/templates/default_streamlit/snowflake.yml +1 -1
- snowflake/cli/templates/default_streamlit/streamlit_app.py +14 -0
- {snowflake_cli_labs-2.4.1.dist-info → snowflake_cli_labs-2.5.0rc1.dist-info}/METADATA +23 -7
- snowflake_cli_labs-2.5.0rc1.dist-info/RECORD +206 -0
- snowflake/cli/plugins/nativeapp/feature_flags.py +0 -10
- snowflake/cli/templates/environment.yml.jinja +0 -5
- snowflake/cli/templates/streamlit_app_launcher.py.jinja +0 -19
- snowflake_cli_labs-2.4.1.dist-info/RECORD +0 -206
- {snowflake_cli_labs-2.4.1.dist-info → snowflake_cli_labs-2.5.0rc1.dist-info}/WHEEL +0 -0
- {snowflake_cli_labs-2.4.1.dist-info → snowflake_cli_labs-2.5.0rc1.dist-info}/entry_points.txt +0 -0
- {snowflake_cli_labs-2.4.1.dist-info → snowflake_cli_labs-2.5.0rc1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,3 +1,17 @@
|
|
|
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
|
+
|
|
1
15
|
from snowflake.cli.api.plugins.command import plugin_hook_spec
|
|
2
16
|
|
|
3
17
|
|
|
@@ -1,3 +1,17 @@
|
|
|
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
|
+
|
|
1
15
|
from __future__ import annotations
|
|
2
16
|
|
|
3
17
|
from dataclasses import dataclass
|
|
@@ -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.
|
|
@@ -1,5 +1,20 @@
|
|
|
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
|
+
|
|
1
15
|
from __future__ import annotations
|
|
2
16
|
|
|
17
|
+
from dataclasses import dataclass
|
|
3
18
|
from pathlib import Path
|
|
4
19
|
from typing import List
|
|
5
20
|
|
|
@@ -14,32 +29,63 @@ from snowflake.cli.api.project.util import (
|
|
|
14
29
|
to_identifier,
|
|
15
30
|
)
|
|
16
31
|
from snowflake.cli.api.secure_path import SecurePath
|
|
32
|
+
from snowflake.cli.api.utils.definition_rendering import render_definition_template
|
|
33
|
+
from snowflake.cli.api.utils.dict_utils import deep_merge_dicts
|
|
34
|
+
from snowflake.cli.api.utils.types import Definition
|
|
17
35
|
from yaml import load
|
|
18
36
|
|
|
19
37
|
DEFAULT_USERNAME = "unknown_user"
|
|
20
38
|
|
|
21
39
|
|
|
22
|
-
|
|
40
|
+
@dataclass
|
|
41
|
+
class ProjectProperties:
|
|
23
42
|
"""
|
|
24
|
-
|
|
25
|
-
|
|
43
|
+
This class stores 2 objects representing the project definition:
|
|
44
|
+
|
|
45
|
+
The raw_project_definition object:
|
|
46
|
+
- Only contains data structures like dict, list, and scalars.
|
|
47
|
+
- The purpose of the raw_project_defintion object is to represent the same structure as the yaml project definition file.
|
|
48
|
+
- This can be used as a templating context when users reference variables in the project definition file.
|
|
49
|
+
|
|
50
|
+
The project_definition object:
|
|
51
|
+
- This is a transformed object type through Pydantic, which has been normalized.
|
|
52
|
+
- This object could have slightly different structure than what the users see in their yaml project definition files.
|
|
53
|
+
- This should be used for the business logic of snow CLI modules.
|
|
26
54
|
"""
|
|
55
|
+
|
|
56
|
+
project_definition: ProjectDefinition
|
|
57
|
+
raw_project_definition: Definition
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _get_merged_definitions(paths: List[Path]) -> Definition:
|
|
27
61
|
spaths: List[SecurePath] = [SecurePath(p) for p in paths]
|
|
28
62
|
if len(spaths) == 0:
|
|
29
63
|
raise ValueError("Need at least one definition file.")
|
|
30
64
|
|
|
31
65
|
with spaths[0].open("r", read_file_limit_mb=DEFAULT_SIZE_LIMIT_MB) as base_yml:
|
|
32
|
-
definition = load(base_yml.read(), Loader=yaml.loader.BaseLoader)
|
|
33
|
-
project = ProjectDefinition(**definition)
|
|
66
|
+
definition = load(base_yml.read(), Loader=yaml.loader.BaseLoader) or {}
|
|
34
67
|
|
|
35
68
|
for override_path in spaths[1:]:
|
|
36
69
|
with override_path.open(
|
|
37
70
|
"r", read_file_limit_mb=DEFAULT_SIZE_LIMIT_MB
|
|
38
71
|
) as override_yml:
|
|
39
|
-
overrides = load(override_yml.read(), Loader=yaml.loader.BaseLoader)
|
|
40
|
-
|
|
72
|
+
overrides = load(override_yml.read(), Loader=yaml.loader.BaseLoader) or {}
|
|
73
|
+
deep_merge_dicts(definition, overrides)
|
|
74
|
+
|
|
75
|
+
return definition
|
|
41
76
|
|
|
42
|
-
|
|
77
|
+
|
|
78
|
+
def load_project(paths: List[Path]) -> ProjectProperties:
|
|
79
|
+
"""
|
|
80
|
+
Loads project definition, optionally overriding values. Definition values
|
|
81
|
+
are merged in left-to-right order (increasing precedence).
|
|
82
|
+
Templating is also applied after the merging process.
|
|
83
|
+
"""
|
|
84
|
+
merged_definitions = _get_merged_definitions(paths)
|
|
85
|
+
rendered_definition = render_definition_template(merged_definitions)
|
|
86
|
+
return ProjectProperties(
|
|
87
|
+
ProjectDefinition(**rendered_definition), rendered_definition
|
|
88
|
+
)
|
|
43
89
|
|
|
44
90
|
|
|
45
91
|
def generate_local_override_yml(
|
|
@@ -1,3 +1,17 @@
|
|
|
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
|
+
|
|
1
15
|
from __future__ import annotations
|
|
2
16
|
|
|
3
17
|
import functools
|
|
@@ -6,8 +20,10 @@ from pathlib import Path
|
|
|
6
20
|
from typing import List, Optional
|
|
7
21
|
|
|
8
22
|
from snowflake.cli.api.exceptions import MissingConfiguration
|
|
9
|
-
from snowflake.cli.api.project.definition import
|
|
23
|
+
from snowflake.cli.api.project.definition import ProjectProperties, load_project
|
|
10
24
|
from snowflake.cli.api.project.schemas.project_definition import ProjectDefinition
|
|
25
|
+
from snowflake.cli.api.utils.rendering import CONTEXT_KEY
|
|
26
|
+
from snowflake.cli.api.utils.types import Context
|
|
11
27
|
|
|
12
28
|
|
|
13
29
|
def _compat_is_mount(path: Path):
|
|
@@ -100,6 +116,16 @@ class DefinitionManager:
|
|
|
100
116
|
DefinitionManager.USER_DEFINITION_FILENAME, project_path
|
|
101
117
|
)
|
|
102
118
|
|
|
119
|
+
@functools.cached_property
|
|
120
|
+
def _project_properties(self) -> ProjectProperties:
|
|
121
|
+
return load_project(self._project_config_paths)
|
|
122
|
+
|
|
103
123
|
@functools.cached_property
|
|
104
124
|
def project_definition(self) -> ProjectDefinition:
|
|
105
|
-
return
|
|
125
|
+
return self._project_properties.project_definition
|
|
126
|
+
|
|
127
|
+
@functools.cached_property
|
|
128
|
+
def template_context(self) -> Context:
|
|
129
|
+
definition = self._project_properties.raw_project_definition
|
|
130
|
+
|
|
131
|
+
return {CONTEXT_KEY: definition}
|
|
@@ -1,3 +1,17 @@
|
|
|
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
|
+
|
|
1
15
|
from textwrap import dedent
|
|
2
16
|
|
|
3
17
|
from pydantic import ValidationError
|
|
@@ -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.
|
|
@@ -1,3 +1,17 @@
|
|
|
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
|
+
|
|
1
15
|
from __future__ import annotations
|
|
2
16
|
|
|
3
17
|
from typing import Optional, cast
|
|
@@ -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.
|
|
@@ -1,3 +1,17 @@
|
|
|
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
|
+
|
|
1
15
|
from __future__ import annotations
|
|
2
16
|
|
|
3
17
|
from typing import Optional
|
|
@@ -1,3 +1,17 @@
|
|
|
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
|
+
|
|
1
15
|
from __future__ import annotations
|
|
2
16
|
|
|
3
17
|
import re
|
|
@@ -32,6 +46,10 @@ class NativeApp(UpdatableModel):
|
|
|
32
46
|
title="Identifier of the stage that stores the application artifacts.",
|
|
33
47
|
default="app_src.stage",
|
|
34
48
|
)
|
|
49
|
+
scratch_stage: Optional[str] = Field(
|
|
50
|
+
title="Identifier of the stage that stores temporary scratch data used by the Snowflake CLI.",
|
|
51
|
+
default="app_src.stage_snowflake_cli_scratch",
|
|
52
|
+
)
|
|
35
53
|
package: Optional[Package] = Field(title="PackageSchema", default=None)
|
|
36
54
|
application: Optional[Application] = Field(title="Application info", default=None)
|
|
37
55
|
|
|
@@ -41,3 +59,20 @@ class NativeApp(UpdatableModel):
|
|
|
41
59
|
if not re.match(SCHEMA_AND_NAME, input_value):
|
|
42
60
|
raise ValueError("Incorrect value for source_stage value of native_app")
|
|
43
61
|
return input_value
|
|
62
|
+
|
|
63
|
+
@field_validator("artifacts")
|
|
64
|
+
@classmethod
|
|
65
|
+
def transform_artifacts(
|
|
66
|
+
cls, orig_artifacts: List[Union[PathMapping, str]]
|
|
67
|
+
) -> List[PathMapping]:
|
|
68
|
+
transformed_artifacts = []
|
|
69
|
+
if orig_artifacts is None:
|
|
70
|
+
return transformed_artifacts
|
|
71
|
+
|
|
72
|
+
for artifact in orig_artifacts:
|
|
73
|
+
if isinstance(artifact, PathMapping):
|
|
74
|
+
transformed_artifacts.append(artifact)
|
|
75
|
+
else:
|
|
76
|
+
transformed_artifacts.append(PathMapping(src=artifact))
|
|
77
|
+
|
|
78
|
+
return transformed_artifacts
|
|
@@ -1,3 +1,17 @@
|
|
|
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
|
+
|
|
1
15
|
from __future__ import annotations
|
|
2
16
|
|
|
3
17
|
from typing import List, Literal, Optional
|
|
@@ -1,3 +1,17 @@
|
|
|
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
|
+
|
|
1
15
|
from __future__ import annotations
|
|
2
16
|
|
|
3
17
|
from typing import Any, Dict, List, Optional, Union
|
|
@@ -25,7 +39,7 @@ class PathMapping(UpdatableModel):
|
|
|
25
39
|
@classmethod
|
|
26
40
|
def transform_processors(
|
|
27
41
|
cls, input_values: Optional[List[Union[str, Dict, ProcessorMapping]]]
|
|
28
|
-
):
|
|
42
|
+
) -> List[ProcessorMapping]:
|
|
29
43
|
if input_values is None:
|
|
30
44
|
return []
|
|
31
45
|
|
|
@@ -1,3 +1,17 @@
|
|
|
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
|
+
|
|
1
15
|
from __future__ import annotations
|
|
2
16
|
|
|
3
17
|
from typing import Any, Dict, Optional, Union
|
|
@@ -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.
|
|
@@ -1,3 +1,17 @@
|
|
|
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
|
+
|
|
1
15
|
from __future__ import annotations
|
|
2
16
|
|
|
3
17
|
from typing import Optional
|
|
@@ -1,3 +1,17 @@
|
|
|
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
|
+
|
|
1
15
|
from __future__ import annotations
|
|
2
16
|
|
|
3
17
|
from typing import Dict, List, Optional, Union
|
|
@@ -1,3 +1,17 @@
|
|
|
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
|
+
|
|
1
15
|
from __future__ import annotations
|
|
2
16
|
|
|
3
17
|
from typing import List, Optional
|
|
@@ -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.
|
|
@@ -1,3 +1,17 @@
|
|
|
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
|
+
|
|
1
15
|
from __future__ import annotations
|
|
2
16
|
|
|
3
17
|
from typing import List, Optional
|
|
@@ -1,3 +1,17 @@
|
|
|
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
|
+
|
|
1
15
|
from __future__ import annotations
|
|
2
16
|
|
|
3
17
|
from typing import Any, Dict
|
|
@@ -1,9 +1,24 @@
|
|
|
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
|
+
|
|
1
15
|
from __future__ import annotations
|
|
2
16
|
|
|
3
17
|
import codecs
|
|
4
18
|
import os
|
|
5
19
|
import re
|
|
6
20
|
from typing import Optional
|
|
21
|
+
from urllib.parse import quote
|
|
7
22
|
|
|
8
23
|
IDENTIFIER = r'((?:"[^"]*(?:""[^"]*)*")|(?:[A-Za-z_][\w$]{0,254}))'
|
|
9
24
|
IDENTIFIER_NO_LENGTH = r'((?:"[^"]*(?:""[^"]*)*")|(?:[A-Za-z_][\w$]*))'
|
|
@@ -20,6 +35,13 @@ QUOTED_IDENTIFIER_REGEX = r'"((""|[^"]){0,255})"'
|
|
|
20
35
|
VALID_IDENTIFIER_REGEX = f"(?:{UNQUOTED_IDENTIFIER_REGEX}|{QUOTED_IDENTIFIER_REGEX})"
|
|
21
36
|
|
|
22
37
|
|
|
38
|
+
def encode_uri_component(s: str) -> str:
|
|
39
|
+
"""
|
|
40
|
+
Implementation of JavaScript's encodeURIComponent.
|
|
41
|
+
"""
|
|
42
|
+
return quote(s, safe="!~*'()")
|
|
43
|
+
|
|
44
|
+
|
|
23
45
|
def clean_identifier(input_: str):
|
|
24
46
|
"""
|
|
25
47
|
Removes characters that cannot be used in an unquoted identifier,
|
|
@@ -92,9 +114,9 @@ def append_to_identifier(identifier: str, suffix: str) -> str:
|
|
|
92
114
|
|
|
93
115
|
def unquote_identifier(identifier: str) -> str:
|
|
94
116
|
"""
|
|
95
|
-
Returns a version of this identifier that can be used inside of a
|
|
96
|
-
|
|
97
|
-
|
|
117
|
+
Returns a version of this identifier that can be used inside of a
|
|
118
|
+
string for a LIKE clause, or to match an identifier passed back as
|
|
119
|
+
a value from a SQL statement.
|
|
98
120
|
"""
|
|
99
121
|
if match := re.fullmatch(QUOTED_IDENTIFIER_REGEX, identifier):
|
|
100
122
|
return match.group(1).replace('""', '"')
|
|
@@ -102,6 +124,13 @@ def unquote_identifier(identifier: str) -> str:
|
|
|
102
124
|
return identifier.upper()
|
|
103
125
|
|
|
104
126
|
|
|
127
|
+
def identifier_for_url(identifier: str) -> str:
|
|
128
|
+
"""
|
|
129
|
+
Returns a version of this identifier that can be used as part of a URL.
|
|
130
|
+
"""
|
|
131
|
+
return encode_uri_component(unquote_identifier(identifier))
|
|
132
|
+
|
|
133
|
+
|
|
105
134
|
def is_valid_string_literal(literal: str) -> bool:
|
|
106
135
|
"""
|
|
107
136
|
Determines if a literal is a valid single quoted string literal
|