snowflake-cli-labs 2.8.0rc1__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 +79 -26
- snowflake/cli/{plugins → _plugins}/git/manager.py +72 -17
- 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 +10 -6
- 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 +8 -6
- snowflake/cli/{plugins → _plugins}/notebook/manager.py +14 -14
- snowflake/cli/{plugins/nativeapp → _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 +43 -21
- 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 +2 -8
- 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 +4 -3
- 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 +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 +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 +20 -17
- snowflake/cli/{plugins → _plugins}/stage/diff.py +1 -47
- snowflake/cli/{plugins → _plugins}/stage/manager.py +62 -24
- 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 +71 -62
- snowflake/cli/{plugins → _plugins}/streamlit/manager.py +68 -70
- 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 +143 -222
- 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 +45 -9
- 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 +47 -27
- snowflake/cli/api/utils/definition_rendering.py +45 -13
- {snowflake_cli_labs-2.8.0rc1.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 -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/__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.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/{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/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.0rc1.dist-info → snowflake_cli_labs-3.0.0.dist-info}/WHEEL +0 -0
- {snowflake_cli_labs-2.8.0rc1.dist-info → snowflake_cli_labs-3.0.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -19,7 +19,7 @@ from functools import wraps
|
|
|
19
19
|
from inspect import Signature
|
|
20
20
|
from typing import Callable, Dict, List, Optional, get_type_hints
|
|
21
21
|
|
|
22
|
-
from snowflake.cli.api.cli_global_context import
|
|
22
|
+
from snowflake.cli.api.cli_global_context import get_cli_context
|
|
23
23
|
from snowflake.cli.api.commands.flags import (
|
|
24
24
|
AccountOption,
|
|
25
25
|
AuthenticatorOption,
|
|
@@ -29,10 +29,12 @@ from snowflake.cli.api.commands.flags import (
|
|
|
29
29
|
DiagAllowlistPathOption,
|
|
30
30
|
DiagLogPathOption,
|
|
31
31
|
EnableDiagOption,
|
|
32
|
+
HostOption,
|
|
32
33
|
MasterTokenOption,
|
|
33
34
|
MfaPasscodeOption,
|
|
34
35
|
OutputFormatOption,
|
|
35
36
|
PasswordOption,
|
|
37
|
+
PortOption,
|
|
36
38
|
PrivateKeyPathOption,
|
|
37
39
|
RoleOption,
|
|
38
40
|
SchemaOption,
|
|
@@ -125,8 +127,9 @@ def with_experimental_behaviour(
|
|
|
125
127
|
|
|
126
128
|
|
|
127
129
|
def _execute_before_command_using_global_options(**options):
|
|
128
|
-
from snowflake.cli.
|
|
130
|
+
from snowflake.cli._app.loggers import create_loggers
|
|
129
131
|
|
|
132
|
+
cli_context = get_cli_context()
|
|
130
133
|
create_loggers(cli_context.verbose, cli_context.enable_tracebacks)
|
|
131
134
|
|
|
132
135
|
|
|
@@ -209,6 +212,18 @@ GLOBAL_CONNECTION_OPTIONS = [
|
|
|
209
212
|
annotation=Optional[str],
|
|
210
213
|
default=ConnectionOption,
|
|
211
214
|
),
|
|
215
|
+
inspect.Parameter(
|
|
216
|
+
"host",
|
|
217
|
+
inspect.Parameter.KEYWORD_ONLY,
|
|
218
|
+
annotation=Optional[str],
|
|
219
|
+
default=HostOption,
|
|
220
|
+
),
|
|
221
|
+
inspect.Parameter(
|
|
222
|
+
"port",
|
|
223
|
+
inspect.Parameter.KEYWORD_ONLY,
|
|
224
|
+
annotation=Optional[int],
|
|
225
|
+
default=PortOption,
|
|
226
|
+
),
|
|
212
227
|
inspect.Parameter(
|
|
213
228
|
"account",
|
|
214
229
|
inspect.Parameter.KEYWORD_ONLY,
|
|
@@ -234,7 +249,7 @@ GLOBAL_CONNECTION_OPTIONS = [
|
|
|
234
249
|
default=AuthenticatorOption,
|
|
235
250
|
),
|
|
236
251
|
inspect.Parameter(
|
|
237
|
-
"
|
|
252
|
+
"private_key_file",
|
|
238
253
|
inspect.Parameter.KEYWORD_ONLY,
|
|
239
254
|
annotation=Optional[str],
|
|
240
255
|
default=PrivateKeyPathOption,
|
|
@@ -342,7 +357,7 @@ GLOBAL_OPTIONS = [
|
|
|
342
357
|
|
|
343
358
|
|
|
344
359
|
def with_output(func):
|
|
345
|
-
from snowflake.cli.
|
|
360
|
+
from snowflake.cli._app.printing import print_result
|
|
346
361
|
|
|
347
362
|
@wraps(func)
|
|
348
363
|
def wrapper(*args, **kwargs):
|
|
@@ -11,9 +11,8 @@
|
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
from snowflake.cli.api.cli_global_context import cli_context
|
|
14
|
+
from snowflake.cli.api.cli_global_context import get_cli_context
|
|
16
15
|
|
|
17
16
|
|
|
18
17
|
def experimental_behaviour_enabled() -> bool:
|
|
19
|
-
return
|
|
18
|
+
return get_cli_context().experimental
|
|
@@ -15,22 +15,24 @@
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
17
|
import tempfile
|
|
18
|
-
from dataclasses import dataclass
|
|
19
|
-
from enum import Enum
|
|
20
|
-
from inspect import signature
|
|
21
18
|
from pathlib import Path
|
|
22
|
-
from typing import Any, Callable,
|
|
19
|
+
from typing import Any, Callable, Optional
|
|
23
20
|
|
|
24
21
|
import click
|
|
25
22
|
import typer
|
|
26
23
|
from click import ClickException
|
|
27
|
-
from snowflake.cli.api.cli_global_context import
|
|
28
|
-
|
|
24
|
+
from snowflake.cli.api.cli_global_context import (
|
|
25
|
+
_CliGlobalContextManager,
|
|
26
|
+
get_cli_context_manager,
|
|
27
|
+
)
|
|
28
|
+
from snowflake.cli.api.commands.common import OnErrorType
|
|
29
|
+
from snowflake.cli.api.commands.overrideable_parameter import OverrideableOption
|
|
30
|
+
from snowflake.cli.api.commands.utils import parse_key_value_variables
|
|
31
|
+
from snowflake.cli.api.config import get_all_connections
|
|
32
|
+
from snowflake.cli.api.connections import ConnectionContext
|
|
29
33
|
from snowflake.cli.api.console import cli_console
|
|
30
|
-
from snowflake.cli.api.
|
|
34
|
+
from snowflake.cli.api.identifiers import FQN
|
|
31
35
|
from snowflake.cli.api.output.formats import OutputFormat
|
|
32
|
-
from snowflake.cli.api.project.definition_manager import DefinitionManager
|
|
33
|
-
from snowflake.cli.api.rendering.jinja import CONTEXT_KEY
|
|
34
36
|
|
|
35
37
|
DEFAULT_CONTEXT_SETTINGS = {"help_option_names": ["--help", "-h"]}
|
|
36
38
|
|
|
@@ -38,115 +40,39 @@ _CONNECTION_SECTION = "Connection configuration"
|
|
|
38
40
|
_CLI_BEHAVIOUR = "Global configuration"
|
|
39
41
|
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
ClickException will be thrown. Note that mutually_exclusive can contain an option's own name but does not require
|
|
55
|
-
it.
|
|
56
|
-
"""
|
|
57
|
-
|
|
58
|
-
def __init__(
|
|
59
|
-
self,
|
|
60
|
-
default: Any,
|
|
61
|
-
*param_decls: str,
|
|
62
|
-
mutually_exclusive: Optional[List[str] | Tuple[str]] = None,
|
|
63
|
-
**kwargs,
|
|
64
|
-
):
|
|
65
|
-
self.default = default
|
|
66
|
-
self.param_decls = param_decls
|
|
67
|
-
self.mutually_exclusive = mutually_exclusive
|
|
68
|
-
self.kwargs = kwargs
|
|
69
|
-
|
|
70
|
-
def __call__(self, **kwargs) -> typer.models.OptionInfo:
|
|
71
|
-
"""
|
|
72
|
-
Returns a typer.models.OptionInfo instance initialized with the specified default values along with any overrides
|
|
73
|
-
from kwargs. Note that if you are overriding param_decls, you must pass an iterable of strings, you cannot use
|
|
74
|
-
positional arguments like you can with typer.Option. Does not modify the original instance.
|
|
75
|
-
"""
|
|
76
|
-
default = kwargs.get("default", self.default)
|
|
77
|
-
param_decls = kwargs.get("param_decls", self.param_decls)
|
|
78
|
-
mutually_exclusive = kwargs.get("mutually_exclusive", self.mutually_exclusive)
|
|
79
|
-
if not isinstance(param_decls, list) and not isinstance(param_decls, tuple):
|
|
80
|
-
raise TypeError("param_decls must be a list or tuple")
|
|
81
|
-
passed_kwargs = self.kwargs.copy()
|
|
82
|
-
passed_kwargs.update(kwargs)
|
|
83
|
-
if passed_kwargs.get("callback", None) or mutually_exclusive:
|
|
84
|
-
passed_kwargs["callback"] = self._callback_factory(
|
|
85
|
-
passed_kwargs.get("callback", None), mutually_exclusive
|
|
86
|
-
)
|
|
87
|
-
for non_kwarg in ["default", "param_decls", "mutually_exclusive"]:
|
|
88
|
-
passed_kwargs.pop(non_kwarg, None)
|
|
89
|
-
return typer.Option(default, *param_decls, **passed_kwargs)
|
|
90
|
-
|
|
91
|
-
class InvalidCallbackSignature(ClickException):
|
|
92
|
-
def __init__(self, callback):
|
|
93
|
-
super().__init__(
|
|
94
|
-
f"Signature {signature(callback)} is not valid for an OverrideableOption callback function. Must have at most one parameter with each of the following types: (typer.Context, typer.CallbackParam, Any Other Type)"
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
def _callback_factory(
|
|
98
|
-
self, callback, mutually_exclusive: Optional[List[str] | Tuple[str]]
|
|
99
|
-
):
|
|
100
|
-
callback = callback if callback else lambda x: x
|
|
101
|
-
|
|
102
|
-
# inspect existing_callback to make sure signature is valid
|
|
103
|
-
existing_params = signature(callback).parameters
|
|
104
|
-
# at most one parameter with each type in [typer.Context, typer.CallbackParam, any other type]
|
|
105
|
-
limits = [
|
|
106
|
-
lambda x: x == typer.Context,
|
|
107
|
-
lambda x: x == typer.CallbackParam,
|
|
108
|
-
lambda x: x != typer.Context and x != typer.CallbackParam,
|
|
109
|
-
]
|
|
110
|
-
for limit in limits:
|
|
111
|
-
if len([v for v in existing_params.values() if limit(v.annotation)]) > 1:
|
|
112
|
-
raise self.InvalidCallbackSignature(callback)
|
|
113
|
-
|
|
114
|
-
def generated_callback(ctx: typer.Context, param: typer.CallbackParam, value):
|
|
115
|
-
if mutually_exclusive:
|
|
116
|
-
for name in mutually_exclusive:
|
|
117
|
-
if value and ctx.params.get(
|
|
118
|
-
name, False
|
|
119
|
-
): # if the current parameter is set to True and a previous parameter is also Truthy
|
|
120
|
-
curr_opt = param.opts[0]
|
|
121
|
-
other_opt = [x for x in ctx.command.params if x.name == name][
|
|
122
|
-
0
|
|
123
|
-
].opts[0]
|
|
124
|
-
raise click.ClickException(
|
|
125
|
-
f"Options '{curr_opt}' and '{other_opt}' are incompatible."
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
# pass args to existing callback based on its signature (this is how Typer infers callback args)
|
|
129
|
-
passed_params = {}
|
|
130
|
-
for existing_param in existing_params:
|
|
131
|
-
annotation = existing_params[existing_param].annotation
|
|
132
|
-
if annotation == typer.Context:
|
|
133
|
-
passed_params[existing_param] = ctx
|
|
134
|
-
elif annotation == typer.CallbackParam:
|
|
135
|
-
passed_params[existing_param] = param
|
|
136
|
-
else:
|
|
137
|
-
passed_params[existing_param] = value
|
|
138
|
-
return callback(**passed_params)
|
|
139
|
-
|
|
140
|
-
return generated_callback
|
|
43
|
+
def _connection_callback(prop: str):
|
|
44
|
+
"""Generates a setter for a field on the current context manager's connection context."""
|
|
45
|
+
if prop not in ConnectionContext.__dataclass_fields__:
|
|
46
|
+
raise KeyError(
|
|
47
|
+
f"Cannot generate setter for non-existent connection attr {prop}"
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
def callback(value):
|
|
51
|
+
try:
|
|
52
|
+
if click.get_current_context().resilient_parsing:
|
|
53
|
+
return
|
|
54
|
+
except RuntimeError:
|
|
55
|
+
pass
|
|
141
56
|
|
|
57
|
+
setattr(get_cli_context_manager().connection_context, prop, value)
|
|
58
|
+
return value
|
|
142
59
|
|
|
143
|
-
|
|
60
|
+
return callback
|
|
144
61
|
|
|
145
62
|
|
|
146
|
-
def
|
|
63
|
+
def _context_callback(prop: str):
|
|
64
|
+
"""Generates a setter for a field on the current context manager."""
|
|
65
|
+
if prop not in _CliGlobalContextManager.__dataclass_fields__:
|
|
66
|
+
raise KeyError(f"Cannot generate setter for non-existent context attr {prop}")
|
|
67
|
+
|
|
147
68
|
def callback(value):
|
|
148
|
-
|
|
149
|
-
|
|
69
|
+
try:
|
|
70
|
+
if click.get_current_context().resilient_parsing:
|
|
71
|
+
return
|
|
72
|
+
except RuntimeError:
|
|
73
|
+
pass
|
|
74
|
+
|
|
75
|
+
setattr(get_cli_context_manager(), prop, value)
|
|
150
76
|
return value
|
|
151
77
|
|
|
152
78
|
return callback
|
|
@@ -158,12 +84,10 @@ ConnectionOption = typer.Option(
|
|
|
158
84
|
"-c",
|
|
159
85
|
"--environment",
|
|
160
86
|
help=f"Name of the connection, as defined in your `config.toml`. Default: `default`.",
|
|
161
|
-
callback=
|
|
162
|
-
lambda: cli_context_manager.connection_context.set_connection_name
|
|
163
|
-
),
|
|
87
|
+
callback=_connection_callback("connection_name"),
|
|
164
88
|
show_default=False,
|
|
165
89
|
rich_help_panel=_CONNECTION_SECTION,
|
|
166
|
-
|
|
90
|
+
shell_complete=lambda _, __, ___: list(get_all_connections()),
|
|
167
91
|
)
|
|
168
92
|
|
|
169
93
|
TemporaryConnectionOption = typer.Option(
|
|
@@ -171,19 +95,35 @@ TemporaryConnectionOption = typer.Option(
|
|
|
171
95
|
"--temporary-connection",
|
|
172
96
|
"-x",
|
|
173
97
|
help="Uses connection defined with command line parameters, instead of one defined in config",
|
|
174
|
-
callback=
|
|
175
|
-
lambda: cli_context_manager.connection_context.set_temporary_connection
|
|
176
|
-
),
|
|
98
|
+
callback=_connection_callback("temporary_connection"),
|
|
177
99
|
is_flag=True,
|
|
178
100
|
rich_help_panel=_CONNECTION_SECTION,
|
|
179
101
|
)
|
|
180
102
|
|
|
103
|
+
HostOption = typer.Option(
|
|
104
|
+
None,
|
|
105
|
+
"--host",
|
|
106
|
+
help="Host address for the connection. Overrides the value specified for the connection.",
|
|
107
|
+
callback=_connection_callback("host"),
|
|
108
|
+
show_default=False,
|
|
109
|
+
rich_help_panel=_CONNECTION_SECTION,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
PortOption = typer.Option(
|
|
113
|
+
None,
|
|
114
|
+
"--port",
|
|
115
|
+
help="Port for the connection. Overrides the value specified for the connection.",
|
|
116
|
+
callback=_connection_callback("port"),
|
|
117
|
+
show_default=False,
|
|
118
|
+
rich_help_panel=_CONNECTION_SECTION,
|
|
119
|
+
)
|
|
120
|
+
|
|
181
121
|
AccountOption = typer.Option(
|
|
182
122
|
None,
|
|
183
123
|
"--account",
|
|
184
124
|
"--accountname",
|
|
185
125
|
help="Name assigned to your Snowflake account. Overrides the value specified for the connection.",
|
|
186
|
-
callback=
|
|
126
|
+
callback=_connection_callback("account"),
|
|
187
127
|
show_default=False,
|
|
188
128
|
rich_help_panel=_CONNECTION_SECTION,
|
|
189
129
|
)
|
|
@@ -193,7 +133,7 @@ UserOption = typer.Option(
|
|
|
193
133
|
"--user",
|
|
194
134
|
"--username",
|
|
195
135
|
help="Username to connect to Snowflake. Overrides the value specified for the connection.",
|
|
196
|
-
callback=
|
|
136
|
+
callback=_connection_callback("user"),
|
|
197
137
|
show_default=False,
|
|
198
138
|
rich_help_panel=_CONNECTION_SECTION,
|
|
199
139
|
)
|
|
@@ -206,7 +146,7 @@ def _password_callback(value: str):
|
|
|
206
146
|
if value:
|
|
207
147
|
cli_console.message(PLAIN_PASSWORD_MSG)
|
|
208
148
|
|
|
209
|
-
return
|
|
149
|
+
return _connection_callback("password")(value)
|
|
210
150
|
|
|
211
151
|
|
|
212
152
|
PasswordOption = typer.Option(
|
|
@@ -224,21 +164,18 @@ AuthenticatorOption = typer.Option(
|
|
|
224
164
|
"--authenticator",
|
|
225
165
|
help="Snowflake authenticator. Overrides the value specified for the connection.",
|
|
226
166
|
hide_input=True,
|
|
227
|
-
callback=
|
|
228
|
-
lambda: cli_context_manager.connection_context.set_authenticator
|
|
229
|
-
),
|
|
167
|
+
callback=_connection_callback("authenticator"),
|
|
230
168
|
show_default=False,
|
|
231
169
|
rich_help_panel=_CONNECTION_SECTION,
|
|
232
170
|
)
|
|
233
171
|
|
|
234
172
|
PrivateKeyPathOption = typer.Option(
|
|
235
173
|
None,
|
|
174
|
+
"--private-key-file",
|
|
236
175
|
"--private-key-path",
|
|
237
|
-
help="Snowflake private key path. Overrides the value specified for the connection.",
|
|
176
|
+
help="Snowflake private key file path. Overrides the value specified for the connection.",
|
|
238
177
|
hide_input=True,
|
|
239
|
-
callback=
|
|
240
|
-
lambda: cli_context_manager.connection_context.set_private_key_path
|
|
241
|
-
),
|
|
178
|
+
callback=_connection_callback("private_key_file"),
|
|
242
179
|
show_default=False,
|
|
243
180
|
rich_help_panel=_CONNECTION_SECTION,
|
|
244
181
|
exists=True,
|
|
@@ -251,9 +188,7 @@ SessionTokenOption = typer.Option(
|
|
|
251
188
|
"--session-token",
|
|
252
189
|
help="Snowflake session token. Can be used only in conjunction with --master-token. Overrides the value specified for the connection.",
|
|
253
190
|
hide_input=True,
|
|
254
|
-
callback=
|
|
255
|
-
lambda: cli_context_manager.connection_context.set_session_token
|
|
256
|
-
),
|
|
191
|
+
callback=_connection_callback("session_token"),
|
|
257
192
|
show_default=False,
|
|
258
193
|
rich_help_panel=_CONNECTION_SECTION,
|
|
259
194
|
exists=True,
|
|
@@ -267,7 +202,7 @@ MasterTokenOption = typer.Option(
|
|
|
267
202
|
"--master-token",
|
|
268
203
|
help="Snowflake master token. Can be used only in conjunction with --session-token. Overrides the value specified for the connection.",
|
|
269
204
|
hide_input=True,
|
|
270
|
-
callback=
|
|
205
|
+
callback=_connection_callback("master_token"),
|
|
271
206
|
show_default=False,
|
|
272
207
|
rich_help_panel=_CONNECTION_SECTION,
|
|
273
208
|
exists=True,
|
|
@@ -280,9 +215,7 @@ TokenFilePathOption = typer.Option(
|
|
|
280
215
|
None,
|
|
281
216
|
"--token-file-path",
|
|
282
217
|
help="Path to file with an OAuth token that should be used when connecting to Snowflake",
|
|
283
|
-
callback=
|
|
284
|
-
lambda: cli_context_manager.connection_context.set_token_file_path
|
|
285
|
-
),
|
|
218
|
+
callback=_connection_callback("token_file_path"),
|
|
286
219
|
show_default=False,
|
|
287
220
|
rich_help_panel=_CONNECTION_SECTION,
|
|
288
221
|
exists=True,
|
|
@@ -295,7 +228,7 @@ DatabaseOption = typer.Option(
|
|
|
295
228
|
"--database",
|
|
296
229
|
"--dbname",
|
|
297
230
|
help="Database to use. Overrides the value specified for the connection.",
|
|
298
|
-
callback=
|
|
231
|
+
callback=_connection_callback("database"),
|
|
299
232
|
show_default=False,
|
|
300
233
|
rich_help_panel=_CONNECTION_SECTION,
|
|
301
234
|
)
|
|
@@ -305,7 +238,7 @@ SchemaOption = typer.Option(
|
|
|
305
238
|
"--schema",
|
|
306
239
|
"--schemaname",
|
|
307
240
|
help="Database schema to use. Overrides the value specified for the connection.",
|
|
308
|
-
callback=
|
|
241
|
+
callback=_connection_callback("schema"),
|
|
309
242
|
show_default=False,
|
|
310
243
|
rich_help_panel=_CONNECTION_SECTION,
|
|
311
244
|
)
|
|
@@ -315,7 +248,7 @@ RoleOption = typer.Option(
|
|
|
315
248
|
"--role",
|
|
316
249
|
"--rolename",
|
|
317
250
|
help="Role to use. Overrides the value specified for the connection.",
|
|
318
|
-
callback=
|
|
251
|
+
callback=_connection_callback("role"),
|
|
319
252
|
show_default=False,
|
|
320
253
|
rich_help_panel=_CONNECTION_SECTION,
|
|
321
254
|
)
|
|
@@ -324,7 +257,7 @@ WarehouseOption = typer.Option(
|
|
|
324
257
|
None,
|
|
325
258
|
"--warehouse",
|
|
326
259
|
help="Warehouse to use. Overrides the value specified for the connection.",
|
|
327
|
-
callback=
|
|
260
|
+
callback=_connection_callback("warehouse"),
|
|
328
261
|
show_default=False,
|
|
329
262
|
rich_help_panel=_CONNECTION_SECTION,
|
|
330
263
|
)
|
|
@@ -333,7 +266,7 @@ MfaPasscodeOption = typer.Option(
|
|
|
333
266
|
None,
|
|
334
267
|
"--mfa-passcode",
|
|
335
268
|
help="Token to use for multi-factor authentication (MFA)",
|
|
336
|
-
callback=
|
|
269
|
+
callback=_connection_callback("mfa_passcode"),
|
|
337
270
|
prompt="MFA passcode",
|
|
338
271
|
prompt_required=False,
|
|
339
272
|
show_default=False,
|
|
@@ -344,19 +277,29 @@ EnableDiagOption = typer.Option(
|
|
|
344
277
|
False,
|
|
345
278
|
"--enable-diag",
|
|
346
279
|
help="Run python connector diagnostic test",
|
|
347
|
-
callback=
|
|
280
|
+
callback=_connection_callback("enable_diag"),
|
|
348
281
|
show_default=False,
|
|
349
282
|
is_flag=True,
|
|
350
283
|
rich_help_panel=_CONNECTION_SECTION,
|
|
351
284
|
)
|
|
352
285
|
|
|
286
|
+
# Set default via callback to avoid including tempdir path in generated docs (snow --docs).
|
|
287
|
+
# Use constant instead of None, as None is removed from telemetry data.
|
|
288
|
+
_DIAG_LOG_DEFAULT_VALUE = "<temporary_directory>"
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
def _diag_log_path_callback(path: str):
|
|
292
|
+
if path == _DIAG_LOG_DEFAULT_VALUE:
|
|
293
|
+
path = tempfile.gettempdir()
|
|
294
|
+
get_cli_context_manager().connection_context.diag_log_path = Path(path)
|
|
295
|
+
return path
|
|
296
|
+
|
|
297
|
+
|
|
353
298
|
DiagLogPathOption: Path = typer.Option(
|
|
354
|
-
|
|
299
|
+
_DIAG_LOG_DEFAULT_VALUE,
|
|
355
300
|
"--diag-log-path",
|
|
356
301
|
help="Diagnostic report path",
|
|
357
|
-
callback=
|
|
358
|
-
lambda: cli_context_manager.connection_context.set_diag_log_path
|
|
359
|
-
),
|
|
302
|
+
callback=_diag_log_path_callback,
|
|
360
303
|
show_default=False,
|
|
361
304
|
rich_help_panel=_CONNECTION_SECTION,
|
|
362
305
|
exists=True,
|
|
@@ -367,9 +310,7 @@ DiagAllowlistPathOption: Path = typer.Option(
|
|
|
367
310
|
None,
|
|
368
311
|
"--diag-allowlist-path",
|
|
369
312
|
help="Diagnostic report path to optional allowlist",
|
|
370
|
-
callback=
|
|
371
|
-
lambda: cli_context_manager.connection_context.set_diag_allowlist_path
|
|
372
|
-
),
|
|
313
|
+
callback=_connection_callback("diag_allowlist_path"),
|
|
373
314
|
show_default=False,
|
|
374
315
|
rich_help_panel=_CONNECTION_SECTION,
|
|
375
316
|
exists=True,
|
|
@@ -381,7 +322,7 @@ OutputFormatOption = typer.Option(
|
|
|
381
322
|
"--format",
|
|
382
323
|
help="Specifies the output format.",
|
|
383
324
|
case_sensitive=False,
|
|
384
|
-
callback=
|
|
325
|
+
callback=_context_callback("output_format"),
|
|
385
326
|
rich_help_panel=_CLI_BEHAVIOUR,
|
|
386
327
|
)
|
|
387
328
|
|
|
@@ -389,7 +330,7 @@ SilentOption = typer.Option(
|
|
|
389
330
|
False,
|
|
390
331
|
"--silent",
|
|
391
332
|
help="Turns off intermediate output to console.",
|
|
392
|
-
callback=
|
|
333
|
+
callback=_context_callback("silent"),
|
|
393
334
|
is_flag=True,
|
|
394
335
|
rich_help_panel=_CLI_BEHAVIOUR,
|
|
395
336
|
is_eager=True,
|
|
@@ -400,7 +341,7 @@ VerboseOption = typer.Option(
|
|
|
400
341
|
"--verbose",
|
|
401
342
|
"-v",
|
|
402
343
|
help="Displays log entries for log levels `info` and higher.",
|
|
403
|
-
callback=
|
|
344
|
+
callback=_context_callback("verbose"),
|
|
404
345
|
is_flag=True,
|
|
405
346
|
rich_help_panel=_CLI_BEHAVIOUR,
|
|
406
347
|
)
|
|
@@ -409,7 +350,7 @@ DebugOption = typer.Option(
|
|
|
409
350
|
False,
|
|
410
351
|
"--debug",
|
|
411
352
|
help="Displays log entries for log levels `debug` and higher; debug logs contains additional information.",
|
|
412
|
-
callback=
|
|
353
|
+
callback=_context_callback("enable_tracebacks"),
|
|
413
354
|
is_flag=True,
|
|
414
355
|
rich_help_panel=_CLI_BEHAVIOUR,
|
|
415
356
|
)
|
|
@@ -450,6 +391,10 @@ OnErrorOption = typer.Option(
|
|
|
450
391
|
NoInteractiveOption = typer.Option(False, "--no-interactive", help="Disable prompting.")
|
|
451
392
|
|
|
452
393
|
|
|
394
|
+
def entity_argument(entity_type: str) -> typer.Argument:
|
|
395
|
+
return typer.Argument(None, help=f"ID of {entity_type} entity.")
|
|
396
|
+
|
|
397
|
+
|
|
453
398
|
def variables_option(description: str):
|
|
454
399
|
return typer.Option(
|
|
455
400
|
None,
|
|
@@ -508,17 +453,46 @@ def experimental_option(
|
|
|
508
453
|
"--experimental",
|
|
509
454
|
help=help_text,
|
|
510
455
|
hidden=True,
|
|
511
|
-
callback=
|
|
456
|
+
callback=_context_callback("experimental"),
|
|
512
457
|
is_flag=True,
|
|
513
458
|
rich_help_panel=_CLI_BEHAVIOUR,
|
|
514
459
|
)
|
|
515
460
|
|
|
516
461
|
|
|
517
|
-
|
|
462
|
+
class IdentifierType(click.ParamType):
|
|
463
|
+
name = "TEXT"
|
|
464
|
+
|
|
465
|
+
def convert(self, value, param, ctx):
|
|
466
|
+
return FQN.from_string(value)
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
class IdentifierStageType(click.ParamType):
|
|
470
|
+
name = "TEXT"
|
|
471
|
+
|
|
472
|
+
def convert(self, value, param, ctx):
|
|
473
|
+
return FQN.from_stage(value)
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
def identifier_argument(
|
|
477
|
+
sf_object: str,
|
|
478
|
+
example: str,
|
|
479
|
+
click_type: click.ParamType = IdentifierType(),
|
|
480
|
+
callback: Callable | None = None,
|
|
481
|
+
) -> typer.Argument:
|
|
518
482
|
return typer.Argument(
|
|
519
483
|
...,
|
|
520
484
|
help=f"Identifier of the {sf_object}. For example: {example}",
|
|
521
485
|
show_default=False,
|
|
486
|
+
click_type=click_type,
|
|
487
|
+
callback=callback,
|
|
488
|
+
)
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
def identifier_stage_argument(
|
|
492
|
+
sf_object: str, example: str, callback: Callable | None = None
|
|
493
|
+
) -> typer.Argument:
|
|
494
|
+
return identifier_argument(
|
|
495
|
+
sf_object, example, click_type=IdentifierStageType(), callback=callback
|
|
522
496
|
)
|
|
523
497
|
|
|
524
498
|
|
|
@@ -530,29 +504,12 @@ def execution_identifier_argument(sf_object: str, example: str) -> typer.Argumen
|
|
|
530
504
|
)
|
|
531
505
|
|
|
532
506
|
|
|
533
|
-
def register_project_definition(is_optional: bool) -> None:
|
|
534
|
-
project_path = cli_context_manager.project_path_arg
|
|
535
|
-
env_overrides_args = cli_context_manager.project_env_overrides_args
|
|
536
|
-
|
|
537
|
-
dm = DefinitionManager(project_path, {CONTEXT_KEY: {"env": env_overrides_args}})
|
|
538
|
-
project_definition = dm.project_definition
|
|
539
|
-
project_root = dm.project_root
|
|
540
|
-
template_context = dm.template_context
|
|
541
|
-
|
|
542
|
-
if not dm.has_definition_file and not is_optional:
|
|
543
|
-
raise MissingConfiguration(
|
|
544
|
-
"Cannot find project definition (snowflake.yml). Please provide a path to the project or run this command in a valid project directory."
|
|
545
|
-
)
|
|
546
|
-
|
|
547
|
-
cli_context_manager.set_project_definition(project_definition)
|
|
548
|
-
cli_context_manager.set_project_root(project_root)
|
|
549
|
-
cli_context_manager.set_template_context(template_context)
|
|
550
|
-
|
|
551
|
-
|
|
552
507
|
def project_definition_option(is_optional: bool):
|
|
553
|
-
def
|
|
554
|
-
|
|
555
|
-
|
|
508
|
+
def project_path_callback(project_path: str) -> str:
|
|
509
|
+
ctx_mgr = get_cli_context_manager()
|
|
510
|
+
ctx_mgr.project_path_arg = project_path
|
|
511
|
+
ctx_mgr.project_is_optional = is_optional
|
|
512
|
+
return project_path
|
|
556
513
|
|
|
557
514
|
return typer.Option(
|
|
558
515
|
None,
|
|
@@ -560,36 +517,26 @@ def project_definition_option(is_optional: bool):
|
|
|
560
517
|
"--project",
|
|
561
518
|
help=f"Path where Snowflake project resides. "
|
|
562
519
|
f"Defaults to current working directory.",
|
|
563
|
-
callback=
|
|
520
|
+
callback=project_path_callback,
|
|
564
521
|
show_default=False,
|
|
565
522
|
)
|
|
566
523
|
|
|
567
524
|
|
|
568
525
|
def project_env_overrides_option():
|
|
569
|
-
def project_env_overrides_callback(
|
|
526
|
+
def project_env_overrides_callback(
|
|
527
|
+
env_overrides_args_list: list[str],
|
|
528
|
+
) -> dict[str, str]:
|
|
570
529
|
env_overrides_args_map = {
|
|
571
530
|
v.key: v.value for v in parse_key_value_variables(env_overrides_args_list)
|
|
572
531
|
}
|
|
573
|
-
|
|
532
|
+
get_cli_context_manager().project_env_overrides_args = env_overrides_args_map
|
|
533
|
+
return env_overrides_args_map
|
|
574
534
|
|
|
575
535
|
return typer.Option(
|
|
576
536
|
[],
|
|
577
537
|
"--env",
|
|
578
|
-
help="String in format of key=value. Overrides variables from env section used for
|
|
579
|
-
callback=
|
|
580
|
-
show_default=False,
|
|
581
|
-
)
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
def readable_file_option(param_name: str, help_str: str) -> typer.Option:
|
|
585
|
-
return typer.Option(
|
|
586
|
-
None,
|
|
587
|
-
param_name,
|
|
588
|
-
exists=True,
|
|
589
|
-
file_okay=True,
|
|
590
|
-
dir_okay=False,
|
|
591
|
-
readable=True,
|
|
592
|
-
help=help_str,
|
|
538
|
+
help="String in format of key=value. Overrides variables from env section used for templates.",
|
|
539
|
+
callback=project_env_overrides_callback,
|
|
593
540
|
show_default=False,
|
|
594
541
|
)
|
|
595
542
|
|
|
@@ -612,29 +559,3 @@ def deprecated_flag_callback_enum(msg: str):
|
|
|
612
559
|
return value.value
|
|
613
560
|
|
|
614
561
|
return _warning_callback
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
@dataclass
|
|
618
|
-
class Variable:
|
|
619
|
-
key: str
|
|
620
|
-
value: str
|
|
621
|
-
|
|
622
|
-
def __init__(self, key: str, value: str):
|
|
623
|
-
self.key = key
|
|
624
|
-
self.value = value
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
def parse_key_value_variables(variables: Optional[List[str]]) -> List[Variable]:
|
|
628
|
-
"""Util for parsing key=value input. Useful for commands accepting multiple input options."""
|
|
629
|
-
if not variables:
|
|
630
|
-
return []
|
|
631
|
-
result: List[Variable] = []
|
|
632
|
-
if not variables:
|
|
633
|
-
return result
|
|
634
|
-
for p in variables:
|
|
635
|
-
if "=" not in p:
|
|
636
|
-
raise ClickException(f"Invalid variable: '{p}'")
|
|
637
|
-
|
|
638
|
-
key, value = p.split("=", 1)
|
|
639
|
-
result.append(Variable(key.strip(), value.strip()))
|
|
640
|
-
return result
|