snowflake-cli-labs 2.8.1__py3-none-any.whl → 2.8.2__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-2.8.1.dist-info → snowflake_cli_labs-2.8.2.dist-info}/METADATA +7 -95
- snowflake_cli_labs-2.8.2.dist-info/RECORD +5 -0
- snowflake/cli/__about__.py +0 -17
- snowflake/cli/__init__.py +0 -13
- snowflake/cli/api/__init__.py +0 -48
- snowflake/cli/api/cli_global_context.py +0 -390
- snowflake/cli/api/commands/__init__.py +0 -13
- snowflake/cli/api/commands/alias.py +0 -23
- snowflake/cli/api/commands/decorators.py +0 -354
- snowflake/cli/api/commands/execution_metadata.py +0 -40
- snowflake/cli/api/commands/experimental_behaviour.py +0 -19
- snowflake/cli/api/commands/flags.py +0 -662
- snowflake/cli/api/commands/project_initialisation.py +0 -65
- snowflake/cli/api/commands/snow_typer.py +0 -237
- snowflake/cli/api/commands/typer_pre_execute.py +0 -26
- snowflake/cli/api/config.py +0 -348
- snowflake/cli/api/console/__init__.py +0 -17
- snowflake/cli/api/console/abc.py +0 -89
- snowflake/cli/api/console/console.py +0 -134
- snowflake/cli/api/console/enum.py +0 -17
- snowflake/cli/api/constants.py +0 -79
- snowflake/cli/api/errno.py +0 -27
- snowflake/cli/api/exceptions.py +0 -164
- snowflake/cli/api/feature_flags.py +0 -55
- snowflake/cli/api/identifiers.py +0 -167
- 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 -84
- snowflake/cli/api/project/definition_manager.py +0 -134
- 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/application_entity.py +0 -44
- snowflake/cli/api/project/schemas/entities/application_package_entity.py +0 -66
- snowflake/cli/api/project/schemas/entities/common.py +0 -78
- snowflake/cli/api/project/schemas/entities/entities.py +0 -30
- snowflake/cli/api/project/schemas/identifier_model.py +0 -49
- snowflake/cli/api/project/schemas/native_app/__init__.py +0 -13
- snowflake/cli/api/project/schemas/native_app/application.py +0 -62
- snowflake/cli/api/project/schemas/native_app/native_app.py +0 -93
- snowflake/cli/api/project/schemas/native_app/package.py +0 -78
- snowflake/cli/api/project/schemas/native_app/path_mapping.py +0 -65
- snowflake/cli/api/project/schemas/project_definition.py +0 -199
- snowflake/cli/api/project/schemas/snowpark/__init__.py +0 -13
- snowflake/cli/api/project/schemas/snowpark/argument.py +0 -28
- snowflake/cli/api/project/schemas/snowpark/callable.py +0 -69
- snowflake/cli/api/project/schemas/snowpark/snowpark.py +0 -36
- snowflake/cli/api/project/schemas/streamlit/__init__.py +0 -13
- snowflake/cli/api/project/schemas/streamlit/streamlit.py +0 -46
- snowflake/cli/api/project/schemas/template.py +0 -77
- snowflake/cli/api/project/schemas/updatable_model.py +0 -194
- snowflake/cli/api/project/util.py +0 -261
- snowflake/cli/api/rendering/__init__.py +0 -13
- snowflake/cli/api/rendering/jinja.py +0 -112
- snowflake/cli/api/rendering/project_definition_templates.py +0 -39
- snowflake/cli/api/rendering/project_templates.py +0 -98
- snowflake/cli/api/rendering/sql_templates.py +0 -60
- snowflake/cli/api/rest_api.py +0 -172
- snowflake/cli/api/sanitizers.py +0 -43
- snowflake/cli/api/secure_path.py +0 -362
- snowflake/cli/api/secure_utils.py +0 -29
- snowflake/cli/api/sql_execution.py +0 -260
- snowflake/cli/api/utils/__init__.py +0 -13
- snowflake/cli/api/utils/cursor.py +0 -34
- snowflake/cli/api/utils/definition_rendering.py +0 -383
- 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/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/build_and_push.sh +0 -8
- snowflake/cli/app/cli_app.py +0 -243
- snowflake/cli/app/commands_registration/__init__.py +0 -33
- snowflake/cli/app/commands_registration/builtin_plugins.py +0 -54
- 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 -100
- 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 -57
- 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/snow_connector.py +0 -243
- snowflake/cli/app/telemetry.py +0 -189
- snowflake/cli/plugins/__init__.py +0 -13
- snowflake/cli/plugins/connection/__init__.py +0 -13
- snowflake/cli/plugins/connection/commands.py +0 -330
- snowflake/cli/plugins/connection/plugin_spec.py +0 -30
- snowflake/cli/plugins/connection/util.py +0 -179
- snowflake/cli/plugins/cortex/__init__.py +0 -13
- snowflake/cli/plugins/cortex/commands.py +0 -327
- 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 -354
- snowflake/cli/plugins/git/manager.py +0 -105
- snowflake/cli/plugins/git/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 -742
- 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 -130
- snowflake/cli/plugins/nativeapp/codegen/sandbox.py +0 -306
- snowflake/cli/plugins/nativeapp/codegen/setup/native_app_setup_processor.py +0 -172
- snowflake/cli/plugins/nativeapp/codegen/setup/setup_driver.py.source +0 -56
- 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 -528
- snowflake/cli/plugins/nativeapp/commands.py +0 -439
- snowflake/cli/plugins/nativeapp/common_flags.py +0 -44
- snowflake/cli/plugins/nativeapp/constants.py +0 -27
- snowflake/cli/plugins/nativeapp/exceptions.py +0 -122
- snowflake/cli/plugins/nativeapp/feature_flags.py +0 -24
- snowflake/cli/plugins/nativeapp/init.py +0 -345
- snowflake/cli/plugins/nativeapp/manager.py +0 -823
- snowflake/cli/plugins/nativeapp/plugin_spec.py +0 -30
- snowflake/cli/plugins/nativeapp/policy.py +0 -50
- snowflake/cli/plugins/nativeapp/project_model.py +0 -195
- snowflake/cli/plugins/nativeapp/run_processor.py +0 -389
- snowflake/cli/plugins/nativeapp/teardown_processor.py +0 -301
- snowflake/cli/plugins/nativeapp/utils.py +0 -98
- snowflake/cli/plugins/nativeapp/v2_conversions/v2_to_v1_decorator.py +0 -135
- snowflake/cli/plugins/nativeapp/version/__init__.py +0 -13
- snowflake/cli/plugins/nativeapp/version/commands.py +0 -170
- snowflake/cli/plugins/nativeapp/version/version_processor.py +0 -362
- snowflake/cli/plugins/notebook/__init__.py +0 -13
- snowflake/cli/plugins/notebook/commands.py +0 -85
- 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 -181
- snowflake/cli/plugins/object/common.py +0 -85
- snowflake/cli/plugins/object/manager.py +0 -97
- snowflake/cli/plugins/object/plugin_spec.py +0 -30
- snowflake/cli/plugins/object_stage_deprecated/__init__.py +0 -15
- snowflake/cli/plugins/object_stage_deprecated/commands.py +0 -122
- snowflake/cli/plugins/object_stage_deprecated/plugin_spec.py +0 -32
- snowflake/cli/plugins/snowpark/__init__.py +0 -13
- snowflake/cli/plugins/snowpark/commands.py +0 -546
- snowflake/cli/plugins/snowpark/common.py +0 -307
- snowflake/cli/plugins/snowpark/manager.py +0 -109
- snowflake/cli/plugins/snowpark/models.py +0 -157
- snowflake/cli/plugins/snowpark/package/__init__.py +0 -13
- snowflake/cli/plugins/snowpark/package/anaconda_packages.py +0 -233
- snowflake/cli/plugins/snowpark/package/commands.py +0 -256
- 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_package_paths.py +0 -65
- snowflake/cli/plugins/snowpark/snowpark_shared.py +0 -95
- snowflake/cli/plugins/snowpark/zipper.py +0 -81
- snowflake/cli/plugins/spcs/__init__.py +0 -35
- 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/jobs/__init__.py +0 -13
- snowflake/cli/plugins/spcs/jobs/commands.py +0 -78
- snowflake/cli/plugins/spcs/jobs/manager.py +0 -53
- 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 -312
- snowflake/cli/plugins/spcs/services/manager.py +0 -170
- snowflake/cli/plugins/sql/__init__.py +0 -13
- snowflake/cli/plugins/sql/commands.py +0 -83
- 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 -263
- snowflake/cli/plugins/stage/diff.py +0 -326
- snowflake/cli/plugins/stage/manager.py +0 -577
- snowflake/cli/plugins/stage/md5.py +0 -160
- snowflake/cli/plugins/stage/plugin_spec.py +0 -30
- snowflake/cli/plugins/streamlit/__init__.py +0 -13
- snowflake/cli/plugins/streamlit/commands.py +0 -179
- snowflake/cli/plugins/streamlit/manager.py +0 -222
- snowflake/cli/plugins/streamlit/plugin_spec.py +0 -30
- snowflake/cli/plugins/workspace/__init__.py +0 -13
- snowflake/cli/plugins/workspace/commands.py +0 -35
- snowflake/cli/plugins/workspace/plugin_spec.py +0 -30
- snowflake/cli/templates/default_snowpark/.gitignore +0 -4
- snowflake/cli/templates/default_snowpark/app/__init__.py +0 -0
- snowflake/cli/templates/default_snowpark/app/common.py +0 -2
- snowflake/cli/templates/default_snowpark/app/functions.py +0 -15
- snowflake/cli/templates/default_snowpark/app/procedures.py +0 -22
- snowflake/cli/templates/default_snowpark/requirements.txt +0 -1
- snowflake/cli/templates/default_snowpark/snowflake.yml +0 -23
- snowflake/cli/templates/default_streamlit/.gitignore +0 -4
- snowflake/cli/templates/default_streamlit/common/hello.py +0 -2
- snowflake/cli/templates/default_streamlit/environment.yml +0 -6
- snowflake/cli/templates/default_streamlit/pages/my_page.py +0 -3
- snowflake/cli/templates/default_streamlit/snowflake.yml +0 -10
- snowflake/cli/templates/default_streamlit/streamlit_app.py +0 -4
- snowflake_cli_labs-2.8.1.dist-info/RECORD +0 -240
- snowflake_cli_labs-2.8.1.dist-info/entry_points.txt +0 -2
- {snowflake_cli_labs-2.8.1.dist-info → snowflake_cli_labs-2.8.2.dist-info}/WHEEL +0 -0
- {snowflake_cli_labs-2.8.1.dist-info → snowflake_cli_labs-2.8.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -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
|
-
|
|
15
|
-
from snowflake.cli.api.cli_global_context import cli_context
|
|
16
|
-
from snowflake.cli.api.exceptions import NoProjectDefinitionError
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def assert_project_type(project_type: str):
|
|
20
|
-
if not getattr(cli_context.project_definition, project_type, None):
|
|
21
|
-
raise NoProjectDefinitionError(
|
|
22
|
-
project_type=project_type, project_file=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,44 +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 Literal, Optional
|
|
18
|
-
|
|
19
|
-
from pydantic import Field
|
|
20
|
-
from snowflake.cli.api.project.schemas.entities.application_package_entity import (
|
|
21
|
-
ApplicationPackageEntity,
|
|
22
|
-
)
|
|
23
|
-
from snowflake.cli.api.project.schemas.entities.common import (
|
|
24
|
-
EntityBase,
|
|
25
|
-
TargetField,
|
|
26
|
-
)
|
|
27
|
-
from snowflake.cli.api.project.schemas.updatable_model import (
|
|
28
|
-
DiscriminatorField,
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class ApplicationEntity(EntityBase):
|
|
33
|
-
type: Literal["application"] = DiscriminatorField() # noqa A003
|
|
34
|
-
name: str = Field(
|
|
35
|
-
title="Name of the application created when this entity is deployed"
|
|
36
|
-
)
|
|
37
|
-
from_: TargetField[ApplicationPackageEntity] = Field(
|
|
38
|
-
alias="from",
|
|
39
|
-
title="An application package this entity should be created from",
|
|
40
|
-
)
|
|
41
|
-
debug: Optional[bool] = Field(
|
|
42
|
-
title="Whether to enable debug mode when using a named stage to create an application object",
|
|
43
|
-
default=None,
|
|
44
|
-
)
|
|
@@ -1,66 +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 pathlib import Path
|
|
18
|
-
from typing import List, Literal, Optional, Union
|
|
19
|
-
|
|
20
|
-
from pydantic import Field
|
|
21
|
-
from snowflake.cli.api.project.schemas.entities.common import (
|
|
22
|
-
EntityBase,
|
|
23
|
-
)
|
|
24
|
-
from snowflake.cli.api.project.schemas.native_app.package import DistributionOptions
|
|
25
|
-
from snowflake.cli.api.project.schemas.native_app.path_mapping import PathMapping
|
|
26
|
-
from snowflake.cli.api.project.schemas.updatable_model import (
|
|
27
|
-
DiscriminatorField,
|
|
28
|
-
IdentifierField,
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class ApplicationPackageEntity(EntityBase):
|
|
33
|
-
type: Literal["application package"] = DiscriminatorField() # noqa: A003
|
|
34
|
-
name: str = Field(
|
|
35
|
-
title="Name of the application package created when this entity is deployed"
|
|
36
|
-
)
|
|
37
|
-
artifacts: List[Union[PathMapping, Path]] = Field(
|
|
38
|
-
title="List of paths or file source/destination pairs to add to the deploy root",
|
|
39
|
-
)
|
|
40
|
-
bundle_root: Optional[Path] = Field(
|
|
41
|
-
title="Folder at the root of your project where artifacts necessary to perform the bundle step are stored.",
|
|
42
|
-
default=Path("output/bundle/"),
|
|
43
|
-
)
|
|
44
|
-
deploy_root: Optional[Path] = Field(
|
|
45
|
-
title="Folder at the root of your project where the build step copies the artifacts",
|
|
46
|
-
default=Path("output/deploy/"),
|
|
47
|
-
)
|
|
48
|
-
generated_root: Optional[Path] = Field(
|
|
49
|
-
title="Subdirectory of the deploy root where files generated by the Snowflake CLI will be written.",
|
|
50
|
-
default=Path("__generated/"),
|
|
51
|
-
)
|
|
52
|
-
stage: Optional[str] = IdentifierField(
|
|
53
|
-
title="Identifier of the stage that stores the application artifacts.",
|
|
54
|
-
default="app_src.stage",
|
|
55
|
-
)
|
|
56
|
-
scratch_stage: Optional[str] = IdentifierField(
|
|
57
|
-
title="Identifier of the stage that stores temporary scratch data used by the Snowflake CLI.",
|
|
58
|
-
default="app_src.stage_snowflake_cli_scratch",
|
|
59
|
-
)
|
|
60
|
-
distribution: Optional[DistributionOptions] = Field(
|
|
61
|
-
title="Distribution of the application package created by the Snowflake CLI",
|
|
62
|
-
default="internal",
|
|
63
|
-
)
|
|
64
|
-
manifest: Path = Field(
|
|
65
|
-
title="Path to manifest.yml",
|
|
66
|
-
)
|
|
@@ -1,78 +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 Generic, List, Optional, TypeVar
|
|
19
|
-
|
|
20
|
-
from pydantic import Field
|
|
21
|
-
from snowflake.cli.api.project.schemas.native_app.application import (
|
|
22
|
-
PostDeployHook,
|
|
23
|
-
)
|
|
24
|
-
from snowflake.cli.api.project.schemas.updatable_model import (
|
|
25
|
-
IdentifierField,
|
|
26
|
-
UpdatableModel,
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
class MetaField(UpdatableModel):
|
|
31
|
-
warehouse: Optional[str] = IdentifierField(
|
|
32
|
-
title="Warehouse used to run the scripts", default=None
|
|
33
|
-
)
|
|
34
|
-
role: Optional[str] = IdentifierField(
|
|
35
|
-
title="Role to use when creating the entity object",
|
|
36
|
-
default=None,
|
|
37
|
-
)
|
|
38
|
-
post_deploy: Optional[List[PostDeployHook]] = Field(
|
|
39
|
-
title="Actions that will be executed after the application object is created/upgraded",
|
|
40
|
-
default=None,
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
class DefaultsField(UpdatableModel):
|
|
45
|
-
schema_: Optional[str] = Field(
|
|
46
|
-
title="Schema.",
|
|
47
|
-
alias="schema",
|
|
48
|
-
default=None,
|
|
49
|
-
)
|
|
50
|
-
stage: Optional[str] = Field(
|
|
51
|
-
title="Stage.",
|
|
52
|
-
default=None,
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
class EntityBase(ABC, UpdatableModel):
|
|
57
|
-
@classmethod
|
|
58
|
-
def get_type(cls) -> str:
|
|
59
|
-
return cls.model_fields["type"].annotation.__args__[0]
|
|
60
|
-
|
|
61
|
-
meta: Optional[MetaField] = Field(title="Meta fields", default=None)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
TargetType = TypeVar("TargetType")
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
class TargetField(UpdatableModel, Generic[TargetType]):
|
|
68
|
-
target: str = Field(
|
|
69
|
-
title="Reference to a target entity",
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
def get_type(self) -> type:
|
|
73
|
-
"""
|
|
74
|
-
Returns the generic type of this class, indicating the entity type.
|
|
75
|
-
Pydantic extracts Generic annotations, and populates
|
|
76
|
-
them in __pydantic_generic_metadata__
|
|
77
|
-
"""
|
|
78
|
-
return self.__pydantic_generic_metadata__["args"][0]
|
|
@@ -1,30 +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 Union, get_args
|
|
18
|
-
|
|
19
|
-
from snowflake.cli.api.project.schemas.entities.application_entity import (
|
|
20
|
-
ApplicationEntity,
|
|
21
|
-
)
|
|
22
|
-
from snowflake.cli.api.project.schemas.entities.application_package_entity import (
|
|
23
|
-
ApplicationPackageEntity,
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
Entity = Union[ApplicationEntity, ApplicationPackageEntity]
|
|
27
|
-
|
|
28
|
-
ALL_ENTITIES = [*get_args(Entity)]
|
|
29
|
-
|
|
30
|
-
v2_entity_types_map = {e.get_type(): e for e in ALL_ENTITIES}
|
|
@@ -1,49 +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 Optional, cast
|
|
18
|
-
|
|
19
|
-
from pydantic import Field
|
|
20
|
-
from snowflake.cli.api.project.schemas.updatable_model import IdentifierField
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class ObjectIdentifierBaseModel:
|
|
24
|
-
"""
|
|
25
|
-
Type representing a base class defining object that can be identified by fully qualified name (db.schema.name).
|
|
26
|
-
This is not a Pydantic model and the purpose of this class is to provide typing support to Pydantic models
|
|
27
|
-
generated using a factory class ObjectIdentifierModel.
|
|
28
|
-
"""
|
|
29
|
-
|
|
30
|
-
name: str
|
|
31
|
-
database: Optional[str]
|
|
32
|
-
schema_name: Optional[str]
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def ObjectIdentifierModel(object_name: str) -> ObjectIdentifierBaseModel: # noqa: N802
|
|
36
|
-
"""Generates ObjectIdentifierBaseModel but with object specific descriptions."""
|
|
37
|
-
|
|
38
|
-
class _ObjectIdentifierModel(ObjectIdentifierBaseModel):
|
|
39
|
-
name: str = Field(title=f"{object_name.capitalize()} name")
|
|
40
|
-
database: Optional[str] = IdentifierField(
|
|
41
|
-
title=f"Name of the database for the {object_name}", default=None
|
|
42
|
-
)
|
|
43
|
-
schema_name: Optional[str] = IdentifierField(
|
|
44
|
-
title=f"Name of the schema for the {object_name}",
|
|
45
|
-
default=None,
|
|
46
|
-
alias="schema",
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
return cast(ObjectIdentifierBaseModel, _ObjectIdentifierModel)
|
|
@@ -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,62 +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 List, Optional
|
|
18
|
-
|
|
19
|
-
from pydantic import Field
|
|
20
|
-
from snowflake.cli.api.project.schemas.updatable_model import (
|
|
21
|
-
IdentifierField,
|
|
22
|
-
UpdatableModel,
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class SqlScriptHookType(UpdatableModel):
|
|
27
|
-
sql_script: str = Field(title="SQL file path relative to the project root")
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# Currently sql_script is the only supported hook type. Change to a Union once other hook types are added
|
|
31
|
-
PostDeployHook = SqlScriptHookType
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class Application(UpdatableModel):
|
|
35
|
-
role: Optional[str] = Field(
|
|
36
|
-
title="Role to use when creating the application object and consumer-side objects",
|
|
37
|
-
default=None,
|
|
38
|
-
)
|
|
39
|
-
name: Optional[str] = Field(
|
|
40
|
-
title="Name of the application object created when you run the snow app run command",
|
|
41
|
-
default=None,
|
|
42
|
-
)
|
|
43
|
-
warehouse: Optional[str] = IdentifierField(
|
|
44
|
-
title="Name of the application object created when you run the snow app run command",
|
|
45
|
-
default=None,
|
|
46
|
-
)
|
|
47
|
-
debug: Optional[bool] = Field(
|
|
48
|
-
title="When set, forces debug_mode on/off for the deployed application object",
|
|
49
|
-
default=None,
|
|
50
|
-
)
|
|
51
|
-
post_deploy: Optional[List[PostDeployHook]] = Field(
|
|
52
|
-
title="Actions that will be executed after the application object is created/upgraded",
|
|
53
|
-
default=None,
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
class ApplicationV11(Application):
|
|
58
|
-
# Templated defaults only supported in v1.1+
|
|
59
|
-
name: Optional[str] = Field(
|
|
60
|
-
title="Name of the application object created when you run the snow app run command",
|
|
61
|
-
default="<% fn.concat_ids(ctx.native_app.name, '_', fn.sanitize_id(fn.get_username('unknown_user')) | lower) %>",
|
|
62
|
-
)
|
|
@@ -1,93 +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 re
|
|
18
|
-
from typing import List, Optional, Union
|
|
19
|
-
|
|
20
|
-
from pydantic import Field, field_validator
|
|
21
|
-
from snowflake.cli.api.project.schemas.native_app.application import (
|
|
22
|
-
Application,
|
|
23
|
-
ApplicationV11,
|
|
24
|
-
)
|
|
25
|
-
from snowflake.cli.api.project.schemas.native_app.package import Package, PackageV11
|
|
26
|
-
from snowflake.cli.api.project.schemas.native_app.path_mapping import PathMapping
|
|
27
|
-
from snowflake.cli.api.project.schemas.updatable_model import UpdatableModel
|
|
28
|
-
from snowflake.cli.api.project.util import (
|
|
29
|
-
SCHEMA_AND_NAME,
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class NativeApp(UpdatableModel):
|
|
34
|
-
name: str = Field(
|
|
35
|
-
title="Project identifier",
|
|
36
|
-
)
|
|
37
|
-
artifacts: List[Union[PathMapping, str]] = Field(
|
|
38
|
-
title="List of file source and destination pairs to add to the deploy root",
|
|
39
|
-
)
|
|
40
|
-
bundle_root: Optional[str] = Field(
|
|
41
|
-
title="Folder at the root of your project where artifacts necessary to perform the bundle step are stored.",
|
|
42
|
-
default="output/bundle/",
|
|
43
|
-
)
|
|
44
|
-
deploy_root: Optional[str] = Field(
|
|
45
|
-
title="Folder at the root of your project where the bundle step copies the artifacts.",
|
|
46
|
-
default="output/deploy/",
|
|
47
|
-
)
|
|
48
|
-
generated_root: Optional[str] = Field(
|
|
49
|
-
title="Subdirectory of the deploy root where files generated by the Snowflake CLI will be written.",
|
|
50
|
-
default="__generated/",
|
|
51
|
-
)
|
|
52
|
-
source_stage: Optional[str] = Field(
|
|
53
|
-
title="Identifier of the stage that stores the application artifacts.",
|
|
54
|
-
default="app_src.stage",
|
|
55
|
-
)
|
|
56
|
-
scratch_stage: Optional[str] = Field(
|
|
57
|
-
title="Identifier of the stage that stores temporary scratch data used by the Snowflake CLI.",
|
|
58
|
-
default="app_src.stage_snowflake_cli_scratch",
|
|
59
|
-
)
|
|
60
|
-
package: Optional[Package] = Field(title="PackageSchema", default=None)
|
|
61
|
-
application: Optional[Application] = Field(title="Application info", default=None)
|
|
62
|
-
|
|
63
|
-
@field_validator("source_stage")
|
|
64
|
-
@classmethod
|
|
65
|
-
def validate_source_stage(cls, input_value: str):
|
|
66
|
-
if not re.match(SCHEMA_AND_NAME, input_value):
|
|
67
|
-
raise ValueError("Incorrect value for source_stage value of native_app")
|
|
68
|
-
return input_value
|
|
69
|
-
|
|
70
|
-
@field_validator("artifacts")
|
|
71
|
-
@classmethod
|
|
72
|
-
def transform_artifacts(
|
|
73
|
-
cls, orig_artifacts: List[Union[PathMapping, str]]
|
|
74
|
-
) -> List[PathMapping]:
|
|
75
|
-
transformed_artifacts = []
|
|
76
|
-
if orig_artifacts is None:
|
|
77
|
-
return transformed_artifacts
|
|
78
|
-
|
|
79
|
-
for artifact in orig_artifacts:
|
|
80
|
-
if isinstance(artifact, PathMapping):
|
|
81
|
-
transformed_artifacts.append(artifact)
|
|
82
|
-
else:
|
|
83
|
-
transformed_artifacts.append(PathMapping(src=artifact))
|
|
84
|
-
|
|
85
|
-
return transformed_artifacts
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
class NativeAppV11(NativeApp):
|
|
89
|
-
# templated defaults are only supported with version 1.1+
|
|
90
|
-
package: Optional[PackageV11] = Field(title="PackageSchema", default=PackageV11())
|
|
91
|
-
application: Optional[ApplicationV11] = Field(
|
|
92
|
-
title="Application info", default=ApplicationV11()
|
|
93
|
-
)
|
|
@@ -1,78 +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 List, Literal, Optional
|
|
18
|
-
|
|
19
|
-
from pydantic import Field, field_validator, model_validator
|
|
20
|
-
from snowflake.cli.api.project.schemas.native_app.application import PostDeployHook
|
|
21
|
-
from snowflake.cli.api.project.schemas.updatable_model import (
|
|
22
|
-
IdentifierField,
|
|
23
|
-
UpdatableModel,
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
DistributionOptions = Literal["internal", "external", "INTERNAL", "EXTERNAL"]
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
class Package(UpdatableModel):
|
|
30
|
-
scripts: Optional[List[str]] = Field(
|
|
31
|
-
title="List of SQL file paths relative to the project root", default=None
|
|
32
|
-
)
|
|
33
|
-
role: Optional[str] = IdentifierField(
|
|
34
|
-
title="Role to use when creating the application package and provider-side objects",
|
|
35
|
-
default=None,
|
|
36
|
-
)
|
|
37
|
-
name: Optional[str] = IdentifierField(
|
|
38
|
-
title="Name of the application package created when you run the snow app run command",
|
|
39
|
-
default=None,
|
|
40
|
-
)
|
|
41
|
-
warehouse: Optional[str] = IdentifierField(
|
|
42
|
-
title="Warehouse used to run the scripts", default=None
|
|
43
|
-
)
|
|
44
|
-
distribution: Optional[DistributionOptions] = Field(
|
|
45
|
-
title="Distribution of the application package created by the Snowflake CLI",
|
|
46
|
-
default="internal",
|
|
47
|
-
)
|
|
48
|
-
post_deploy: Optional[List[PostDeployHook]] = Field(
|
|
49
|
-
title="Actions that will be executed after the application package object is created/updated",
|
|
50
|
-
default=None,
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
@field_validator("scripts")
|
|
54
|
-
@classmethod
|
|
55
|
-
def validate_scripts(cls, input_list):
|
|
56
|
-
if len(input_list) != len(set(input_list)):
|
|
57
|
-
raise ValueError(
|
|
58
|
-
"package.scripts field should contain unique values. Check the list for duplicates and try again"
|
|
59
|
-
)
|
|
60
|
-
return input_list
|
|
61
|
-
|
|
62
|
-
@model_validator(mode="after")
|
|
63
|
-
@classmethod
|
|
64
|
-
def validate_no_scripts_and_post_deploy(cls, value: Package):
|
|
65
|
-
if value.scripts and value.post_deploy:
|
|
66
|
-
raise ValueError(
|
|
67
|
-
"package.scripts and package.post_deploy fields cannot be used together. "
|
|
68
|
-
"We recommend using package.post_deploy for all post package deploy scripts"
|
|
69
|
-
)
|
|
70
|
-
return value
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
class PackageV11(Package):
|
|
74
|
-
# Templated defaults only supported in v1.1+
|
|
75
|
-
name: Optional[str] = IdentifierField(
|
|
76
|
-
title="Name of the application package created when you run the snow app run command",
|
|
77
|
-
default="<% fn.concat_ids(ctx.native_app.name, '_pkg_', fn.sanitize_id(fn.get_username('unknown_user')) | lower) %>",
|
|
78
|
-
)
|
|
@@ -1,65 +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 Any, Dict, List, Optional, Union
|
|
18
|
-
|
|
19
|
-
from pydantic import Field, field_validator
|
|
20
|
-
from snowflake.cli.api.project.schemas.updatable_model import UpdatableModel
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class ProcessorMapping(UpdatableModel):
|
|
24
|
-
name: str = Field(
|
|
25
|
-
title="Name of a processor to invoke on a collection of artifacts."
|
|
26
|
-
)
|
|
27
|
-
properties: Optional[Dict[str, Any]] = Field(
|
|
28
|
-
title="A set of key-value pairs used to configure the output of the processor. Consult a specific processor's documentation for more details on the supported properties.",
|
|
29
|
-
default=None,
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class PathMapping(UpdatableModel):
|
|
34
|
-
src: str = Field(
|
|
35
|
-
title="Source path or glob pattern (relative to project root)", default=None
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
dest: Optional[str] = Field(
|
|
39
|
-
title="Destination path on stage",
|
|
40
|
-
description="Paths are relative to stage root; paths ending with a slash indicate that the destination is a directory which source files should be copied into.",
|
|
41
|
-
default=None,
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
processors: Optional[List[Union[str, ProcessorMapping]]] = Field(
|
|
45
|
-
title="List of processors to apply to matching source files during bundling.",
|
|
46
|
-
default=[],
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
@field_validator("processors")
|
|
50
|
-
@classmethod
|
|
51
|
-
def transform_processors(
|
|
52
|
-
cls, input_values: Optional[List[Union[str, Dict, ProcessorMapping]]]
|
|
53
|
-
) -> List[ProcessorMapping]:
|
|
54
|
-
if input_values is None:
|
|
55
|
-
return []
|
|
56
|
-
|
|
57
|
-
transformed_processors: List[ProcessorMapping] = []
|
|
58
|
-
for input_processor in input_values:
|
|
59
|
-
if isinstance(input_processor, str):
|
|
60
|
-
transformed_processors.append(ProcessorMapping(name=input_processor))
|
|
61
|
-
elif isinstance(input_processor, Dict):
|
|
62
|
-
transformed_processors.append(ProcessorMapping(**input_processor))
|
|
63
|
-
else:
|
|
64
|
-
transformed_processors.append(input_processor)
|
|
65
|
-
return transformed_processors
|