snowflake-cli-labs 2.8.1__py3-none-any.whl → 3.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- snowflake/cli/__about__.py +1 -1
- snowflake/cli/{app → _app}/__main__.py +1 -1
- snowflake/cli/{app → _app}/cli_app.py +22 -13
- snowflake/cli/{app → _app}/commands_registration/builtin_plugins.py +15 -19
- snowflake/cli/{app → _app}/commands_registration/command_plugins_loader.py +9 -9
- snowflake/cli/{app → _app}/commands_registration/commands_registration_with_callbacks.py +4 -4
- snowflake/cli/{app → _app}/commands_registration/exception_logging.py +2 -2
- snowflake/cli/{app → _app}/commands_registration/typer_registration.py +2 -2
- snowflake/cli/{app → _app}/dev/docs/commands_docs_generator.py +30 -12
- snowflake/cli/{app → _app}/dev/docs/generator.py +3 -3
- snowflake/cli/{app → _app}/dev/docs/project_definition_docs_generator.py +4 -4
- snowflake/cli/{app → _app}/dev/docs/templates/usage.rst.jinja2 +14 -4
- snowflake/cli/{app → _app}/main_typer.py +2 -2
- snowflake/cli/{app → _app}/printing.py +2 -2
- snowflake/cli/_app/secret.py +9 -0
- snowflake/cli/{app → _app}/snow_connector.py +127 -61
- snowflake/cli/{app → _app}/telemetry.py +38 -7
- snowflake/cli/_app/version_check.py +74 -0
- snowflake/cli/{plugins → _plugins}/connection/commands.py +34 -11
- snowflake/cli/_plugins/connection/plugin_spec.py +30 -0
- snowflake/cli/{plugins → _plugins}/connection/util.py +16 -0
- snowflake/cli/{plugins → _plugins}/cortex/commands.py +54 -49
- snowflake/cli/{plugins → _plugins}/cortex/constants.py +1 -1
- snowflake/cli/{plugins → _plugins}/cortex/manager.py +5 -5
- snowflake/cli/{plugins → _plugins}/cortex/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/git/commands.py +11 -7
- snowflake/cli/{plugins → _plugins}/git/manager.py +55 -9
- snowflake/cli/{plugins → _plugins}/git/plugin_spec.py +1 -1
- snowflake/cli/_plugins/helpers/commands.py +90 -0
- snowflake/cli/{plugins/notebook → _plugins/helpers}/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/init/commands.py +2 -2
- snowflake/cli/{plugins → _plugins}/init/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/nativeapp/artifacts.py +24 -9
- snowflake/cli/_plugins/nativeapp/bundle_context.py +31 -0
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/artifact_processor.py +4 -4
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/compiler.py +37 -18
- snowflake/cli/_plugins/nativeapp/codegen/setup/native_app_setup_processor.py +249 -0
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/setup/setup_driver.py.source +5 -2
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/extension_function_utils.py +5 -5
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/models.py +1 -1
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/python_processor.py +29 -34
- snowflake/cli/_plugins/nativeapp/codegen/templates/templates_processor.py +114 -0
- snowflake/cli/{plugins → _plugins}/nativeapp/commands.py +252 -132
- snowflake/cli/{plugins → _plugins}/nativeapp/common_flags.py +1 -1
- snowflake/cli/_plugins/nativeapp/entities/application.py +878 -0
- snowflake/cli/_plugins/nativeapp/entities/application_package.py +1392 -0
- snowflake/cli/{plugins → _plugins}/nativeapp/exceptions.py +3 -12
- snowflake/cli/_plugins/nativeapp/manager.py +415 -0
- snowflake/cli/{plugins/connection → _plugins/nativeapp}/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/nativeapp/policy.py +3 -0
- snowflake/cli/{plugins → _plugins}/nativeapp/project_model.py +36 -20
- snowflake/cli/_plugins/nativeapp/run_processor.py +184 -0
- snowflake/cli/_plugins/nativeapp/same_account_install_method.py +70 -0
- snowflake/cli/_plugins/nativeapp/teardown_processor.py +70 -0
- snowflake/cli/_plugins/nativeapp/v2_conversions/v2_to_v1_decorator.py +262 -0
- snowflake/cli/{plugins → _plugins}/nativeapp/version/commands.py +20 -49
- snowflake/cli/_plugins/nativeapp/version/version_processor.py +98 -0
- snowflake/cli/{plugins → _plugins}/notebook/commands.py +3 -2
- snowflake/cli/{plugins → _plugins}/notebook/manager.py +5 -5
- snowflake/cli/{plugins/nativeapp → _plugins/notebook}/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/object/command_aliases.py +4 -4
- snowflake/cli/{plugins → _plugins}/object/commands.py +4 -5
- snowflake/cli/{plugins → _plugins}/object/manager.py +36 -15
- snowflake/cli/{plugins → _plugins}/object/plugin_spec.py +1 -1
- snowflake/cli/_plugins/snowpark/commands.py +450 -0
- snowflake/cli/_plugins/snowpark/common.py +268 -0
- snowflake/cli/{plugins → _plugins}/snowpark/models.py +0 -7
- snowflake/cli/{plugins → _plugins}/snowpark/package/anaconda_packages.py +2 -36
- snowflake/cli/{plugins → _plugins}/snowpark/package/commands.py +13 -74
- snowflake/cli/{plugins → _plugins}/snowpark/package/manager.py +2 -2
- snowflake/cli/{plugins → _plugins}/snowpark/package_utils.py +5 -5
- snowflake/cli/_plugins/snowpark/plugin_spec.py +30 -0
- snowflake/cli/_plugins/snowpark/snowpark_entity.py +29 -0
- snowflake/cli/_plugins/snowpark/snowpark_entity_model.py +173 -0
- snowflake/cli/_plugins/snowpark/snowpark_project_paths.py +109 -0
- snowflake/cli/{plugins → _plugins}/snowpark/snowpark_shared.py +0 -36
- snowflake/cli/{plugins → _plugins}/snowpark/zipper.py +16 -8
- snowflake/cli/{plugins → _plugins}/spcs/__init__.py +5 -7
- snowflake/cli/{plugins → _plugins}/spcs/compute_pool/commands.py +8 -8
- snowflake/cli/{plugins → _plugins}/spcs/compute_pool/manager.py +3 -3
- snowflake/cli/{plugins → _plugins}/spcs/image_registry/commands.py +3 -3
- snowflake/cli/{plugins → _plugins}/spcs/image_repository/commands.py +6 -6
- snowflake/cli/{plugins → _plugins}/spcs/image_repository/manager.py +1 -1
- snowflake/cli/{plugins → _plugins}/spcs/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/spcs/services/commands.py +44 -11
- snowflake/cli/{plugins → _plugins}/spcs/services/manager.py +43 -5
- snowflake/cli/{plugins → _plugins}/sql/commands.py +20 -17
- snowflake/cli/{plugins → _plugins}/sql/manager.py +1 -1
- snowflake/cli/{plugins → _plugins}/sql/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/stage/commands.py +15 -14
- snowflake/cli/{plugins → _plugins}/stage/diff.py +1 -47
- snowflake/cli/{plugins → _plugins}/stage/manager.py +12 -7
- snowflake/cli/{plugins → _plugins}/stage/plugin_spec.py +1 -1
- snowflake/cli/_plugins/stage/utils.py +54 -0
- snowflake/cli/{plugins → _plugins}/streamlit/commands.py +64 -48
- snowflake/cli/{plugins → _plugins}/streamlit/manager.py +67 -69
- snowflake/cli/_plugins/streamlit/plugin_spec.py +30 -0
- snowflake/cli/_plugins/streamlit/streamlit_entity.py +12 -0
- snowflake/cli/_plugins/streamlit/streamlit_entity_model.py +66 -0
- snowflake/cli/_plugins/workspace/action_context.py +18 -0
- snowflake/cli/_plugins/workspace/commands.py +306 -0
- snowflake/cli/_plugins/workspace/manager.py +74 -0
- snowflake/cli/_plugins/workspace/plugin_spec.py +30 -0
- snowflake/cli/api/cli_global_context.py +152 -295
- snowflake/cli/api/commands/common.py +25 -0
- snowflake/cli/api/commands/decorators.py +19 -4
- snowflake/cli/api/commands/experimental_behaviour.py +2 -3
- snowflake/cli/api/commands/flags.py +127 -228
- snowflake/cli/api/commands/overrideable_parameter.py +143 -0
- snowflake/cli/api/commands/snow_typer.py +21 -11
- snowflake/cli/api/commands/utils.py +18 -0
- snowflake/cli/api/config.py +44 -12
- snowflake/cli/api/connections.py +216 -0
- snowflake/cli/api/console/abc.py +8 -3
- snowflake/cli/api/constants.py +11 -0
- snowflake/cli/api/entities/common.py +56 -0
- snowflake/cli/api/entities/utils.py +370 -0
- snowflake/cli/api/errno.py +1 -0
- snowflake/cli/api/exceptions.py +31 -5
- snowflake/cli/api/feature_flags.py +0 -1
- snowflake/cli/api/identifiers.py +28 -5
- snowflake/cli/api/metrics.py +92 -0
- snowflake/cli/api/project/definition.py +48 -6
- snowflake/cli/api/project/definition_conversion.py +400 -0
- snowflake/cli/api/project/definition_manager.py +16 -5
- snowflake/cli/api/project/project_verification.py +3 -3
- snowflake/cli/api/project/schemas/entities/common.py +91 -16
- snowflake/cli/api/project/schemas/entities/entities.py +37 -6
- snowflake/cli/api/project/schemas/project_definition.py +180 -49
- snowflake/cli/api/project/schemas/updatable_model.py +11 -3
- snowflake/cli/api/project/schemas/v1/__init__.py +0 -0
- snowflake/cli/api/project/schemas/{identifier_model.py → v1/identifier_model.py} +3 -1
- snowflake/cli/api/project/schemas/v1/native_app/__init__.py +0 -0
- snowflake/cli/api/project/schemas/{native_app → v1/native_app}/application.py +8 -9
- snowflake/cli/api/project/schemas/{native_app → v1/native_app}/native_app.py +4 -4
- snowflake/cli/api/project/schemas/{native_app → v1/native_app}/package.py +7 -1
- snowflake/cli/api/project/schemas/v1/snowpark/__init__.py +0 -0
- snowflake/cli/api/project/schemas/{snowpark → v1/snowpark}/callable.py +2 -2
- snowflake/cli/api/project/schemas/{snowpark → v1/snowpark}/snowpark.py +2 -2
- snowflake/cli/api/project/schemas/v1/streamlit/__init__.py +0 -0
- snowflake/cli/api/project/schemas/{streamlit → v1/streamlit}/streamlit.py +2 -1
- snowflake/cli/api/project/util.py +23 -6
- snowflake/cli/api/rendering/jinja.py +14 -8
- snowflake/cli/api/rendering/project_definition_templates.py +5 -1
- snowflake/cli/api/rendering/sql_templates.py +56 -11
- snowflake/cli/api/rest_api.py +11 -5
- snowflake/cli/api/secure_path.py +16 -18
- snowflake/cli/api/secure_utils.py +90 -1
- snowflake/cli/api/sql_execution.py +43 -23
- snowflake/cli/api/utils/definition_rendering.py +45 -13
- {snowflake_cli_labs-2.8.1.dist-info → snowflake_cli_labs-3.0.0.dist-info}/METADATA +20 -18
- snowflake_cli_labs-3.0.0.dist-info/RECORD +242 -0
- snowflake_cli_labs-3.0.0.dist-info/entry_points.txt +2 -0
- snowflake/cli/api/commands/project_initialisation.py +0 -65
- snowflake/cli/api/commands/typer_pre_execute.py +0 -26
- 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/app/build_and_push.sh +0 -8
- snowflake/cli/plugins/nativeapp/codegen/setup/native_app_setup_processor.py +0 -172
- snowflake/cli/plugins/nativeapp/init.py +0 -345
- snowflake/cli/plugins/nativeapp/manager.py +0 -823
- snowflake/cli/plugins/nativeapp/run_processor.py +0 -389
- snowflake/cli/plugins/nativeapp/teardown_processor.py +0 -301
- snowflake/cli/plugins/nativeapp/v2_conversions/v2_to_v1_decorator.py +0 -135
- snowflake/cli/plugins/nativeapp/version/version_processor.py +0 -362
- 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/commands.py +0 -546
- snowflake/cli/plugins/snowpark/common.py +0 -307
- snowflake/cli/plugins/snowpark/manager.py +0 -109
- snowflake/cli/plugins/snowpark/plugin_spec.py +0 -30
- snowflake/cli/plugins/snowpark/snowpark_package_paths.py +0 -65
- snowflake/cli/plugins/spcs/jobs/commands.py +0 -78
- snowflake/cli/plugins/spcs/jobs/manager.py +0 -53
- snowflake/cli/plugins/streamlit/__init__.py +0 -13
- 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/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/{app → _app}/__init__.py +0 -0
- /snowflake/cli/{api/project/schemas/native_app → _app/api_impl}/__init__.py +0 -0
- /snowflake/cli/{api/project/schemas/snowpark → _app/api_impl/plugin}/__init__.py +0 -0
- /snowflake/cli/{app → _app}/api_impl/plugin/plugin_config_provider_impl.py +0 -0
- /snowflake/cli/{app → _app}/commands_registration/__init__.py +0 -0
- /snowflake/cli/{app → _app}/commands_registration/threadsafe.py +0 -0
- /snowflake/cli/{app → _app}/constants.py +0 -0
- /snowflake/cli/{api/project/schemas/streamlit → _app/dev}/__init__.py +0 -0
- /snowflake/cli/{app → _app}/dev/commands_structure.py +0 -0
- /snowflake/cli/{app/api_impl → _app/dev/docs}/__init__.py +0 -0
- /snowflake/cli/{app → _app}/dev/docs/project_definition_generate_json_schema.py +0 -0
- /snowflake/cli/{app → _app}/dev/docs/template_utils.py +0 -0
- /snowflake/cli/{app → _app}/dev/docs/templates/definition_description.rst.jinja2 +0 -0
- /snowflake/cli/{app → _app}/dev/docs/templates/overview.rst.jinja2 +0 -0
- /snowflake/cli/{app → _app}/dev/pycharm_remote_debug.py +0 -0
- /snowflake/cli/{app → _app}/loggers.py +0 -0
- /snowflake/cli/{app/api_impl/plugin → _plugins}/__init__.py +0 -0
- /snowflake/cli/{app/dev → _plugins/connection}/__init__.py +0 -0
- /snowflake/cli/{app/dev/docs → _plugins/cortex}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/cortex/types.py +0 -0
- /snowflake/cli/{plugins → _plugins/git}/__init__.py +0 -0
- /snowflake/cli/{plugins/connection → _plugins/helpers}/__init__.py +0 -0
- /snowflake/cli/{plugins/cortex → _plugins/init}/__init__.py +0 -0
- /snowflake/cli/{plugins/git → _plugins/nativeapp}/__init__.py +0 -0
- /snowflake/cli/{plugins/init → _plugins/nativeapp/codegen}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/codegen/sandbox.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/callback_source.py.jinja +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/constants.py +0 -0
- /snowflake/cli/{templates/default_snowpark/app → _plugins/nativeapp/entities}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/feature_flags.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/utils.py +0 -0
- /snowflake/cli/{plugins/nativeapp → _plugins/nativeapp/version}/__init__.py +0 -0
- /snowflake/cli/{plugins/nativeapp/codegen → _plugins/notebook}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/notebook/exceptions.py +0 -0
- /snowflake/cli/{plugins → _plugins}/notebook/types.py +0 -0
- /snowflake/cli/{plugins/nativeapp/version → _plugins/object}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/object/common.py +0 -0
- /snowflake/cli/{plugins/notebook → _plugins/snowpark}/__init__.py +0 -0
- /snowflake/cli/{plugins/object → _plugins/snowpark/package}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/snowpark/package/utils.py +0 -0
- /snowflake/cli/{plugins → _plugins}/spcs/common.py +0 -0
- /snowflake/cli/{plugins/snowpark → _plugins/spcs/compute_pool}/__init__.py +0 -0
- /snowflake/cli/{plugins/snowpark/package → _plugins/spcs/image_registry}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/spcs/image_registry/manager.py +0 -0
- /snowflake/cli/{plugins/spcs/compute_pool → _plugins/spcs/image_repository}/__init__.py +0 -0
- /snowflake/cli/{plugins/spcs/image_registry → _plugins/spcs/services}/__init__.py +0 -0
- /snowflake/cli/{plugins/spcs/image_repository → _plugins/sql}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/sql/snowsql_templating.py +0 -0
- /snowflake/cli/{plugins/spcs/jobs → _plugins/stage}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/stage/md5.py +0 -0
- /snowflake/cli/{plugins/spcs/services → _plugins/streamlit}/__init__.py +0 -0
- /snowflake/cli/{plugins/sql → _plugins/workspace}/__init__.py +0 -0
- /snowflake/cli/{plugins/stage → api/project/schemas/entities}/__init__.py +0 -0
- /snowflake/cli/api/project/schemas/{native_app → v1/native_app}/path_mapping.py +0 -0
- /snowflake/cli/api/project/schemas/{snowpark → v1/snowpark}/argument.py +0 -0
- {snowflake_cli_labs-2.8.1.dist-info → snowflake_cli_labs-3.0.0.dist-info}/WHEEL +0 -0
- {snowflake_cli_labs-2.8.1.dist-info → snowflake_cli_labs-3.0.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,135 +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 functools import wraps
|
|
18
|
-
from pathlib import Path
|
|
19
|
-
from typing import Any, Dict, Optional, Union
|
|
20
|
-
|
|
21
|
-
from click import ClickException
|
|
22
|
-
from snowflake.cli.api.cli_global_context import cli_context, cli_context_manager
|
|
23
|
-
from snowflake.cli.api.project.schemas.entities.application_entity import (
|
|
24
|
-
ApplicationEntity,
|
|
25
|
-
)
|
|
26
|
-
from snowflake.cli.api.project.schemas.entities.application_package_entity import (
|
|
27
|
-
ApplicationPackageEntity,
|
|
28
|
-
)
|
|
29
|
-
from snowflake.cli.api.project.schemas.native_app.path_mapping import PathMapping
|
|
30
|
-
from snowflake.cli.api.project.schemas.project_definition import (
|
|
31
|
-
DefinitionV11,
|
|
32
|
-
DefinitionV20,
|
|
33
|
-
)
|
|
34
|
-
from snowflake.cli.api.utils.definition_rendering import render_definition_template
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def _convert_v2_artifact_to_v1_dict(
|
|
38
|
-
v2_artifact: Union[PathMapping, Path]
|
|
39
|
-
) -> Union[Dict, str]:
|
|
40
|
-
if isinstance(v2_artifact, PathMapping):
|
|
41
|
-
return {
|
|
42
|
-
"src": v2_artifact.src,
|
|
43
|
-
"dest": v2_artifact.dest,
|
|
44
|
-
"processors": v2_artifact.processors,
|
|
45
|
-
}
|
|
46
|
-
return str(v2_artifact)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def _pdf_v2_to_v1(v2_definition: DefinitionV20) -> DefinitionV11:
|
|
50
|
-
pdfv1: Dict[str, Any] = {"definition_version": "1.1", "native_app": {}}
|
|
51
|
-
|
|
52
|
-
app_package_definition: ApplicationPackageEntity = None
|
|
53
|
-
app_definition: Optional[ApplicationEntity] = None
|
|
54
|
-
|
|
55
|
-
for key, entity in v2_definition.entities.items():
|
|
56
|
-
if entity.get_type() == ApplicationPackageEntity.get_type():
|
|
57
|
-
if app_package_definition:
|
|
58
|
-
raise ClickException(
|
|
59
|
-
"More than one application package entity exists in the project definition file."
|
|
60
|
-
)
|
|
61
|
-
app_package_definition = entity
|
|
62
|
-
elif entity.get_type() == ApplicationEntity.get_type():
|
|
63
|
-
if app_definition:
|
|
64
|
-
raise ClickException(
|
|
65
|
-
"More than one application entity exists in the project definition file."
|
|
66
|
-
)
|
|
67
|
-
app_definition = entity
|
|
68
|
-
if not app_package_definition:
|
|
69
|
-
raise ClickException(
|
|
70
|
-
"Could not find an application package entity in the project definition file."
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
# NativeApp
|
|
74
|
-
if app_definition and app_definition.name:
|
|
75
|
-
pdfv1["native_app"]["name"] = app_definition.name
|
|
76
|
-
else:
|
|
77
|
-
pdfv1["native_app"]["name"] = app_package_definition.name.split("_pkg_")[0]
|
|
78
|
-
pdfv1["native_app"]["artifacts"] = [
|
|
79
|
-
_convert_v2_artifact_to_v1_dict(a) for a in app_package_definition.artifacts
|
|
80
|
-
]
|
|
81
|
-
pdfv1["native_app"]["source_stage"] = app_package_definition.stage
|
|
82
|
-
pdfv1["native_app"]["bundle_root"] = str(app_package_definition.bundle_root)
|
|
83
|
-
pdfv1["native_app"]["generated_root"] = str(app_package_definition.generated_root)
|
|
84
|
-
pdfv1["native_app"]["deploy_root"] = str(app_package_definition.deploy_root)
|
|
85
|
-
|
|
86
|
-
# Package
|
|
87
|
-
pdfv1["native_app"]["package"] = {}
|
|
88
|
-
pdfv1["native_app"]["package"]["name"] = app_package_definition.name
|
|
89
|
-
if app_package_definition.distribution:
|
|
90
|
-
pdfv1["native_app"]["package"][
|
|
91
|
-
"distribution"
|
|
92
|
-
] = app_package_definition.distribution
|
|
93
|
-
if app_package_definition.meta and app_package_definition.meta.post_deploy:
|
|
94
|
-
pdfv1["native_app"]["package"][
|
|
95
|
-
"post_deploy"
|
|
96
|
-
] = app_package_definition.meta.post_deploy
|
|
97
|
-
|
|
98
|
-
# Application
|
|
99
|
-
if app_definition:
|
|
100
|
-
pdfv1["native_app"]["application"] = {}
|
|
101
|
-
pdfv1["native_app"]["application"]["name"] = app_definition.name
|
|
102
|
-
if app_definition.meta and app_definition.meta.role:
|
|
103
|
-
pdfv1["native_app"]["application"]["role"] = app_definition.meta.role
|
|
104
|
-
if app_definition.meta and app_definition.meta.post_deploy:
|
|
105
|
-
pdfv1["native_app"]["application"][
|
|
106
|
-
"post_deploy"
|
|
107
|
-
] = app_definition.meta.post_deploy
|
|
108
|
-
|
|
109
|
-
result = render_definition_template(pdfv1, {})
|
|
110
|
-
# Override the definition object in global context
|
|
111
|
-
return result.project_definition
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
def nativeapp_definition_v2_to_v1(func):
|
|
115
|
-
"""
|
|
116
|
-
A command decorator that attempts to automatically convert a native app project from
|
|
117
|
-
definition v2 to v1.1. Assumes with_project_definition() has already been called.
|
|
118
|
-
The definition object in CliGlobalContext will be replaced with the converted object.
|
|
119
|
-
Exactly one application package entity type is expected, and up to one application
|
|
120
|
-
entity type is expected.
|
|
121
|
-
"""
|
|
122
|
-
|
|
123
|
-
@wraps(func)
|
|
124
|
-
def wrapper(*args, **kwargs):
|
|
125
|
-
original_pdf: DefinitionV20 = cli_context.project_definition
|
|
126
|
-
if not original_pdf:
|
|
127
|
-
raise ValueError(
|
|
128
|
-
"Project definition could not be found. The nativeapp_definition_v2_to_v1 command decorator assumes with_project_definition() was called before it."
|
|
129
|
-
)
|
|
130
|
-
if original_pdf.definition_version == "2":
|
|
131
|
-
pdfv1 = _pdf_v2_to_v1(original_pdf)
|
|
132
|
-
cli_context_manager.set_project_definition(pdfv1)
|
|
133
|
-
return func(*args, **kwargs)
|
|
134
|
-
|
|
135
|
-
return wrapper
|
|
@@ -1,362 +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 textwrap import dedent
|
|
19
|
-
from typing import Dict, List, Optional
|
|
20
|
-
|
|
21
|
-
import typer
|
|
22
|
-
from click import BadOptionUsage, ClickException
|
|
23
|
-
from snowflake.cli.api.console import cli_console as cc
|
|
24
|
-
from snowflake.cli.api.exceptions import SnowflakeSQLExecutionError
|
|
25
|
-
from snowflake.cli.api.project.schemas.native_app.native_app import NativeApp
|
|
26
|
-
from snowflake.cli.api.project.util import unquote_identifier
|
|
27
|
-
from snowflake.cli.api.utils.cursor import (
|
|
28
|
-
find_all_rows,
|
|
29
|
-
find_first_row,
|
|
30
|
-
)
|
|
31
|
-
from snowflake.cli.plugins.nativeapp.artifacts import (
|
|
32
|
-
BundleMap,
|
|
33
|
-
find_version_info_in_manifest_file,
|
|
34
|
-
)
|
|
35
|
-
from snowflake.cli.plugins.nativeapp.constants import VERSION_COL
|
|
36
|
-
from snowflake.cli.plugins.nativeapp.exceptions import (
|
|
37
|
-
ApplicationPackageAlreadyExistsError,
|
|
38
|
-
ApplicationPackageDoesNotExistError,
|
|
39
|
-
)
|
|
40
|
-
from snowflake.cli.plugins.nativeapp.manager import (
|
|
41
|
-
NativeAppCommandProcessor,
|
|
42
|
-
NativeAppManager,
|
|
43
|
-
ensure_correct_owner,
|
|
44
|
-
)
|
|
45
|
-
from snowflake.cli.plugins.nativeapp.policy import PolicyBase
|
|
46
|
-
from snowflake.cli.plugins.nativeapp.run_processor import NativeAppRunProcessor
|
|
47
|
-
from snowflake.connector import ProgrammingError
|
|
48
|
-
from snowflake.connector.cursor import DictCursor
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def check_index_changes_in_git_repo(
|
|
52
|
-
project_root: Path, policy: PolicyBase, is_interactive: bool
|
|
53
|
-
) -> None:
|
|
54
|
-
"""
|
|
55
|
-
Checks if the project root, i.e. the native apps project is a git repository. If it is a git repository,
|
|
56
|
-
it also checks if there any local changes to the directory that may not be on the application package stage.
|
|
57
|
-
"""
|
|
58
|
-
from git import Repo
|
|
59
|
-
from git.exc import InvalidGitRepositoryError
|
|
60
|
-
|
|
61
|
-
try:
|
|
62
|
-
repo = Repo(project_root, search_parent_directories=True)
|
|
63
|
-
assert repo.git_dir is not None
|
|
64
|
-
|
|
65
|
-
# Check if the repo has any changes, including untracked files
|
|
66
|
-
if repo.is_dirty(untracked_files=True):
|
|
67
|
-
cc.warning(
|
|
68
|
-
"Changes detected in the git repository. "
|
|
69
|
-
"(Rerun your command with --skip-git-check flag to ignore this check)"
|
|
70
|
-
)
|
|
71
|
-
repo.git.execute(["git", "status"])
|
|
72
|
-
|
|
73
|
-
user_prompt = (
|
|
74
|
-
"You have local changes in this repository that are not part of a previous commit. "
|
|
75
|
-
"Do you still want to continue?"
|
|
76
|
-
)
|
|
77
|
-
if not policy.should_proceed(user_prompt):
|
|
78
|
-
if is_interactive:
|
|
79
|
-
cc.message("Not creating a new version.")
|
|
80
|
-
raise typer.Exit(0)
|
|
81
|
-
else:
|
|
82
|
-
cc.message(
|
|
83
|
-
"Cannot create a new version non-interactively without --force."
|
|
84
|
-
)
|
|
85
|
-
raise typer.Exit(1)
|
|
86
|
-
|
|
87
|
-
except InvalidGitRepositoryError:
|
|
88
|
-
pass # not a git repository, which is acceptable
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
class NativeAppVersionCreateProcessor(NativeAppRunProcessor):
|
|
92
|
-
def __init__(self, project_definition: Dict, project_root: Path):
|
|
93
|
-
super().__init__(project_definition, project_root)
|
|
94
|
-
|
|
95
|
-
def get_existing_release_directive_info_for_version(
|
|
96
|
-
self, version: str
|
|
97
|
-
) -> List[dict]:
|
|
98
|
-
"""
|
|
99
|
-
Get all existing release directives, if present, set on the version defined in an application package.
|
|
100
|
-
It executes a 'show release directives in application package' query and returns the filtered results, if they exist.
|
|
101
|
-
"""
|
|
102
|
-
with self.use_role(self.package_role):
|
|
103
|
-
show_obj_query = (
|
|
104
|
-
f"show release directives in application package {self.package_name}"
|
|
105
|
-
)
|
|
106
|
-
show_obj_cursor = self._execute_query(
|
|
107
|
-
show_obj_query, cursor_class=DictCursor
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
if show_obj_cursor.rowcount is None:
|
|
111
|
-
raise SnowflakeSQLExecutionError(show_obj_query)
|
|
112
|
-
|
|
113
|
-
show_obj_rows = find_all_rows(
|
|
114
|
-
show_obj_cursor,
|
|
115
|
-
lambda row: row[VERSION_COL] == unquote_identifier(version),
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
return show_obj_rows
|
|
119
|
-
|
|
120
|
-
def add_new_version(self, version: str) -> None:
|
|
121
|
-
"""
|
|
122
|
-
Defines a new version in an existing application package.
|
|
123
|
-
"""
|
|
124
|
-
with self.use_role(self.package_role):
|
|
125
|
-
cc.step(
|
|
126
|
-
f"Defining a new version {version} in application package {self.package_name}"
|
|
127
|
-
)
|
|
128
|
-
add_version_query = dedent(
|
|
129
|
-
f"""\
|
|
130
|
-
alter application package {self.package_name}
|
|
131
|
-
add version {version}
|
|
132
|
-
using @{self.stage_fqn}
|
|
133
|
-
"""
|
|
134
|
-
)
|
|
135
|
-
self._execute_query(add_version_query, cursor_class=DictCursor)
|
|
136
|
-
cc.message(
|
|
137
|
-
f"Version {version} created for application package {self.package_name}."
|
|
138
|
-
)
|
|
139
|
-
|
|
140
|
-
def add_new_patch_to_version(self, version: str, patch: Optional[int] = None):
|
|
141
|
-
"""
|
|
142
|
-
Add a new patch, optionally a custom one, to an existing version in an application package.
|
|
143
|
-
"""
|
|
144
|
-
with self.use_role(self.package_role):
|
|
145
|
-
cc.step(
|
|
146
|
-
f"Adding new patch to version {version} defined in application package {self.package_name}"
|
|
147
|
-
)
|
|
148
|
-
add_version_query = dedent(
|
|
149
|
-
f"""\
|
|
150
|
-
alter application package {self.package_name}
|
|
151
|
-
add patch {patch if patch else ""} for version {version}
|
|
152
|
-
using @{self.stage_fqn}
|
|
153
|
-
"""
|
|
154
|
-
)
|
|
155
|
-
result_cursor = self._execute_query(
|
|
156
|
-
add_version_query, cursor_class=DictCursor
|
|
157
|
-
)
|
|
158
|
-
|
|
159
|
-
show_row = find_first_row(
|
|
160
|
-
result_cursor,
|
|
161
|
-
lambda row: row[VERSION_COL] == unquote_identifier(version),
|
|
162
|
-
)
|
|
163
|
-
|
|
164
|
-
new_patch = show_row["patch"]
|
|
165
|
-
cc.message(
|
|
166
|
-
f"Patch {new_patch} created for version {version} defined in application package {self.package_name}."
|
|
167
|
-
)
|
|
168
|
-
|
|
169
|
-
def process(
|
|
170
|
-
self,
|
|
171
|
-
bundle_map: BundleMap,
|
|
172
|
-
version: Optional[str],
|
|
173
|
-
patch: Optional[int],
|
|
174
|
-
policy: PolicyBase,
|
|
175
|
-
git_policy: PolicyBase,
|
|
176
|
-
is_interactive: bool,
|
|
177
|
-
*args,
|
|
178
|
-
**kwargs,
|
|
179
|
-
):
|
|
180
|
-
"""
|
|
181
|
-
Perform bundle, application package creation, stage upload, version and/or patch to an application package.
|
|
182
|
-
"""
|
|
183
|
-
|
|
184
|
-
# Make sure version is not None before proceeding any further.
|
|
185
|
-
# This will raise an exception if version information is not found. Patch can be None.
|
|
186
|
-
if not version:
|
|
187
|
-
cc.message(
|
|
188
|
-
"Version was not provided through the Snowflake CLI. Checking version in the manifest.yml instead."
|
|
189
|
-
)
|
|
190
|
-
|
|
191
|
-
version, patch = find_version_info_in_manifest_file(self.deploy_root)
|
|
192
|
-
if not version:
|
|
193
|
-
raise ClickException(
|
|
194
|
-
"Manifest.yml file does not contain a value for the version field."
|
|
195
|
-
)
|
|
196
|
-
|
|
197
|
-
# Check if --patch needs to throw a bad option error, either if application package does not exist or if version does not exist
|
|
198
|
-
if patch:
|
|
199
|
-
try:
|
|
200
|
-
if not self.get_existing_version_info(version):
|
|
201
|
-
raise BadOptionUsage(
|
|
202
|
-
option_name="patch",
|
|
203
|
-
message=f"Cannot create a custom patch when version {version} is not defined in the application package {self.package_name}. Try again without using --patch.",
|
|
204
|
-
)
|
|
205
|
-
except ApplicationPackageDoesNotExistError as app_err:
|
|
206
|
-
raise BadOptionUsage(
|
|
207
|
-
option_name="patch",
|
|
208
|
-
message=f"Cannot create a custom patch when application package {self.package_name} does not exist. Try again without using --patch.",
|
|
209
|
-
)
|
|
210
|
-
|
|
211
|
-
if git_policy.should_proceed():
|
|
212
|
-
check_index_changes_in_git_repo(
|
|
213
|
-
project_root=self.project_root,
|
|
214
|
-
policy=policy,
|
|
215
|
-
is_interactive=is_interactive,
|
|
216
|
-
)
|
|
217
|
-
|
|
218
|
-
# TODO: consider using self.deploy() instead
|
|
219
|
-
|
|
220
|
-
try:
|
|
221
|
-
self.create_app_package()
|
|
222
|
-
except ApplicationPackageAlreadyExistsError as e:
|
|
223
|
-
cc.warning(e.message)
|
|
224
|
-
if not policy.should_proceed("Proceed with using this package?"):
|
|
225
|
-
raise typer.Abort() from e
|
|
226
|
-
|
|
227
|
-
with self.use_role(self.package_role):
|
|
228
|
-
# Now that the application package exists, create shared data
|
|
229
|
-
self._apply_package_scripts()
|
|
230
|
-
|
|
231
|
-
# Upload files from deploy root local folder to the above stage
|
|
232
|
-
self.sync_deploy_root_with_stage(
|
|
233
|
-
bundle_map=bundle_map,
|
|
234
|
-
role=self.package_role,
|
|
235
|
-
prune=True,
|
|
236
|
-
recursive=True,
|
|
237
|
-
stage_fqn=self.stage_fqn,
|
|
238
|
-
)
|
|
239
|
-
with self.use_package_warehouse():
|
|
240
|
-
self.execute_package_post_deploy_hooks()
|
|
241
|
-
|
|
242
|
-
# Warn if the version exists in a release directive(s)
|
|
243
|
-
existing_release_directives = (
|
|
244
|
-
self.get_existing_release_directive_info_for_version(version)
|
|
245
|
-
)
|
|
246
|
-
if existing_release_directives:
|
|
247
|
-
release_directive_names = ", ".join(
|
|
248
|
-
row["name"] for row in existing_release_directives
|
|
249
|
-
)
|
|
250
|
-
cc.warning(
|
|
251
|
-
dedent(
|
|
252
|
-
f"""\
|
|
253
|
-
Version {version} already defined in application package {self.package_name} and in release directive(s): {release_directive_names}.
|
|
254
|
-
"""
|
|
255
|
-
)
|
|
256
|
-
)
|
|
257
|
-
|
|
258
|
-
user_prompt = (
|
|
259
|
-
f"Are you sure you want to create a new patch for version {version} in application "
|
|
260
|
-
f"package {self.package_name}? Once added, this operation cannot be undone."
|
|
261
|
-
)
|
|
262
|
-
if not policy.should_proceed(user_prompt):
|
|
263
|
-
if is_interactive:
|
|
264
|
-
cc.message("Not creating a new patch.")
|
|
265
|
-
raise typer.Exit(0)
|
|
266
|
-
else:
|
|
267
|
-
cc.message(
|
|
268
|
-
"Cannot create a new patch non-interactively without --force."
|
|
269
|
-
)
|
|
270
|
-
raise typer.Exit(1)
|
|
271
|
-
|
|
272
|
-
# Define a new version in the application package
|
|
273
|
-
if not self.get_existing_version_info(version):
|
|
274
|
-
self.add_new_version(version=version)
|
|
275
|
-
return # A new version created automatically has patch 0, we do not need to further increment the patch.
|
|
276
|
-
|
|
277
|
-
# Add a new patch to an existing (old) version
|
|
278
|
-
self.add_new_patch_to_version(version=version, patch=patch)
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
class NativeAppVersionDropProcessor(NativeAppManager, NativeAppCommandProcessor):
|
|
282
|
-
def __init__(self, project_definition: NativeApp, project_root: Path):
|
|
283
|
-
super().__init__(project_definition, project_root)
|
|
284
|
-
|
|
285
|
-
def process(
|
|
286
|
-
self,
|
|
287
|
-
version: Optional[str],
|
|
288
|
-
policy: PolicyBase,
|
|
289
|
-
is_interactive: bool,
|
|
290
|
-
*args,
|
|
291
|
-
**kwargs,
|
|
292
|
-
):
|
|
293
|
-
"""
|
|
294
|
-
Drops a version defined in an application package. If --force is provided, then no user prompts will be executed.
|
|
295
|
-
"""
|
|
296
|
-
|
|
297
|
-
# 1. Check for existing an existing application package
|
|
298
|
-
show_obj_row = self.get_existing_app_pkg_info()
|
|
299
|
-
if show_obj_row:
|
|
300
|
-
# Check for the right owner role
|
|
301
|
-
ensure_correct_owner(
|
|
302
|
-
row=show_obj_row, role=self.package_role, obj_name=self.package_name
|
|
303
|
-
)
|
|
304
|
-
else:
|
|
305
|
-
raise ApplicationPackageDoesNotExistError(self.package_name)
|
|
306
|
-
|
|
307
|
-
# 2. Check distribution of the existing application package
|
|
308
|
-
actual_distribution = self.get_app_pkg_distribution_in_snowflake
|
|
309
|
-
if not self.verify_project_distribution(actual_distribution):
|
|
310
|
-
cc.warning(
|
|
311
|
-
f"Continuing to execute `snow app version drop` on application package {self.package_name} with distribution '{actual_distribution}'."
|
|
312
|
-
)
|
|
313
|
-
|
|
314
|
-
# 3. If the user did not pass in a version string, determine from manifest.yml
|
|
315
|
-
if not version:
|
|
316
|
-
cc.message(
|
|
317
|
-
dedent(
|
|
318
|
-
f"""\
|
|
319
|
-
Version was not provided through the Snowflake CLI. Checking version in the manifest.yml instead.
|
|
320
|
-
This step will bundle your app artifacts to determine the location of the manifest.yml file.
|
|
321
|
-
"""
|
|
322
|
-
)
|
|
323
|
-
)
|
|
324
|
-
self.build_bundle()
|
|
325
|
-
version, _ = find_version_info_in_manifest_file(self.deploy_root)
|
|
326
|
-
if not version:
|
|
327
|
-
raise ClickException(
|
|
328
|
-
"Manifest.yml file does not contain a value for the version field."
|
|
329
|
-
)
|
|
330
|
-
|
|
331
|
-
cc.step(
|
|
332
|
-
dedent(
|
|
333
|
-
f"""\
|
|
334
|
-
About to drop version {version} in application package {self.package_name}.
|
|
335
|
-
"""
|
|
336
|
-
)
|
|
337
|
-
)
|
|
338
|
-
|
|
339
|
-
# If user did not provide --force, ask for confirmation
|
|
340
|
-
user_prompt = (
|
|
341
|
-
f"Are you sure you want to drop version {version} in application package {self.package_name}? Once dropped, this operation cannot be undone.",
|
|
342
|
-
)
|
|
343
|
-
if not policy.should_proceed(user_prompt):
|
|
344
|
-
if is_interactive:
|
|
345
|
-
cc.message("Not dropping version.")
|
|
346
|
-
raise typer.Exit(0)
|
|
347
|
-
else:
|
|
348
|
-
cc.message("Cannot drop version non-interactively without --force.")
|
|
349
|
-
raise typer.Exit(1)
|
|
350
|
-
|
|
351
|
-
# Drop the version
|
|
352
|
-
with self.use_role(self.package_role):
|
|
353
|
-
try:
|
|
354
|
-
self._execute_query(
|
|
355
|
-
f"alter application package {self.package_name} drop version {version}"
|
|
356
|
-
)
|
|
357
|
-
except ProgrammingError as err:
|
|
358
|
-
raise err # e.g. version is referenced in a release directive(s)
|
|
359
|
-
|
|
360
|
-
cc.message(
|
|
361
|
-
f"Version {version} in application package {self.package_name} dropped successfully."
|
|
362
|
-
)
|
|
@@ -1,15 +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
|
-
# TODO 3.0: remove this file
|
|
@@ -1,122 +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
|
-
# TODO 3.0: remove these commands
|
|
16
|
-
|
|
17
|
-
from __future__ import annotations
|
|
18
|
-
|
|
19
|
-
import typer
|
|
20
|
-
from snowflake.cli.api.commands.flags import (
|
|
21
|
-
PatternOption,
|
|
22
|
-
)
|
|
23
|
-
from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
|
|
24
|
-
from snowflake.cli.api.console import cli_console
|
|
25
|
-
from snowflake.cli.api.plugins.command import CommandPath
|
|
26
|
-
from snowflake.cli.plugins.stage.commands import (
|
|
27
|
-
StageNameArgument,
|
|
28
|
-
copy,
|
|
29
|
-
stage_create,
|
|
30
|
-
stage_diff,
|
|
31
|
-
stage_list_files,
|
|
32
|
-
stage_remove,
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
_deprecated_command_msg = (
|
|
36
|
-
f"`{CommandPath(['object', 'stage'])}` command group is deprecated."
|
|
37
|
-
f" Please use `{CommandPath(['stage'])}` instead."
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
app = SnowTyperFactory(name="stage", help="Manages stages.", deprecated=True)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
@app.callback()
|
|
44
|
-
def warn_command_deprecated() -> None:
|
|
45
|
-
cli_console.warning(_deprecated_command_msg)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
@app.command("list", requires_connection=True, deprecated=True)
|
|
49
|
-
def deprecated_stage_list(
|
|
50
|
-
stage_name: str = StageNameArgument, pattern=PatternOption, **options
|
|
51
|
-
):
|
|
52
|
-
"""
|
|
53
|
-
Lists the stage contents.
|
|
54
|
-
"""
|
|
55
|
-
return stage_list_files(stage_name=stage_name, pattern=pattern, **options)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
@app.command("copy", requires_connection=True, deprecated=True)
|
|
59
|
-
def deprecated_copy(
|
|
60
|
-
source_path: str = typer.Argument(
|
|
61
|
-
help="Source path for copy operation. Can be either stage path or local."
|
|
62
|
-
),
|
|
63
|
-
destination_path: str = typer.Argument(
|
|
64
|
-
help="Target directory path for copy operation. Should be stage if source is local or local if source is stage.",
|
|
65
|
-
),
|
|
66
|
-
overwrite: bool = typer.Option(
|
|
67
|
-
False,
|
|
68
|
-
help="Overwrites existing files in the target path.",
|
|
69
|
-
),
|
|
70
|
-
parallel: int = typer.Option(
|
|
71
|
-
4,
|
|
72
|
-
help="Number of parallel threads to use when uploading files.",
|
|
73
|
-
),
|
|
74
|
-
recursive: bool = typer.Option(
|
|
75
|
-
False,
|
|
76
|
-
help="Copy files recursively with directory structure.",
|
|
77
|
-
),
|
|
78
|
-
**options,
|
|
79
|
-
):
|
|
80
|
-
"""
|
|
81
|
-
Copies all files from target path to target directory. This works for both uploading
|
|
82
|
-
to and downloading files from the stage.
|
|
83
|
-
"""
|
|
84
|
-
copy(
|
|
85
|
-
source_path=source_path,
|
|
86
|
-
destination_path=destination_path,
|
|
87
|
-
overwrite=overwrite,
|
|
88
|
-
parallel=parallel,
|
|
89
|
-
recursive=recursive,
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
@app.command("create", requires_connection=True, deprecated=True)
|
|
94
|
-
def deprecated_stage_create(stage_name: str = StageNameArgument, **options):
|
|
95
|
-
"""
|
|
96
|
-
Creates a named stage if it does not already exist.
|
|
97
|
-
"""
|
|
98
|
-
stage_create(stage_name=stage_name, **options)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
@app.command("remove", requires_connection=True, deprecated=True)
|
|
102
|
-
def deprecated_stage_remove(
|
|
103
|
-
stage_name: str = StageNameArgument,
|
|
104
|
-
file_name: str = typer.Argument(..., help="Name of the file to remove."),
|
|
105
|
-
**options,
|
|
106
|
-
):
|
|
107
|
-
"""
|
|
108
|
-
Removes a file from a stage.
|
|
109
|
-
"""
|
|
110
|
-
stage_remove(stage_name=stage_name, file_name=file_name)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
@app.command("diff", hidden=True, requires_connection=True, deprecated=True)
|
|
114
|
-
def deprecated_stage_diff(
|
|
115
|
-
stage_name: str = typer.Argument(None, help="Fully qualified name of a stage"),
|
|
116
|
-
folder_name: str = typer.Argument(None, help="Path to local folder"),
|
|
117
|
-
**options,
|
|
118
|
-
):
|
|
119
|
-
"""
|
|
120
|
-
Diffs a stage with a local folder.
|
|
121
|
-
"""
|
|
122
|
-
return stage_diff(stage_name=stage_name, folder_name=folder_name, **options)
|
|
@@ -1,32 +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
|
-
# TODO 3.0: remove this file
|
|
16
|
-
|
|
17
|
-
from snowflake.cli.api.plugins.command import (
|
|
18
|
-
CommandPath,
|
|
19
|
-
CommandSpec,
|
|
20
|
-
CommandType,
|
|
21
|
-
plugin_hook_impl,
|
|
22
|
-
)
|
|
23
|
-
from snowflake.cli.plugins.object_stage_deprecated import commands
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
@plugin_hook_impl
|
|
27
|
-
def command_spec():
|
|
28
|
-
return CommandSpec(
|
|
29
|
-
parent_command_path=CommandPath(["object"]),
|
|
30
|
-
command_type=CommandType.COMMAND_GROUP,
|
|
31
|
-
typer_instance=commands.app.create_instance(),
|
|
32
|
-
)
|