snowflake-cli-labs 2.8.0rc1__py3-none-any.whl → 3.0.0rc0__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 +12 -12
- snowflake/cli/{app → _app}/commands_registration/builtin_plugins.py +13 -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 → _app}/snow_connector.py +6 -6
- snowflake/cli/{app → _app}/telemetry.py +4 -5
- snowflake/cli/{plugins → _plugins}/connection/commands.py +22 -5
- 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 +32 -20
- snowflake/cli/{plugins → _plugins}/git/manager.py +6 -5
- snowflake/cli/{plugins → _plugins}/git/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/init/commands.py +10 -6
- snowflake/cli/{plugins → _plugins}/init/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/nativeapp/artifacts.py +14 -0
- snowflake/cli/_plugins/nativeapp/bundle_context.py +31 -0
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/artifact_processor.py +3 -3
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/compiler.py +16 -18
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/setup/native_app_setup_processor.py +24 -28
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/extension_function_utils.py +4 -4
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/python_processor.py +20 -24
- snowflake/cli/{plugins → _plugins}/nativeapp/commands.py +171 -42
- snowflake/cli/{plugins → _plugins}/nativeapp/common_flags.py +1 -1
- snowflake/cli/{plugins → _plugins}/nativeapp/init.py +1 -1
- snowflake/cli/_plugins/nativeapp/manager.py +601 -0
- snowflake/cli/{plugins/connection → _plugins/nativeapp}/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/nativeapp/project_model.py +34 -11
- snowflake/cli/{plugins → _plugins}/nativeapp/run_processor.py +25 -23
- snowflake/cli/{plugins → _plugins}/nativeapp/teardown_processor.py +8 -8
- snowflake/cli/{plugins → _plugins}/nativeapp/v2_conversions/v2_to_v1_decorator.py +47 -28
- snowflake/cli/{plugins → _plugins}/nativeapp/version/commands.py +15 -12
- snowflake/cli/{plugins → _plugins}/nativeapp/version/version_processor.py +22 -20
- snowflake/cli/{plugins → _plugins}/notebook/commands.py +8 -6
- snowflake/cli/{plugins → _plugins}/notebook/manager.py +14 -14
- snowflake/cli/{plugins → _plugins}/notebook/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/notebook/types.py +0 -1
- snowflake/cli/{plugins → _plugins}/object/command_aliases.py +6 -5
- snowflake/cli/{plugins → _plugins}/object/commands.py +16 -10
- snowflake/cli/{plugins → _plugins}/object/manager.py +7 -6
- snowflake/cli/{plugins → _plugins}/object/plugin_spec.py +1 -1
- snowflake/cli/_plugins/snowpark/commands.py +510 -0
- snowflake/cli/_plugins/snowpark/common.py +252 -0
- snowflake/cli/{plugins → _plugins}/snowpark/models.py +0 -7
- snowflake/cli/{plugins → _plugins}/snowpark/package/anaconda_packages.py +1 -1
- snowflake/cli/{plugins → _plugins}/snowpark/package/commands.py +13 -74
- snowflake/cli/{plugins → _plugins}/snowpark/package/manager.py +4 -3
- snowflake/cli/{plugins → _plugins}/snowpark/package_utils.py +5 -5
- snowflake/cli/{plugins/nativeapp → _plugins/snowpark}/plugin_spec.py +1 -1
- 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 +29 -28
- 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 +25 -19
- 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 +66 -32
- snowflake/cli/{plugins → _plugins}/spcs/services/manager.py +43 -5
- snowflake/cli/{plugins → _plugins}/sql/commands.py +19 -15
- 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 +20 -17
- snowflake/cli/{plugins → _plugins}/stage/diff.py +1 -47
- snowflake/cli/{plugins → _plugins}/stage/manager.py +8 -6
- snowflake/cli/{plugins → _plugins}/stage/plugin_spec.py +1 -1
- snowflake/cli/_plugins/stage/utils.py +54 -0
- snowflake/cli/_plugins/streamlit/commands.py +242 -0
- snowflake/cli/{plugins → _plugins}/streamlit/manager.py +47 -70
- snowflake/cli/_plugins/streamlit/plugin_spec.py +30 -0
- snowflake/cli/_plugins/workspace/action_context.py +11 -0
- snowflake/cli/_plugins/workspace/commands.py +113 -0
- snowflake/cli/_plugins/workspace/manager.py +57 -0
- snowflake/cli/{plugins → _plugins}/workspace/plugin_spec.py +1 -1
- snowflake/cli/api/cli_global_context.py +34 -7
- snowflake/cli/api/commands/common.py +25 -0
- snowflake/cli/api/commands/decorators.py +4 -3
- snowflake/cli/api/commands/experimental_behaviour.py +2 -3
- snowflake/cli/api/commands/flags.py +73 -174
- snowflake/cli/api/commands/overrideable_parameter.py +143 -0
- snowflake/cli/api/commands/snow_typer.py +5 -4
- snowflake/cli/api/commands/typer_pre_execute.py +3 -3
- snowflake/cli/api/commands/utils.py +18 -0
- snowflake/cli/api/config.py +1 -1
- snowflake/cli/api/console/abc.py +5 -2
- snowflake/cli/api/entities/application_entity.py +12 -0
- snowflake/cli/api/entities/application_package_entity.py +260 -0
- snowflake/cli/api/entities/common.py +47 -0
- snowflake/cli/api/entities/snowpark_entity.py +29 -0
- snowflake/cli/api/entities/streamlit_entity.py +12 -0
- snowflake/cli/api/entities/utils.py +321 -0
- snowflake/cli/api/exceptions.py +19 -3
- snowflake/cli/api/feature_flags.py +2 -1
- snowflake/cli/api/identifiers.py +41 -9
- snowflake/cli/api/project/definition.py +13 -5
- snowflake/cli/api/project/definition_manager.py +12 -1
- snowflake/cli/api/project/project_verification.py +3 -3
- snowflake/cli/api/project/schemas/entities/{application_entity.py → application_entity_model.py} +21 -9
- snowflake/cli/api/project/schemas/entities/{application_package_entity.py → application_package_entity_model.py} +26 -15
- snowflake/cli/api/project/schemas/entities/common.py +80 -6
- snowflake/cli/api/project/schemas/entities/entities.py +38 -8
- snowflake/cli/api/project/schemas/entities/snowpark_entity.py +176 -0
- snowflake/cli/api/project/schemas/entities/streamlit_entity_model.py +73 -0
- snowflake/cli/api/project/schemas/identifier_model.py +10 -1
- snowflake/cli/api/project/schemas/native_app/application.py +8 -9
- snowflake/cli/api/project/schemas/native_app/package.py +7 -1
- snowflake/cli/api/project/schemas/project_definition.py +97 -23
- snowflake/cli/api/project/schemas/updatable_model.py +11 -3
- snowflake/cli/api/project/util.py +23 -6
- snowflake/cli/api/rendering/jinja.py +28 -8
- snowflake/cli/api/rendering/sql_templates.py +41 -12
- snowflake/cli/api/secure_path.py +3 -0
- snowflake/cli/api/sql_execution.py +35 -19
- snowflake/cli/api/utils/definition_rendering.py +14 -2
- {snowflake_cli_labs-2.8.0rc1.dist-info → snowflake_cli_labs-3.0.0rc0.dist-info}/METADATA +12 -12
- snowflake_cli_labs-3.0.0rc0.dist-info/RECORD +234 -0
- snowflake_cli_labs-3.0.0rc0.dist-info/entry_points.txt +2 -0
- snowflake/cli/api/commands/project_initialisation.py +0 -65
- snowflake/cli/app/build_and_push.sh +0 -8
- snowflake/cli/plugins/nativeapp/manager.py +0 -823
- 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 -548
- 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/commands.py +0 -186
- snowflake/cli/plugins/streamlit/plugin_spec.py +0 -30
- snowflake/cli/plugins/workspace/commands.py +0 -35
- 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.0rc1.dist-info/RECORD +0 -240
- snowflake_cli_labs-2.8.0rc1.dist-info/entry_points.txt +0 -2
- /snowflake/cli/{app → _app}/__init__.py +0 -0
- /snowflake/cli/{app → _app}/api_impl/__init__.py +0 -0
- /snowflake/cli/{app → _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/{app → _app}/dev/__init__.py +0 -0
- /snowflake/cli/{app → _app}/dev/commands_structure.py +0 -0
- /snowflake/cli/{app → _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/{plugins → _plugins}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/connection/__init__.py +0 -0
- /snowflake/cli/{plugins → _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 → _plugins}/init/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/codegen/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/codegen/sandbox.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/codegen/setup/setup_driver.py.source +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/callback_source.py.jinja +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/models.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/constants.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/exceptions.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/feature_flags.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/policy.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/utils.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/version/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/notebook/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/notebook/exceptions.py +0 -0
- /snowflake/cli/{plugins → _plugins}/object/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/object/common.py +0 -0
- /snowflake/cli/{plugins → _plugins}/snowpark/__init__.py +0 -0
- /snowflake/cli/{plugins → _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 → _plugins}/spcs/compute_pool/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/spcs/image_registry/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/spcs/image_registry/manager.py +0 -0
- /snowflake/cli/{plugins → _plugins}/spcs/image_repository/__init__.py +0 -0
- /snowflake/cli/{plugins/spcs/jobs → _plugins/spcs/services}/__init__.py +0 -0
- /snowflake/cli/{plugins/spcs/services → _plugins/sql}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/sql/snowsql_templating.py +0 -0
- /snowflake/cli/{plugins/sql → _plugins/stage}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/stage/md5.py +0 -0
- /snowflake/cli/{plugins/stage → _plugins/streamlit}/__init__.py +0 -0
- /snowflake/cli/{plugins/streamlit → _plugins/workspace}/__init__.py +0 -0
- /snowflake/cli/{plugins/workspace → api/project/schemas/entities}/__init__.py +0 -0
- {snowflake_cli_labs-2.8.0rc1.dist-info → snowflake_cli_labs-3.0.0rc0.dist-info}/WHEEL +0 -0
- {snowflake_cli_labs-2.8.0rc1.dist-info → snowflake_cli_labs-3.0.0rc0.dist-info}/licenses/LICENSE +0 -0
snowflake/cli/__about__.py
CHANGED
|
@@ -25,24 +25,24 @@ import click
|
|
|
25
25
|
import typer
|
|
26
26
|
from click import Context
|
|
27
27
|
from snowflake.cli import __about__
|
|
28
|
-
from snowflake.cli.
|
|
29
|
-
from snowflake.cli.api.config import config_init
|
|
30
|
-
from snowflake.cli.api.output.formats import OutputFormat
|
|
31
|
-
from snowflake.cli.api.output.types import CollectionResult
|
|
32
|
-
from snowflake.cli.api.secure_path import SecurePath
|
|
33
|
-
from snowflake.cli.app.api_impl.plugin.plugin_config_provider_impl import (
|
|
28
|
+
from snowflake.cli._app.api_impl.plugin.plugin_config_provider_impl import (
|
|
34
29
|
PluginConfigProviderImpl,
|
|
35
30
|
)
|
|
36
|
-
from snowflake.cli.
|
|
31
|
+
from snowflake.cli._app.commands_registration.commands_registration_with_callbacks import (
|
|
37
32
|
CommandsRegistrationWithCallbacks,
|
|
38
33
|
)
|
|
39
|
-
from snowflake.cli.
|
|
40
|
-
from snowflake.cli.
|
|
41
|
-
from snowflake.cli.
|
|
34
|
+
from snowflake.cli._app.dev.commands_structure import generate_commands_structure
|
|
35
|
+
from snowflake.cli._app.dev.docs.generator import generate_docs
|
|
36
|
+
from snowflake.cli._app.dev.pycharm_remote_debug import (
|
|
42
37
|
setup_pycharm_remote_debugger_if_provided,
|
|
43
38
|
)
|
|
44
|
-
from snowflake.cli.
|
|
45
|
-
from snowflake.cli.
|
|
39
|
+
from snowflake.cli._app.main_typer import SnowCliMainTyper
|
|
40
|
+
from snowflake.cli._app.printing import MessageResult, print_result
|
|
41
|
+
from snowflake.cli.api import Api, api_provider
|
|
42
|
+
from snowflake.cli.api.config import config_init
|
|
43
|
+
from snowflake.cli.api.output.formats import OutputFormat
|
|
44
|
+
from snowflake.cli.api.output.types import CollectionResult
|
|
45
|
+
from snowflake.cli.api.secure_path import SecurePath
|
|
46
46
|
from snowflake.connector.config_manager import CONFIG_MANAGER
|
|
47
47
|
|
|
48
48
|
log = logging.getLogger(__name__)
|
|
@@ -12,24 +12,19 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from snowflake.cli.
|
|
16
|
-
from snowflake.cli.
|
|
17
|
-
from snowflake.cli.
|
|
18
|
-
from snowflake.cli.
|
|
19
|
-
from snowflake.cli.
|
|
20
|
-
from snowflake.cli.
|
|
21
|
-
from snowflake.cli.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
from snowflake.cli.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
from snowflake.cli.
|
|
28
|
-
from snowflake.cli.plugins.spcs import plugin_spec as spcs_plugin_spec
|
|
29
|
-
from snowflake.cli.plugins.sql import plugin_spec as sql_plugin_spec
|
|
30
|
-
from snowflake.cli.plugins.stage import plugin_spec as stage_plugin_spec
|
|
31
|
-
from snowflake.cli.plugins.streamlit import plugin_spec as streamlit_plugin_spec
|
|
32
|
-
from snowflake.cli.plugins.workspace import plugin_spec as workspace_plugin_spec
|
|
15
|
+
from snowflake.cli._plugins.connection import plugin_spec as connection_plugin_spec
|
|
16
|
+
from snowflake.cli._plugins.cortex import plugin_spec as cortex_plugin_spec
|
|
17
|
+
from snowflake.cli._plugins.git import plugin_spec as git_plugin_spec
|
|
18
|
+
from snowflake.cli._plugins.init import plugin_spec as init_plugin_spec
|
|
19
|
+
from snowflake.cli._plugins.nativeapp import plugin_spec as nativeapp_plugin_spec
|
|
20
|
+
from snowflake.cli._plugins.notebook import plugin_spec as notebook_plugin_spec
|
|
21
|
+
from snowflake.cli._plugins.object import plugin_spec as object_plugin_spec
|
|
22
|
+
from snowflake.cli._plugins.snowpark import plugin_spec as snowpark_plugin_spec
|
|
23
|
+
from snowflake.cli._plugins.spcs import plugin_spec as spcs_plugin_spec
|
|
24
|
+
from snowflake.cli._plugins.sql import plugin_spec as sql_plugin_spec
|
|
25
|
+
from snowflake.cli._plugins.stage import plugin_spec as stage_plugin_spec
|
|
26
|
+
from snowflake.cli._plugins.streamlit import plugin_spec as streamlit_plugin_spec
|
|
27
|
+
from snowflake.cli._plugins.workspace import plugin_spec as workspace_plugin_spec
|
|
33
28
|
|
|
34
29
|
|
|
35
30
|
# plugin name to plugin spec
|
|
@@ -45,7 +40,6 @@ def get_builtin_plugin_name_to_plugin_spec():
|
|
|
45
40
|
"streamlit": streamlit_plugin_spec,
|
|
46
41
|
"git": git_plugin_spec,
|
|
47
42
|
"notebook": notebook_plugin_spec,
|
|
48
|
-
"object-stage-deprecated": object_stage_deprecated_plugin_spec,
|
|
49
43
|
"cortex": cortex_plugin_spec,
|
|
50
44
|
"init": init_plugin_spec,
|
|
51
45
|
"workspace": workspace_plugin_spec,
|
|
@@ -18,21 +18,21 @@ import logging
|
|
|
18
18
|
from typing import Dict, List, Optional
|
|
19
19
|
|
|
20
20
|
import pluggy
|
|
21
|
-
from snowflake.cli.
|
|
22
|
-
SNOWCLI_COMMAND_PLUGIN_NAMESPACE,
|
|
23
|
-
CommandPath,
|
|
24
|
-
CommandSpec,
|
|
25
|
-
plugin_hook_specs,
|
|
26
|
-
)
|
|
27
|
-
from snowflake.cli.app.commands_registration import (
|
|
21
|
+
from snowflake.cli._app.commands_registration import (
|
|
28
22
|
LoadedBuiltInCommandPlugin,
|
|
29
23
|
LoadedCommandPlugin,
|
|
30
24
|
LoadedExternalCommandPlugin,
|
|
31
25
|
)
|
|
32
|
-
from snowflake.cli.
|
|
26
|
+
from snowflake.cli._app.commands_registration.builtin_plugins import (
|
|
33
27
|
get_builtin_plugin_name_to_plugin_spec,
|
|
34
28
|
)
|
|
35
|
-
from snowflake.cli.
|
|
29
|
+
from snowflake.cli._app.commands_registration.exception_logging import exception_logging
|
|
30
|
+
from snowflake.cli.api.plugins.command import (
|
|
31
|
+
SNOWCLI_COMMAND_PLUGIN_NAMESPACE,
|
|
32
|
+
CommandPath,
|
|
33
|
+
CommandSpec,
|
|
34
|
+
plugin_hook_specs,
|
|
35
|
+
)
|
|
36
36
|
|
|
37
37
|
log = logging.getLogger(__name__)
|
|
38
38
|
log_exception = exception_logging(log)
|
|
@@ -17,15 +17,15 @@ from __future__ import annotations
|
|
|
17
17
|
from dataclasses import dataclass
|
|
18
18
|
from typing import Callable, List
|
|
19
19
|
|
|
20
|
-
from snowflake.cli.
|
|
21
|
-
from snowflake.cli.app.commands_registration.command_plugins_loader import (
|
|
20
|
+
from snowflake.cli._app.commands_registration.command_plugins_loader import (
|
|
22
21
|
load_builtin_and_external_command_plugins,
|
|
23
22
|
load_only_builtin_command_plugins,
|
|
24
23
|
)
|
|
25
|
-
from snowflake.cli.
|
|
26
|
-
from snowflake.cli.
|
|
24
|
+
from snowflake.cli._app.commands_registration.threadsafe import ThreadsafeCounter
|
|
25
|
+
from snowflake.cli._app.commands_registration.typer_registration import (
|
|
27
26
|
register_commands_from_plugins,
|
|
28
27
|
)
|
|
28
|
+
from snowflake.cli.api.plugins.plugin_config import PluginConfigProvider
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
@dataclass
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
from logging import Logger
|
|
16
16
|
from typing import Callable
|
|
17
17
|
|
|
18
|
-
from snowflake.cli.api.cli_global_context import
|
|
18
|
+
from snowflake.cli.api.cli_global_context import get_cli_context
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
def exception_logging(logger: Logger) -> Callable[[str, Exception], None]:
|
|
22
22
|
def log_error(msg: str, exception: Exception) -> None:
|
|
23
|
-
exc_info = exception if
|
|
23
|
+
exc_info = exception if get_cli_context().enable_tracebacks else None
|
|
24
24
|
logger.error(msg=msg, exc_info=exc_info)
|
|
25
25
|
|
|
26
26
|
return log_error
|
|
@@ -18,9 +18,9 @@ import logging
|
|
|
18
18
|
from typing import List
|
|
19
19
|
|
|
20
20
|
import click
|
|
21
|
+
from snowflake.cli._app.commands_registration import LoadedCommandPlugin
|
|
22
|
+
from snowflake.cli._app.commands_registration.exception_logging import exception_logging
|
|
21
23
|
from snowflake.cli.api.plugins.command import CommandSpec, CommandType
|
|
22
|
-
from snowflake.cli.app.commands_registration import LoadedCommandPlugin
|
|
23
|
-
from snowflake.cli.app.commands_registration.exception_logging import exception_logging
|
|
24
24
|
from typer.core import TyperGroup
|
|
25
25
|
|
|
26
26
|
log = logging.getLogger(__name__)
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
17
|
import logging
|
|
18
|
-
from typing import List, Optional
|
|
18
|
+
from typing import Any, List, Optional
|
|
19
19
|
|
|
20
20
|
from click import Command
|
|
21
|
+
from snowflake.cli._app.dev.docs.template_utils import get_template_environment
|
|
21
22
|
from snowflake.cli.api.secure_path import SecurePath
|
|
22
|
-
from snowflake.cli.app.dev.docs.template_utils import get_template_environment
|
|
23
23
|
from typer.core import TyperArgument
|
|
24
24
|
|
|
25
25
|
log = logging.getLogger(__name__)
|
|
@@ -86,15 +86,33 @@ def _render_command_usage(
|
|
|
86
86
|
# Included files, which these are, need to use the .txt extension.
|
|
87
87
|
file_path = root / f"usage-{command_name}.txt"
|
|
88
88
|
log.info("Creating %s", file_path)
|
|
89
|
+
command_help_params = _split_docstring(command.help)
|
|
90
|
+
template_params = {
|
|
91
|
+
"name": command_name,
|
|
92
|
+
"options": options,
|
|
93
|
+
"arguments": arguments,
|
|
94
|
+
"path": path,
|
|
95
|
+
}
|
|
89
96
|
with file_path.open("w+") as fh:
|
|
90
|
-
fh.write(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
fh.write(template.render(command_help_params | template_params))
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _split_docstring(command_help: Optional[str]) -> dict[str, Any]:
|
|
101
|
+
if command_help is None:
|
|
102
|
+
return {}
|
|
103
|
+
|
|
104
|
+
split_command_help = command_help.split("## ")
|
|
105
|
+
|
|
106
|
+
if len(split_command_help) == 1:
|
|
107
|
+
return {"help": split_command_help[0]}
|
|
108
|
+
|
|
109
|
+
additional_sections = []
|
|
110
|
+
for section in split_command_help[1:]:
|
|
111
|
+
lines = section.split("\n")
|
|
112
|
+
additional_sections.append(
|
|
113
|
+
{"title": lines[0], "content": "\n".join(lines[1:]).strip()}
|
|
100
114
|
)
|
|
115
|
+
return {
|
|
116
|
+
"help": split_command_help[0],
|
|
117
|
+
"additional_sections": additional_sections,
|
|
118
|
+
}
|
|
@@ -17,11 +17,11 @@ from __future__ import annotations
|
|
|
17
17
|
import logging
|
|
18
18
|
|
|
19
19
|
from click import Command
|
|
20
|
-
from snowflake.cli.
|
|
21
|
-
from snowflake.cli.
|
|
22
|
-
from snowflake.cli.app.dev.docs.project_definition_docs_generator import (
|
|
20
|
+
from snowflake.cli._app.dev.docs.commands_docs_generator import generate_command_docs
|
|
21
|
+
from snowflake.cli._app.dev.docs.project_definition_docs_generator import (
|
|
23
22
|
generate_project_definition_docs,
|
|
24
23
|
)
|
|
24
|
+
from snowflake.cli.api.secure_path import SecurePath
|
|
25
25
|
|
|
26
26
|
log = logging.getLogger(__name__)
|
|
27
27
|
|
|
@@ -18,12 +18,12 @@ import logging
|
|
|
18
18
|
from typing import Any, Dict
|
|
19
19
|
|
|
20
20
|
from pydantic.json_schema import model_json_schema
|
|
21
|
-
from snowflake.cli.
|
|
22
|
-
from snowflake.cli.api.secure_path import SecurePath
|
|
23
|
-
from snowflake.cli.app.dev.docs.project_definition_generate_json_schema import (
|
|
21
|
+
from snowflake.cli._app.dev.docs.project_definition_generate_json_schema import (
|
|
24
22
|
ProjectDefinitionGenerateJsonSchema,
|
|
25
23
|
)
|
|
26
|
-
from snowflake.cli.
|
|
24
|
+
from snowflake.cli._app.dev.docs.template_utils import get_template_environment
|
|
25
|
+
from snowflake.cli.api.project.schemas.project_definition import DefinitionV11
|
|
26
|
+
from snowflake.cli.api.secure_path import SecurePath
|
|
27
27
|
|
|
28
28
|
log = logging.getLogger(__name__)
|
|
29
29
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{{ help | replace("`", "``") }}
|
|
1
|
+
{{ help | replace("`", "``") | replace("\n", " ") }}
|
|
2
2
|
|
|
3
3
|
Syntax
|
|
4
4
|
===============================================================================
|
|
@@ -26,7 +26,7 @@ Arguments
|
|
|
26
26
|
{{ param.make_metavar().replace("[", "").replace("]", "").lower() }}
|
|
27
27
|
{%- endif -%}
|
|
28
28
|
{{ '}' }}`
|
|
29
|
-
{% if param.help %}{{ " " + param.help | replace("`", "``") }}{% if param.help[-1] != '.' %}.{% endif %}{% else %} TBD{% endif %}
|
|
29
|
+
{% if param.help %}{{ " " + param.help | replace("`", "``") | replace("\n", " ") }}{% if param.help[-1] != '.' %}.{% endif %}{% if param.default %} Default: {{ param.default }}.{% endif %}{% else %} TBD{% endif %}
|
|
30
30
|
{% endfor %}
|
|
31
31
|
{% else %}
|
|
32
32
|
|
|
@@ -48,10 +48,20 @@ Options
|
|
|
48
48
|
{%- if param.type.name != "choice" %}{{ ' {' }}{% else %} {% endif %}{{ param.make_metavar() }}{% if param.type.name != "choice" %}{{ '}' }}
|
|
49
49
|
{%- endif %}
|
|
50
50
|
{%- endif %}`
|
|
51
|
-
{% if param.help %}{{ " " + param.help | replace("`", "``") }}{% if param.help[-1] != '.' %}.{% endif %}{% else %} TBD{% endif %}
|
|
52
|
-
{% endfor
|
|
51
|
+
{% if param.help %}{{ " " + param.help | replace("`", "``") | replace("\n", " ") }}{% if param.help[-1] != '.' %}.{% endif %}{% if param.default is not none %} Default: {{ param.default }}.{% endif %}{% else %} TBD{% endif %}
|
|
52
|
+
{% endfor -%}
|
|
53
53
|
{% else %}
|
|
54
54
|
|
|
55
55
|
None
|
|
56
56
|
|
|
57
57
|
{% endif -%}
|
|
58
|
+
|
|
59
|
+
{%- if additional_sections %}
|
|
60
|
+
..
|
|
61
|
+
{%- for section in additional_sections %}
|
|
62
|
+
{{ section.title }}
|
|
63
|
+
===============================================================================
|
|
64
|
+
|
|
65
|
+
{{ section.content | indent(2) }}
|
|
66
|
+
{% endfor %}
|
|
67
|
+
{% endif %}
|
|
@@ -17,13 +17,13 @@ from __future__ import annotations
|
|
|
17
17
|
import sys
|
|
18
18
|
|
|
19
19
|
import typer
|
|
20
|
-
from snowflake.cli.api.cli_global_context import
|
|
20
|
+
from snowflake.cli.api.cli_global_context import get_cli_context
|
|
21
21
|
from snowflake.cli.api.commands.flags import DEFAULT_CONTEXT_SETTINGS, DebugOption
|
|
22
22
|
from snowflake.cli.api.console import cli_console
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
def _handle_exception(exception: Exception):
|
|
26
|
-
if
|
|
26
|
+
if get_cli_context().enable_tracebacks:
|
|
27
27
|
raise exception
|
|
28
28
|
else:
|
|
29
29
|
cli_console.warning(
|
|
@@ -26,7 +26,7 @@ from rich import box, get_console
|
|
|
26
26
|
from rich import print as rich_print
|
|
27
27
|
from rich.live import Live
|
|
28
28
|
from rich.table import Table
|
|
29
|
-
from snowflake.cli.api.cli_global_context import
|
|
29
|
+
from snowflake.cli.api.cli_global_context import get_cli_context
|
|
30
30
|
from snowflake.cli.api.output.formats import OutputFormat
|
|
31
31
|
from snowflake.cli.api.output.types import (
|
|
32
32
|
CollectionResult,
|
|
@@ -65,7 +65,7 @@ class CustomJSONEncoder(JSONEncoder):
|
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
def _get_format_type() -> OutputFormat:
|
|
68
|
-
output_format =
|
|
68
|
+
output_format = get_cli_context().output_format
|
|
69
69
|
if output_format:
|
|
70
70
|
return output_format
|
|
71
71
|
return OutputFormat.TABLE
|
|
@@ -21,7 +21,11 @@ from typing import Dict, Optional
|
|
|
21
21
|
|
|
22
22
|
import snowflake.connector
|
|
23
23
|
from click.exceptions import ClickException
|
|
24
|
-
from snowflake.cli.
|
|
24
|
+
from snowflake.cli._app.constants import (
|
|
25
|
+
PARAM_APPLICATION_NAME,
|
|
26
|
+
)
|
|
27
|
+
from snowflake.cli._app.telemetry import command_info
|
|
28
|
+
from snowflake.cli.api.cli_global_context import get_cli_context
|
|
25
29
|
from snowflake.cli.api.config import (
|
|
26
30
|
get_connection_dict,
|
|
27
31
|
get_default_connection_dict,
|
|
@@ -33,10 +37,6 @@ from snowflake.cli.api.exceptions import (
|
|
|
33
37
|
SnowflakeConnectionError,
|
|
34
38
|
)
|
|
35
39
|
from snowflake.cli.api.secure_path import SecurePath
|
|
36
|
-
from snowflake.cli.app.constants import (
|
|
37
|
-
PARAM_APPLICATION_NAME,
|
|
38
|
-
)
|
|
39
|
-
from snowflake.cli.app.telemetry import command_info
|
|
40
40
|
from snowflake.connector import SnowflakeConnection
|
|
41
41
|
from snowflake.connector.errors import DatabaseError, ForbiddenError
|
|
42
42
|
|
|
@@ -75,7 +75,7 @@ def connect_to_snowflake(
|
|
|
75
75
|
connection_parameters = {} # we will apply overrides in next step
|
|
76
76
|
else:
|
|
77
77
|
connection_parameters = get_default_connection_dict()
|
|
78
|
-
|
|
78
|
+
get_cli_context().connection_context.set_connection_name(
|
|
79
79
|
get_default_connection_name()
|
|
80
80
|
)
|
|
81
81
|
|
|
@@ -21,12 +21,12 @@ from typing import Any, Dict, Union
|
|
|
21
21
|
|
|
22
22
|
import click
|
|
23
23
|
from snowflake.cli.__about__ import VERSION
|
|
24
|
-
from snowflake.cli.
|
|
24
|
+
from snowflake.cli._app.constants import PARAM_APPLICATION_NAME
|
|
25
|
+
from snowflake.cli.api.cli_global_context import get_cli_context
|
|
25
26
|
from snowflake.cli.api.commands.execution_metadata import ExecutionMetadata
|
|
26
27
|
from snowflake.cli.api.config import get_feature_flags_section
|
|
27
28
|
from snowflake.cli.api.output.formats import OutputFormat
|
|
28
29
|
from snowflake.cli.api.utils.error_handling import ignore_exceptions
|
|
29
|
-
from snowflake.cli.app.constants import PARAM_APPLICATION_NAME
|
|
30
30
|
from snowflake.connector.telemetry import (
|
|
31
31
|
TelemetryData,
|
|
32
32
|
TelemetryField,
|
|
@@ -88,8 +88,7 @@ def _find_command_info() -> TelemetryDict:
|
|
|
88
88
|
|
|
89
89
|
|
|
90
90
|
def _get_definition_version() -> str | None:
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
cli_context = get_cli_context()
|
|
93
92
|
if cli_context.project_definition:
|
|
94
93
|
return cli_context.project_definition.definition_version
|
|
95
94
|
return None
|
|
@@ -144,7 +143,7 @@ class CLITelemetryClient:
|
|
|
144
143
|
self._telemetry.send_batch()
|
|
145
144
|
|
|
146
145
|
|
|
147
|
-
_telemetry = CLITelemetryClient(ctx=
|
|
146
|
+
_telemetry = CLITelemetryClient(ctx=get_cli_context())
|
|
148
147
|
|
|
149
148
|
|
|
150
149
|
@ignore_exceptions()
|
|
@@ -21,7 +21,12 @@ import typer
|
|
|
21
21
|
from click import ClickException, Context, Parameter # type: ignore
|
|
22
22
|
from click.core import ParameterSource # type: ignore
|
|
23
23
|
from click.types import StringParamType
|
|
24
|
-
from snowflake.cli.
|
|
24
|
+
from snowflake.cli._plugins.connection.util import (
|
|
25
|
+
strip_and_check_if_exists,
|
|
26
|
+
strip_if_value_present,
|
|
27
|
+
)
|
|
28
|
+
from snowflake.cli._plugins.object.manager import ObjectManager
|
|
29
|
+
from snowflake.cli.api.cli_global_context import get_cli_context
|
|
25
30
|
from snowflake.cli.api.commands.flags import (
|
|
26
31
|
PLAIN_PASSWORD_MSG,
|
|
27
32
|
)
|
|
@@ -43,7 +48,6 @@ from snowflake.cli.api.output.types import (
|
|
|
43
48
|
MessageResult,
|
|
44
49
|
ObjectResult,
|
|
45
50
|
)
|
|
46
|
-
from snowflake.cli.plugins.object.manager import ObjectManager
|
|
47
51
|
from snowflake.connector import ProgrammingError
|
|
48
52
|
from snowflake.connector.config_manager import CONFIG_MANAGER
|
|
49
53
|
|
|
@@ -94,8 +98,8 @@ def require_integer(field_name: str):
|
|
|
94
98
|
def callback(value: str):
|
|
95
99
|
if value is None:
|
|
96
100
|
return None
|
|
97
|
-
if value.isdigit():
|
|
98
|
-
return value
|
|
101
|
+
if value.strip().isdigit():
|
|
102
|
+
return value.strip()
|
|
99
103
|
raise ClickException(f"Value of {field_name} must be integer")
|
|
100
104
|
|
|
101
105
|
return callback
|
|
@@ -117,6 +121,7 @@ def add(
|
|
|
117
121
|
prompt="Name for this connection",
|
|
118
122
|
help="Name of the new connection.",
|
|
119
123
|
show_default=False,
|
|
124
|
+
callback=strip_if_value_present,
|
|
120
125
|
),
|
|
121
126
|
account: str = typer.Option(
|
|
122
127
|
None,
|
|
@@ -126,6 +131,7 @@ def add(
|
|
|
126
131
|
prompt="Snowflake account name",
|
|
127
132
|
help="Account name to use when authenticating with Snowflake.",
|
|
128
133
|
show_default=False,
|
|
134
|
+
callback=strip_if_value_present,
|
|
129
135
|
),
|
|
130
136
|
user: str = typer.Option(
|
|
131
137
|
None,
|
|
@@ -135,6 +141,7 @@ def add(
|
|
|
135
141
|
prompt="Snowflake username",
|
|
136
142
|
show_default=False,
|
|
137
143
|
help="Username to connect to Snowflake.",
|
|
144
|
+
callback=strip_if_value_present,
|
|
138
145
|
),
|
|
139
146
|
password: str = typer.Option(
|
|
140
147
|
EmptyInput(),
|
|
@@ -153,6 +160,7 @@ def add(
|
|
|
153
160
|
click_type=OptionalPrompt(),
|
|
154
161
|
prompt="Role for the connection",
|
|
155
162
|
help="Role to use on Snowflake.",
|
|
163
|
+
callback=strip_if_value_present,
|
|
156
164
|
),
|
|
157
165
|
warehouse: str = typer.Option(
|
|
158
166
|
EmptyInput(),
|
|
@@ -161,6 +169,7 @@ def add(
|
|
|
161
169
|
click_type=OptionalPrompt(),
|
|
162
170
|
prompt="Warehouse for the connection",
|
|
163
171
|
help="Warehouse to use on Snowflake.",
|
|
172
|
+
callback=strip_if_value_present,
|
|
164
173
|
),
|
|
165
174
|
database: str = typer.Option(
|
|
166
175
|
EmptyInput(),
|
|
@@ -169,6 +178,7 @@ def add(
|
|
|
169
178
|
click_type=OptionalPrompt(),
|
|
170
179
|
prompt="Database for the connection",
|
|
171
180
|
help="Database to use on Snowflake.",
|
|
181
|
+
callback=strip_if_value_present,
|
|
172
182
|
),
|
|
173
183
|
schema: str = typer.Option(
|
|
174
184
|
EmptyInput(),
|
|
@@ -177,6 +187,7 @@ def add(
|
|
|
177
187
|
click_type=OptionalPrompt(),
|
|
178
188
|
prompt="Schema for the connection",
|
|
179
189
|
help="Schema to use on Snowflake.",
|
|
190
|
+
callback=strip_if_value_present,
|
|
180
191
|
),
|
|
181
192
|
host: str = typer.Option(
|
|
182
193
|
EmptyInput(),
|
|
@@ -185,6 +196,7 @@ def add(
|
|
|
185
196
|
click_type=OptionalPrompt(),
|
|
186
197
|
prompt="Connection host",
|
|
187
198
|
help="Host name the connection attempts to connect to Snowflake.",
|
|
199
|
+
callback=strip_if_value_present,
|
|
188
200
|
),
|
|
189
201
|
port: int = typer.Option(
|
|
190
202
|
EmptyInput(),
|
|
@@ -202,6 +214,7 @@ def add(
|
|
|
202
214
|
click_type=OptionalPrompt(),
|
|
203
215
|
prompt="Snowflake region",
|
|
204
216
|
help="Region name if not the default Snowflake deployment.",
|
|
217
|
+
callback=strip_if_value_present,
|
|
205
218
|
),
|
|
206
219
|
authenticator: str = typer.Option(
|
|
207
220
|
EmptyInput(),
|
|
@@ -218,6 +231,7 @@ def add(
|
|
|
218
231
|
click_type=OptionalPrompt(),
|
|
219
232
|
prompt="Path to private key file",
|
|
220
233
|
help="Path to file containing private key",
|
|
234
|
+
callback=strip_and_check_if_exists,
|
|
221
235
|
),
|
|
222
236
|
token_file_path: str = typer.Option(
|
|
223
237
|
EmptyInput(),
|
|
@@ -226,6 +240,7 @@ def add(
|
|
|
226
240
|
click_type=OptionalPrompt(),
|
|
227
241
|
prompt="Path to token file",
|
|
228
242
|
help="Path to file with an OAuth token that should be used when connecting to Snowflake",
|
|
243
|
+
callback=strip_and_check_if_exists,
|
|
229
244
|
),
|
|
230
245
|
set_as_default: bool = typer.Option(
|
|
231
246
|
False,
|
|
@@ -276,6 +291,7 @@ def test(
|
|
|
276
291
|
"""
|
|
277
292
|
|
|
278
293
|
# Test connection
|
|
294
|
+
cli_context = get_cli_context()
|
|
279
295
|
conn = cli_context.connection
|
|
280
296
|
|
|
281
297
|
# Test session attributes
|
|
@@ -320,7 +336,8 @@ def test(
|
|
|
320
336
|
@app.command(requires_connection=False)
|
|
321
337
|
def set_default(
|
|
322
338
|
name: str = typer.Argument(
|
|
323
|
-
help="Name of the connection, as defined in your `config.toml`"
|
|
339
|
+
help="Name of the connection, as defined in your `config.toml`",
|
|
340
|
+
show_default=False,
|
|
324
341
|
),
|
|
325
342
|
**options,
|
|
326
343
|
):
|
|
@@ -0,0 +1,30 @@
|
|
|
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._plugins.connection import commands
|
|
16
|
+
from snowflake.cli.api.plugins.command import (
|
|
17
|
+
SNOWCLI_ROOT_COMMAND_PATH,
|
|
18
|
+
CommandSpec,
|
|
19
|
+
CommandType,
|
|
20
|
+
plugin_hook_impl,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@plugin_hook_impl
|
|
25
|
+
def command_spec():
|
|
26
|
+
return CommandSpec(
|
|
27
|
+
parent_command_path=SNOWCLI_ROOT_COMMAND_PATH,
|
|
28
|
+
command_type=CommandType.COMMAND_GROUP,
|
|
29
|
+
typer_instance=commands.app.create_instance(),
|
|
30
|
+
)
|
|
@@ -16,6 +16,8 @@ from __future__ import annotations
|
|
|
16
16
|
|
|
17
17
|
import json
|
|
18
18
|
import logging
|
|
19
|
+
import os
|
|
20
|
+
from typing import Optional
|
|
19
21
|
|
|
20
22
|
from click.exceptions import ClickException
|
|
21
23
|
from snowflake.connector import SnowflakeConnection
|
|
@@ -177,3 +179,17 @@ def make_snowsight_url(conn: SnowflakeConnection, path: str) -> str:
|
|
|
177
179
|
account = get_account(conn)
|
|
178
180
|
path_with_slash = path if path.startswith("/") else f"/{path}"
|
|
179
181
|
return f"{snowsight_host}/{deployment}/{account}{path_with_slash}"
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def strip_if_value_present(value: Optional[str]) -> Optional[str]:
|
|
185
|
+
return value.strip() if value else value
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def ensure_that_path_exist(path: Optional[str]) -> Optional[str]:
|
|
189
|
+
if path and not os.path.exists(path):
|
|
190
|
+
raise ClickException(f"Path {path} does not exist.")
|
|
191
|
+
return path
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def strip_and_check_if_exists(value: Optional[str]) -> Optional[str]:
|
|
195
|
+
return ensure_that_path_exist(strip_if_value_present(value))
|