snowflake-cli 2.8.2__py3-none-any.whl → 3.0.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.
- 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 +448 -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 -76
- snowflake/cli/{plugins → _plugins}/snowpark/package/manager.py +2 -2
- snowflake/cli/{plugins → _plugins}/snowpark/package_utils.py +32 -43
- 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 +176 -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-2.8.2.dist-info → snowflake_cli-3.0.2.dist-info}/METADATA +18 -18
- snowflake_cli-3.0.2.dist-info/RECORD +242 -0
- snowflake_cli-3.0.2.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-2.8.2.dist-info/RECORD +0 -240
- snowflake_cli-2.8.2.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-2.8.2.dist-info → snowflake_cli-3.0.2.dist-info}/WHEEL +0 -0
- {snowflake_cli-2.8.2.dist-info → snowflake_cli-3.0.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -19,17 +19,17 @@ import logging
|
|
|
19
19
|
from typing import Callable, Optional
|
|
20
20
|
|
|
21
21
|
from click import ClickException
|
|
22
|
-
from snowflake.cli.
|
|
23
|
-
from snowflake.cli.api.exceptions import SnowflakeSQLExecutionError
|
|
24
|
-
from snowflake.cli.api.secure_path import SecurePath
|
|
25
|
-
from snowflake.cli.api.sql_execution import SqlExecutionMixin
|
|
26
|
-
from snowflake.cli.plugins.cortex.types import (
|
|
22
|
+
from snowflake.cli._plugins.cortex.types import (
|
|
27
23
|
Language,
|
|
28
24
|
Model,
|
|
29
25
|
Question,
|
|
30
26
|
SourceDocument,
|
|
31
27
|
Text,
|
|
32
28
|
)
|
|
29
|
+
from snowflake.cli.api.constants import DEFAULT_SIZE_LIMIT_MB
|
|
30
|
+
from snowflake.cli.api.exceptions import SnowflakeSQLExecutionError
|
|
31
|
+
from snowflake.cli.api.secure_path import SecurePath
|
|
32
|
+
from snowflake.cli.api.sql_execution import SqlExecutionMixin
|
|
33
33
|
from snowflake.connector import ProgrammingError
|
|
34
34
|
from snowflake.connector.cursor import DictCursor
|
|
35
35
|
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
from snowflake.cli._plugins.cortex import commands
|
|
15
16
|
from snowflake.cli.api.plugins.command import (
|
|
16
17
|
SNOWCLI_ROOT_COMMAND_PATH,
|
|
17
18
|
CommandSpec,
|
|
18
19
|
CommandType,
|
|
19
20
|
plugin_hook_impl,
|
|
20
21
|
)
|
|
21
|
-
from snowflake.cli.plugins.cortex import commands
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
@plugin_hook_impl
|
|
@@ -22,6 +22,13 @@ from typing import Dict, List, Optional
|
|
|
22
22
|
|
|
23
23
|
import typer
|
|
24
24
|
from click import ClickException
|
|
25
|
+
from snowflake.cli._plugins.git.manager import GitManager
|
|
26
|
+
from snowflake.cli._plugins.object.command_aliases import (
|
|
27
|
+
add_object_command_aliases,
|
|
28
|
+
scope_option,
|
|
29
|
+
)
|
|
30
|
+
from snowflake.cli._plugins.object.manager import ObjectManager
|
|
31
|
+
from snowflake.cli.api.commands.common import OnErrorType
|
|
25
32
|
from snowflake.cli.api.commands.flags import (
|
|
26
33
|
ExecuteVariablesOption,
|
|
27
34
|
OnErrorOption,
|
|
@@ -34,13 +41,6 @@ from snowflake.cli.api.console.console import cli_console
|
|
|
34
41
|
from snowflake.cli.api.constants import ObjectType
|
|
35
42
|
from snowflake.cli.api.output.types import CollectionResult, CommandResult, QueryResult
|
|
36
43
|
from snowflake.cli.api.utils.path_utils import is_stage_path
|
|
37
|
-
from snowflake.cli.plugins.git.manager import GitManager
|
|
38
|
-
from snowflake.cli.plugins.object.command_aliases import (
|
|
39
|
-
add_object_command_aliases,
|
|
40
|
-
scope_option,
|
|
41
|
-
)
|
|
42
|
-
from snowflake.cli.plugins.object.manager import ObjectManager
|
|
43
|
-
from snowflake.cli.plugins.stage.manager import OnErrorType
|
|
44
44
|
from snowflake.connector import DictCursor
|
|
45
45
|
|
|
46
46
|
app = SnowTyperFactory(
|
|
@@ -72,6 +72,7 @@ RepoPathArgument = typer.Argument(
|
|
|
72
72
|
" For example: @my_repo/branches/main/"
|
|
73
73
|
),
|
|
74
74
|
callback=_repo_path_argument_callback,
|
|
75
|
+
show_default=False,
|
|
75
76
|
)
|
|
76
77
|
add_object_command_aliases(
|
|
77
78
|
app=app,
|
|
@@ -124,6 +125,8 @@ def setup(
|
|
|
124
125
|
"""
|
|
125
126
|
Sets up a git repository object.
|
|
126
127
|
|
|
128
|
+
## Usage notes
|
|
129
|
+
|
|
127
130
|
You will be prompted for:
|
|
128
131
|
|
|
129
132
|
* url - address of repository to be used for git clone operation
|
|
@@ -294,6 +297,7 @@ def copy(
|
|
|
294
297
|
repository_path: str = RepoPathArgument,
|
|
295
298
|
destination_path: str = typer.Argument(
|
|
296
299
|
help="Target path for copy operation. Should be a path to a directory on remote stage or local file system.",
|
|
300
|
+
show_default=False,
|
|
297
301
|
),
|
|
298
302
|
parallel: int = typer.Option(
|
|
299
303
|
4,
|
|
@@ -14,29 +14,36 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from pathlib import Path
|
|
17
|
+
from pathlib import Path, PurePosixPath
|
|
18
18
|
from textwrap import dedent
|
|
19
19
|
from typing import List
|
|
20
20
|
|
|
21
|
-
from
|
|
22
|
-
from snowflake.cli.
|
|
21
|
+
from click import UsageError
|
|
22
|
+
from snowflake.cli._plugins.stage.manager import (
|
|
23
23
|
USER_STAGE_PREFIX,
|
|
24
24
|
StageManager,
|
|
25
25
|
StagePathParts,
|
|
26
26
|
UserStagePathParts,
|
|
27
27
|
)
|
|
28
|
+
from snowflake.cli.api.identifiers import FQN
|
|
28
29
|
from snowflake.connector.cursor import SnowflakeCursor
|
|
29
30
|
|
|
31
|
+
# Replace magic numbers with constants
|
|
32
|
+
OMIT_FIRST = slice(1, None)
|
|
33
|
+
OMIT_STAGE = slice(3, None)
|
|
34
|
+
OMIT_STAGE_IN_NEW_LIST_FILES = slice(2, None)
|
|
35
|
+
ONLY_STAGE = slice(3)
|
|
36
|
+
|
|
30
37
|
|
|
31
38
|
class GitStagePathParts(StagePathParts):
|
|
32
39
|
def __init__(self, stage_path: str):
|
|
33
40
|
self.stage = GitManager.get_stage_from_path(stage_path)
|
|
34
|
-
stage_path_parts =
|
|
41
|
+
stage_path_parts = GitManager.split_git_path(stage_path)
|
|
35
42
|
git_repo_name = stage_path_parts[0].split(".")[-1]
|
|
36
43
|
if git_repo_name.startswith("@"):
|
|
37
|
-
git_repo_name = git_repo_name[
|
|
44
|
+
git_repo_name = git_repo_name[OMIT_FIRST]
|
|
38
45
|
self.stage_name = "/".join([git_repo_name, *stage_path_parts[1:3], ""])
|
|
39
|
-
self.directory = "/".join(stage_path_parts[
|
|
46
|
+
self.directory = "/".join(stage_path_parts[OMIT_STAGE])
|
|
40
47
|
self.is_directory = True if stage_path.endswith("/") else False
|
|
41
48
|
|
|
42
49
|
@property
|
|
@@ -45,7 +52,12 @@ class GitStagePathParts(StagePathParts):
|
|
|
45
52
|
|
|
46
53
|
@classmethod
|
|
47
54
|
def get_directory(cls, stage_path: str) -> str:
|
|
48
|
-
|
|
55
|
+
git_path_parts = GitManager.split_git_path(stage_path)
|
|
56
|
+
# New file list does not have a stage name at the beginning
|
|
57
|
+
if stage_path.startswith("/"):
|
|
58
|
+
return "/".join(git_path_parts[OMIT_STAGE_IN_NEW_LIST_FILES])
|
|
59
|
+
else:
|
|
60
|
+
return "/".join(git_path_parts[OMIT_STAGE])
|
|
49
61
|
|
|
50
62
|
@property
|
|
51
63
|
def full_path(self) -> str:
|
|
@@ -53,7 +65,7 @@ class GitStagePathParts(StagePathParts):
|
|
|
53
65
|
|
|
54
66
|
def replace_stage_prefix(self, file_path: str) -> str:
|
|
55
67
|
stage = Path(self.stage).parts[0]
|
|
56
|
-
file_path_without_prefix = Path(file_path).parts[
|
|
68
|
+
file_path_without_prefix = Path(file_path).parts[OMIT_FIRST]
|
|
57
69
|
return f"{stage}/{'/'.join(file_path_without_prefix)}"
|
|
58
70
|
|
|
59
71
|
def add_stage_prefix(self, file_path: str) -> str:
|
|
@@ -95,7 +107,8 @@ class GitManager(StageManager):
|
|
|
95
107
|
Returns stage name from potential path on stage. For example
|
|
96
108
|
repo/branches/main/foo/bar -> repo/branches/main/
|
|
97
109
|
"""
|
|
98
|
-
|
|
110
|
+
path_parts = GitManager.split_git_path(path)
|
|
111
|
+
return f"{'/'.join(path_parts[ONLY_STAGE])}/"
|
|
99
112
|
|
|
100
113
|
@staticmethod
|
|
101
114
|
def _stage_path_part_factory(stage_path: str) -> StagePathParts:
|
|
@@ -103,3 +116,36 @@ class GitManager(StageManager):
|
|
|
103
116
|
if stage_path.startswith(USER_STAGE_PREFIX):
|
|
104
117
|
return UserStagePathParts(stage_path)
|
|
105
118
|
return GitStagePathParts(stage_path)
|
|
119
|
+
|
|
120
|
+
@staticmethod
|
|
121
|
+
def split_git_path(path: str):
|
|
122
|
+
# Check if path contains quotes and split it accordingly
|
|
123
|
+
if '/"' in path and '"/' in path:
|
|
124
|
+
if path.count('"') > 2:
|
|
125
|
+
raise UsageError(
|
|
126
|
+
f'Invalid string {path}, too much " in path, expected 2.'
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
path_parts = path.split('"')
|
|
130
|
+
before_quoted_part = GitManager._split_path_without_empty_parts(
|
|
131
|
+
path_parts[0]
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
if path_parts[2] == "/":
|
|
135
|
+
after_quoted_part = []
|
|
136
|
+
else:
|
|
137
|
+
after_quoted_part = GitManager._split_path_without_empty_parts(
|
|
138
|
+
path_parts[2]
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
return [
|
|
142
|
+
*before_quoted_part,
|
|
143
|
+
f'"{path_parts[1]}"',
|
|
144
|
+
*after_quoted_part,
|
|
145
|
+
]
|
|
146
|
+
else:
|
|
147
|
+
return GitManager._split_path_without_empty_parts(path)
|
|
148
|
+
|
|
149
|
+
@staticmethod
|
|
150
|
+
def _split_path_without_empty_parts(path: str):
|
|
151
|
+
return [e for e in PurePosixPath(path).parts if e != "/"]
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
from snowflake.cli._plugins.git import commands
|
|
15
16
|
from snowflake.cli.api.plugins.command import (
|
|
16
17
|
SNOWCLI_ROOT_COMMAND_PATH,
|
|
17
18
|
CommandSpec,
|
|
18
19
|
CommandType,
|
|
19
20
|
plugin_hook_impl,
|
|
20
21
|
)
|
|
21
|
-
from snowflake.cli.plugins.git import commands
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
@plugin_hook_impl
|
|
@@ -0,0 +1,90 @@
|
|
|
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 typer
|
|
18
|
+
import yaml
|
|
19
|
+
from click import ClickException
|
|
20
|
+
from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
|
|
21
|
+
from snowflake.cli.api.output.types import MessageResult
|
|
22
|
+
from snowflake.cli.api.project.definition_conversion import (
|
|
23
|
+
convert_project_definition_to_v2,
|
|
24
|
+
)
|
|
25
|
+
from snowflake.cli.api.project.definition_manager import DefinitionManager
|
|
26
|
+
from snowflake.cli.api.secure_path import SecurePath
|
|
27
|
+
|
|
28
|
+
app = SnowTyperFactory(
|
|
29
|
+
name="helpers",
|
|
30
|
+
help="Helper commands.",
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@app.command()
|
|
35
|
+
def v1_to_v2(
|
|
36
|
+
accept_templates: bool = typer.Option(
|
|
37
|
+
False, "-t", "--accept-templates", help="Allows the migration of templates."
|
|
38
|
+
),
|
|
39
|
+
migrate_local_yml: (bool | None) = typer.Option(
|
|
40
|
+
None,
|
|
41
|
+
"-l",
|
|
42
|
+
"--migrate-local-overrides/--no-migrate-local-overrides",
|
|
43
|
+
help=(
|
|
44
|
+
"Merge values in snowflake.local.yml into the main project definition. "
|
|
45
|
+
"The snowflake.local.yml file will not be migrated, "
|
|
46
|
+
"instead its values will be reflected in the output snowflake.yml file. "
|
|
47
|
+
"If unset and snowflake.local.yml is present, an error will be raised."
|
|
48
|
+
),
|
|
49
|
+
show_default=False,
|
|
50
|
+
),
|
|
51
|
+
**options,
|
|
52
|
+
):
|
|
53
|
+
"""Migrates the Snowpark, Streamlit, and Native App project definition files from V1 to V2."""
|
|
54
|
+
manager = DefinitionManager()
|
|
55
|
+
local_yml_path = manager.project_root / "snowflake.local.yml"
|
|
56
|
+
has_local_yml = local_yml_path in manager.project_config_paths
|
|
57
|
+
if has_local_yml:
|
|
58
|
+
if migrate_local_yml is None:
|
|
59
|
+
raise ClickException(
|
|
60
|
+
"snowflake.local.yml file detected, "
|
|
61
|
+
"please specify --migrate-local-overrides to include "
|
|
62
|
+
"or --no-migrate-local-overrides to exclude its values."
|
|
63
|
+
)
|
|
64
|
+
if not migrate_local_yml:
|
|
65
|
+
# If we don't want the local file,
|
|
66
|
+
# remove it from the list of paths to load
|
|
67
|
+
manager.project_config_paths.remove(local_yml_path)
|
|
68
|
+
|
|
69
|
+
pd = manager.unrendered_project_definition
|
|
70
|
+
|
|
71
|
+
if pd.meets_version_requirement("2"):
|
|
72
|
+
return MessageResult("Project definition is already at version 2.")
|
|
73
|
+
|
|
74
|
+
pd_v2 = convert_project_definition_to_v2(
|
|
75
|
+
manager.project_root, pd, accept_templates, manager.template_context
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
SecurePath("snowflake.yml").rename("snowflake_V1.yml")
|
|
79
|
+
if has_local_yml:
|
|
80
|
+
SecurePath("snowflake.local.yml").rename("snowflake_V1.local.yml")
|
|
81
|
+
with open("snowflake.yml", "w") as file:
|
|
82
|
+
yaml.dump(
|
|
83
|
+
pd_v2.model_dump(
|
|
84
|
+
exclude_unset=True, exclude_none=True, mode="json", by_alias=True
|
|
85
|
+
),
|
|
86
|
+
file,
|
|
87
|
+
sort_keys=False,
|
|
88
|
+
width=float("inf"), # Don't break lines
|
|
89
|
+
)
|
|
90
|
+
return MessageResult("Project definition migrated to version 2.")
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
from snowflake.cli._plugins.helpers import commands
|
|
15
16
|
from snowflake.cli.api.plugins.command import (
|
|
16
17
|
SNOWCLI_ROOT_COMMAND_PATH,
|
|
17
18
|
CommandSpec,
|
|
18
19
|
CommandType,
|
|
19
20
|
plugin_hook_impl,
|
|
20
21
|
)
|
|
21
|
-
from snowflake.cli.plugins.notebook import commands
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
@plugin_hook_impl
|
|
@@ -23,10 +23,10 @@ from click import ClickException
|
|
|
23
23
|
from snowflake.cli.__about__ import VERSION
|
|
24
24
|
from snowflake.cli.api.commands.flags import (
|
|
25
25
|
NoInteractiveOption,
|
|
26
|
-
parse_key_value_variables,
|
|
27
26
|
variables_option,
|
|
28
27
|
)
|
|
29
28
|
from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
|
|
29
|
+
from snowflake.cli.api.commands.utils import parse_key_value_variables
|
|
30
30
|
from snowflake.cli.api.constants import DEFAULT_SIZE_LIMIT_MB
|
|
31
31
|
from snowflake.cli.api.exceptions import InvalidTemplate
|
|
32
32
|
from snowflake.cli.api.output.types import (
|
|
@@ -107,7 +107,7 @@ def _fetch_remote_template(
|
|
|
107
107
|
from git import rmtree as git_rmtree
|
|
108
108
|
|
|
109
109
|
# TODO: during nativeapp refactor get rid of this dependency
|
|
110
|
-
from snowflake.cli.
|
|
110
|
+
from snowflake.cli._plugins.nativeapp.utils import shallow_git_clone
|
|
111
111
|
|
|
112
112
|
log.info("Downloading remote template from %s", url)
|
|
113
113
|
try:
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
from snowflake.cli._plugins.init import commands
|
|
15
16
|
from snowflake.cli.api.plugins.command import (
|
|
16
17
|
SNOWCLI_ROOT_COMMAND_PATH,
|
|
17
18
|
CommandSpec,
|
|
18
19
|
CommandType,
|
|
19
20
|
plugin_hook_impl,
|
|
20
21
|
)
|
|
21
|
-
from snowflake.cli.plugins.init import commands
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
@plugin_hook_impl
|
|
@@ -22,7 +22,8 @@ from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Tupl
|
|
|
22
22
|
|
|
23
23
|
from click.exceptions import ClickException
|
|
24
24
|
from snowflake.cli.api.constants import DEFAULT_SIZE_LIMIT_MB
|
|
25
|
-
from snowflake.cli.api.project.schemas.native_app.path_mapping import PathMapping
|
|
25
|
+
from snowflake.cli.api.project.schemas.v1.native_app.path_mapping import PathMapping
|
|
26
|
+
from snowflake.cli.api.project.util import to_identifier
|
|
26
27
|
from snowflake.cli.api.secure_path import SecurePath
|
|
27
28
|
from yaml import safe_load
|
|
28
29
|
|
|
@@ -199,6 +200,12 @@ class _ArtifactPathMap:
|
|
|
199
200
|
"""
|
|
200
201
|
return self.__src_to_dest.keys()
|
|
201
202
|
|
|
203
|
+
def is_empty(self) -> bool:
|
|
204
|
+
"""
|
|
205
|
+
Returns True if this map has no source-destination mappings.
|
|
206
|
+
"""
|
|
207
|
+
return len(self.__src_dest_pairs) == 0
|
|
208
|
+
|
|
202
209
|
def __iter__(self) -> Iterator[Tuple[Path, Path]]:
|
|
203
210
|
"""
|
|
204
211
|
Returns all (source, destination) pairs known to this map, in insertion order.
|
|
@@ -240,6 +247,9 @@ class BundleMap:
|
|
|
240
247
|
self._deploy_root: Path = resolve_without_follow(deploy_root)
|
|
241
248
|
self._artifact_map = _ArtifactPathMap(project_root=self._project_root)
|
|
242
249
|
|
|
250
|
+
def is_empty(self) -> bool:
|
|
251
|
+
return self._artifact_map.is_empty()
|
|
252
|
+
|
|
243
253
|
def deploy_root(self) -> Path:
|
|
244
254
|
return self._deploy_root
|
|
245
255
|
|
|
@@ -658,6 +668,11 @@ def build_bundle(
|
|
|
658
668
|
for artifact in artifacts:
|
|
659
669
|
bundle_map.add(artifact)
|
|
660
670
|
|
|
671
|
+
if bundle_map.is_empty():
|
|
672
|
+
raise ArtifactError(
|
|
673
|
+
"No artifacts mapping found in project definition, nothing to do."
|
|
674
|
+
)
|
|
675
|
+
|
|
661
676
|
for (absolute_src, absolute_dest) in bundle_map.all_mappings(
|
|
662
677
|
absolute=True, expand_directories=False
|
|
663
678
|
):
|
|
@@ -720,23 +735,23 @@ def find_setup_script_file(deploy_root: Path) -> Path:
|
|
|
720
735
|
|
|
721
736
|
def find_version_info_in_manifest_file(
|
|
722
737
|
deploy_root: Path,
|
|
723
|
-
) -> Tuple[Optional[str], Optional[
|
|
738
|
+
) -> Tuple[Optional[str], Optional[int]]:
|
|
724
739
|
"""
|
|
725
740
|
Find version and patch, if available, in the manifest.yml file.
|
|
726
741
|
"""
|
|
727
|
-
version_field = "version"
|
|
728
742
|
name_field = "name"
|
|
729
743
|
patch_field = "patch"
|
|
730
744
|
|
|
731
745
|
manifest_content = find_and_read_manifest_file(deploy_root=deploy_root)
|
|
732
746
|
|
|
733
747
|
version_name: Optional[str] = None
|
|
734
|
-
|
|
748
|
+
patch_number: Optional[int] = None
|
|
735
749
|
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
750
|
+
version_info = manifest_content.get("version", None)
|
|
751
|
+
if version_info:
|
|
752
|
+
if name_field in version_info:
|
|
753
|
+
version_name = to_identifier(str(version_info[name_field]))
|
|
739
754
|
if patch_field in version_info:
|
|
740
|
-
|
|
755
|
+
patch_number = int(version_info[patch_field])
|
|
741
756
|
|
|
742
|
-
return version_name,
|
|
757
|
+
return version_name, patch_number
|
|
@@ -0,0 +1,31 @@
|
|
|
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 dataclasses import dataclass
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
from typing import (
|
|
18
|
+
List,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
from snowflake.cli.api.project.schemas.v1.native_app.path_mapping import PathMapping
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass
|
|
25
|
+
class BundleContext:
|
|
26
|
+
package_name: str
|
|
27
|
+
artifacts: List[PathMapping]
|
|
28
|
+
project_root: Path
|
|
29
|
+
bundle_root: Path
|
|
30
|
+
deploy_root: Path
|
|
31
|
+
generated_root: Path
|
|
@@ -19,11 +19,11 @@ from pathlib import Path
|
|
|
19
19
|
from typing import Optional
|
|
20
20
|
|
|
21
21
|
from click import ClickException
|
|
22
|
-
from snowflake.cli.
|
|
22
|
+
from snowflake.cli._plugins.nativeapp.bundle_context import BundleContext
|
|
23
|
+
from snowflake.cli.api.project.schemas.v1.native_app.path_mapping import (
|
|
23
24
|
PathMapping,
|
|
24
25
|
ProcessorMapping,
|
|
25
26
|
)
|
|
26
|
-
from snowflake.cli.plugins.nativeapp.project_model import NativeAppProjectModel
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
class UnsupportedArtifactProcessorError(ClickException):
|
|
@@ -74,9 +74,9 @@ class ProjectFileContextManager:
|
|
|
74
74
|
class ArtifactProcessor(ABC):
|
|
75
75
|
def __init__(
|
|
76
76
|
self,
|
|
77
|
-
|
|
77
|
+
bundle_ctx: BundleContext,
|
|
78
78
|
) -> None:
|
|
79
|
-
self.
|
|
79
|
+
self._bundle_ctx = bundle_ctx
|
|
80
80
|
|
|
81
81
|
@abstractmethod
|
|
82
82
|
def process(
|
|
@@ -14,31 +14,41 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
+
import copy
|
|
18
|
+
import re
|
|
17
19
|
from typing import Dict, Optional
|
|
18
20
|
|
|
19
|
-
from
|
|
20
|
-
from snowflake.cli.
|
|
21
|
-
|
|
22
|
-
)
|
|
23
|
-
from snowflake.cli.plugins.nativeapp.codegen.artifact_processor import (
|
|
21
|
+
from click import ClickException
|
|
22
|
+
from snowflake.cli._plugins.nativeapp.bundle_context import BundleContext
|
|
23
|
+
from snowflake.cli._plugins.nativeapp.codegen.artifact_processor import (
|
|
24
24
|
ArtifactProcessor,
|
|
25
25
|
UnsupportedArtifactProcessorError,
|
|
26
26
|
)
|
|
27
|
-
from snowflake.cli.
|
|
27
|
+
from snowflake.cli._plugins.nativeapp.codegen.setup.native_app_setup_processor import (
|
|
28
28
|
NativeAppSetupProcessor,
|
|
29
29
|
)
|
|
30
|
-
from snowflake.cli.
|
|
30
|
+
from snowflake.cli._plugins.nativeapp.codegen.snowpark.python_processor import (
|
|
31
31
|
SnowparkAnnotationProcessor,
|
|
32
32
|
)
|
|
33
|
-
from snowflake.cli.
|
|
34
|
-
|
|
33
|
+
from snowflake.cli._plugins.nativeapp.codegen.templates.templates_processor import (
|
|
34
|
+
TemplatesProcessor,
|
|
35
|
+
)
|
|
36
|
+
from snowflake.cli._plugins.nativeapp.feature_flags import FeatureFlag
|
|
37
|
+
from snowflake.cli.api.cli_global_context import get_cli_context
|
|
38
|
+
from snowflake.cli.api.console import cli_console as cc
|
|
39
|
+
from snowflake.cli.api.metrics import CLICounterField
|
|
40
|
+
from snowflake.cli.api.project.schemas.v1.native_app.path_mapping import (
|
|
41
|
+
ProcessorMapping,
|
|
42
|
+
)
|
|
35
43
|
|
|
36
44
|
SNOWPARK_PROCESSOR = "snowpark"
|
|
37
|
-
NA_SETUP_PROCESSOR = "native
|
|
45
|
+
NA_SETUP_PROCESSOR = "native app setup"
|
|
46
|
+
TEMPLATES_PROCESSOR = "templates"
|
|
38
47
|
|
|
39
48
|
_REGISTERED_PROCESSORS_BY_NAME = {
|
|
40
49
|
SNOWPARK_PROCESSOR: SnowparkAnnotationProcessor,
|
|
41
50
|
NA_SETUP_PROCESSOR: NativeAppSetupProcessor,
|
|
51
|
+
TEMPLATES_PROCESSOR: TemplatesProcessor,
|
|
42
52
|
}
|
|
43
53
|
|
|
44
54
|
|
|
@@ -53,9 +63,9 @@ class NativeAppCompiler:
|
|
|
53
63
|
|
|
54
64
|
def __init__(
|
|
55
65
|
self,
|
|
56
|
-
|
|
66
|
+
bundle_ctx: BundleContext,
|
|
57
67
|
):
|
|
58
|
-
self.
|
|
68
|
+
self._bundle_ctx = bundle_ctx
|
|
59
69
|
# dictionary of all processors created and shared between different artifact objects.
|
|
60
70
|
self.cached_processors: Dict[str, ArtifactProcessor] = {}
|
|
61
71
|
|
|
@@ -64,17 +74,20 @@ class NativeAppCompiler:
|
|
|
64
74
|
Go through every artifact object in the project definition of a native app, and execute processors in order of specification for each of the artifact object.
|
|
65
75
|
May have side-effects on the filesystem by either directly editing source files or the deploy root.
|
|
66
76
|
"""
|
|
77
|
+
metrics = get_cli_context().metrics
|
|
78
|
+
metrics.set_counter_default(CLICounterField.TEMPLATES_PROCESSOR, 0)
|
|
79
|
+
metrics.set_counter_default(CLICounterField.SNOWPARK_PROCESSOR, 0)
|
|
67
80
|
|
|
68
81
|
if not self._should_invoke_processors():
|
|
69
82
|
return
|
|
70
83
|
|
|
71
84
|
with cc.phase("Invoking artifact processors"):
|
|
72
|
-
if self.
|
|
85
|
+
if self._bundle_ctx.generated_root.exists():
|
|
73
86
|
raise ClickException(
|
|
74
|
-
f"Path {self.
|
|
87
|
+
f"Path {self._bundle_ctx.generated_root} already exists. Please choose a different name for your generated directory in the project definition file."
|
|
75
88
|
)
|
|
76
89
|
|
|
77
|
-
for artifact in self.
|
|
90
|
+
for artifact in self._bundle_ctx.artifacts:
|
|
78
91
|
for processor in artifact.processors:
|
|
79
92
|
if self._is_enabled(processor):
|
|
80
93
|
artifact_processor = self._try_create_processor(
|
|
@@ -110,15 +123,21 @@ class NativeAppCompiler:
|
|
|
110
123
|
# No registered processor with the specified name
|
|
111
124
|
return None
|
|
112
125
|
|
|
113
|
-
|
|
114
|
-
|
|
126
|
+
processor_ctx = copy.copy(self._bundle_ctx)
|
|
127
|
+
processor_subdirectory = re.sub(r"[^a-zA-Z0-9_$]", "_", processor_name)
|
|
128
|
+
processor_ctx.bundle_root = (
|
|
129
|
+
self._bundle_ctx.bundle_root / processor_subdirectory
|
|
130
|
+
)
|
|
131
|
+
processor_ctx.generated_root = (
|
|
132
|
+
self._bundle_ctx.generated_root / processor_subdirectory
|
|
115
133
|
)
|
|
134
|
+
current_processor = processor_factory(processor_ctx)
|
|
116
135
|
self.cached_processors[processor_name] = current_processor
|
|
117
136
|
|
|
118
137
|
return current_processor
|
|
119
138
|
|
|
120
139
|
def _should_invoke_processors(self):
|
|
121
|
-
for artifact in self.
|
|
140
|
+
for artifact in self._bundle_ctx.artifacts:
|
|
122
141
|
for processor in artifact.processors:
|
|
123
142
|
if self._is_enabled(processor):
|
|
124
143
|
return True
|