snowflake-cli-labs 2.8.1__py3-none-any.whl → 3.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- snowflake/cli/__about__.py +1 -1
- snowflake/cli/{app → _app}/__main__.py +1 -1
- snowflake/cli/{app → _app}/cli_app.py +22 -13
- snowflake/cli/{app → _app}/commands_registration/builtin_plugins.py +15 -19
- snowflake/cli/{app → _app}/commands_registration/command_plugins_loader.py +9 -9
- snowflake/cli/{app → _app}/commands_registration/commands_registration_with_callbacks.py +4 -4
- snowflake/cli/{app → _app}/commands_registration/exception_logging.py +2 -2
- snowflake/cli/{app → _app}/commands_registration/typer_registration.py +2 -2
- snowflake/cli/{app → _app}/dev/docs/commands_docs_generator.py +30 -12
- snowflake/cli/{app → _app}/dev/docs/generator.py +3 -3
- snowflake/cli/{app → _app}/dev/docs/project_definition_docs_generator.py +4 -4
- snowflake/cli/{app → _app}/dev/docs/templates/usage.rst.jinja2 +14 -4
- snowflake/cli/{app → _app}/main_typer.py +2 -2
- snowflake/cli/{app → _app}/printing.py +2 -2
- snowflake/cli/_app/secret.py +9 -0
- snowflake/cli/{app → _app}/snow_connector.py +127 -61
- snowflake/cli/{app → _app}/telemetry.py +38 -7
- snowflake/cli/_app/version_check.py +74 -0
- snowflake/cli/{plugins → _plugins}/connection/commands.py +34 -11
- snowflake/cli/_plugins/connection/plugin_spec.py +30 -0
- snowflake/cli/{plugins → _plugins}/connection/util.py +16 -0
- snowflake/cli/{plugins → _plugins}/cortex/commands.py +54 -49
- snowflake/cli/{plugins → _plugins}/cortex/constants.py +1 -1
- snowflake/cli/{plugins → _plugins}/cortex/manager.py +5 -5
- snowflake/cli/{plugins → _plugins}/cortex/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/git/commands.py +11 -7
- snowflake/cli/{plugins → _plugins}/git/manager.py +55 -9
- snowflake/cli/{plugins → _plugins}/git/plugin_spec.py +1 -1
- snowflake/cli/_plugins/helpers/commands.py +90 -0
- snowflake/cli/{plugins/notebook → _plugins/helpers}/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/init/commands.py +2 -2
- snowflake/cli/{plugins → _plugins}/init/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/nativeapp/artifacts.py +24 -9
- snowflake/cli/_plugins/nativeapp/bundle_context.py +31 -0
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/artifact_processor.py +4 -4
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/compiler.py +37 -18
- snowflake/cli/_plugins/nativeapp/codegen/setup/native_app_setup_processor.py +249 -0
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/setup/setup_driver.py.source +5 -2
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/extension_function_utils.py +5 -5
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/models.py +1 -1
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/python_processor.py +29 -34
- snowflake/cli/_plugins/nativeapp/codegen/templates/templates_processor.py +114 -0
- snowflake/cli/{plugins → _plugins}/nativeapp/commands.py +252 -132
- snowflake/cli/{plugins → _plugins}/nativeapp/common_flags.py +1 -1
- snowflake/cli/_plugins/nativeapp/entities/application.py +878 -0
- snowflake/cli/_plugins/nativeapp/entities/application_package.py +1392 -0
- snowflake/cli/{plugins → _plugins}/nativeapp/exceptions.py +3 -12
- snowflake/cli/_plugins/nativeapp/manager.py +415 -0
- snowflake/cli/{plugins/connection → _plugins/nativeapp}/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/nativeapp/policy.py +3 -0
- snowflake/cli/{plugins → _plugins}/nativeapp/project_model.py +36 -20
- snowflake/cli/_plugins/nativeapp/run_processor.py +184 -0
- snowflake/cli/_plugins/nativeapp/same_account_install_method.py +70 -0
- snowflake/cli/_plugins/nativeapp/teardown_processor.py +70 -0
- snowflake/cli/_plugins/nativeapp/v2_conversions/v2_to_v1_decorator.py +262 -0
- snowflake/cli/{plugins → _plugins}/nativeapp/version/commands.py +20 -49
- snowflake/cli/_plugins/nativeapp/version/version_processor.py +98 -0
- snowflake/cli/{plugins → _plugins}/notebook/commands.py +3 -2
- snowflake/cli/{plugins → _plugins}/notebook/manager.py +5 -5
- snowflake/cli/{plugins/nativeapp → _plugins/notebook}/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/object/command_aliases.py +4 -4
- snowflake/cli/{plugins → _plugins}/object/commands.py +4 -5
- snowflake/cli/{plugins → _plugins}/object/manager.py +36 -15
- snowflake/cli/{plugins → _plugins}/object/plugin_spec.py +1 -1
- snowflake/cli/_plugins/snowpark/commands.py +450 -0
- snowflake/cli/_plugins/snowpark/common.py +268 -0
- snowflake/cli/{plugins → _plugins}/snowpark/models.py +0 -7
- snowflake/cli/{plugins → _plugins}/snowpark/package/anaconda_packages.py +2 -36
- snowflake/cli/{plugins → _plugins}/snowpark/package/commands.py +13 -74
- snowflake/cli/{plugins → _plugins}/snowpark/package/manager.py +2 -2
- snowflake/cli/{plugins → _plugins}/snowpark/package_utils.py +5 -5
- snowflake/cli/_plugins/snowpark/plugin_spec.py +30 -0
- snowflake/cli/_plugins/snowpark/snowpark_entity.py +29 -0
- snowflake/cli/_plugins/snowpark/snowpark_entity_model.py +173 -0
- snowflake/cli/_plugins/snowpark/snowpark_project_paths.py +109 -0
- snowflake/cli/{plugins → _plugins}/snowpark/snowpark_shared.py +0 -36
- snowflake/cli/{plugins → _plugins}/snowpark/zipper.py +16 -8
- snowflake/cli/{plugins → _plugins}/spcs/__init__.py +5 -7
- snowflake/cli/{plugins → _plugins}/spcs/compute_pool/commands.py +8 -8
- snowflake/cli/{plugins → _plugins}/spcs/compute_pool/manager.py +3 -3
- snowflake/cli/{plugins → _plugins}/spcs/image_registry/commands.py +3 -3
- snowflake/cli/{plugins → _plugins}/spcs/image_repository/commands.py +6 -6
- snowflake/cli/{plugins → _plugins}/spcs/image_repository/manager.py +1 -1
- snowflake/cli/{plugins → _plugins}/spcs/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/spcs/services/commands.py +44 -11
- snowflake/cli/{plugins → _plugins}/spcs/services/manager.py +43 -5
- snowflake/cli/{plugins → _plugins}/sql/commands.py +20 -17
- snowflake/cli/{plugins → _plugins}/sql/manager.py +1 -1
- snowflake/cli/{plugins → _plugins}/sql/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/stage/commands.py +15 -14
- snowflake/cli/{plugins → _plugins}/stage/diff.py +1 -47
- snowflake/cli/{plugins → _plugins}/stage/manager.py +12 -7
- snowflake/cli/{plugins → _plugins}/stage/plugin_spec.py +1 -1
- snowflake/cli/_plugins/stage/utils.py +54 -0
- snowflake/cli/{plugins → _plugins}/streamlit/commands.py +64 -48
- snowflake/cli/{plugins → _plugins}/streamlit/manager.py +67 -69
- snowflake/cli/_plugins/streamlit/plugin_spec.py +30 -0
- snowflake/cli/_plugins/streamlit/streamlit_entity.py +12 -0
- snowflake/cli/_plugins/streamlit/streamlit_entity_model.py +66 -0
- snowflake/cli/_plugins/workspace/action_context.py +18 -0
- snowflake/cli/_plugins/workspace/commands.py +306 -0
- snowflake/cli/_plugins/workspace/manager.py +74 -0
- snowflake/cli/_plugins/workspace/plugin_spec.py +30 -0
- snowflake/cli/api/cli_global_context.py +152 -295
- snowflake/cli/api/commands/common.py +25 -0
- snowflake/cli/api/commands/decorators.py +19 -4
- snowflake/cli/api/commands/experimental_behaviour.py +2 -3
- snowflake/cli/api/commands/flags.py +127 -228
- snowflake/cli/api/commands/overrideable_parameter.py +143 -0
- snowflake/cli/api/commands/snow_typer.py +21 -11
- snowflake/cli/api/commands/utils.py +18 -0
- snowflake/cli/api/config.py +44 -12
- snowflake/cli/api/connections.py +216 -0
- snowflake/cli/api/console/abc.py +8 -3
- snowflake/cli/api/constants.py +11 -0
- snowflake/cli/api/entities/common.py +56 -0
- snowflake/cli/api/entities/utils.py +370 -0
- snowflake/cli/api/errno.py +1 -0
- snowflake/cli/api/exceptions.py +31 -5
- snowflake/cli/api/feature_flags.py +0 -1
- snowflake/cli/api/identifiers.py +28 -5
- snowflake/cli/api/metrics.py +92 -0
- snowflake/cli/api/project/definition.py +48 -6
- snowflake/cli/api/project/definition_conversion.py +400 -0
- snowflake/cli/api/project/definition_manager.py +16 -5
- snowflake/cli/api/project/project_verification.py +3 -3
- snowflake/cli/api/project/schemas/entities/common.py +91 -16
- snowflake/cli/api/project/schemas/entities/entities.py +37 -6
- snowflake/cli/api/project/schemas/project_definition.py +180 -49
- snowflake/cli/api/project/schemas/updatable_model.py +11 -3
- snowflake/cli/api/project/schemas/v1/__init__.py +0 -0
- snowflake/cli/api/project/schemas/{identifier_model.py → v1/identifier_model.py} +3 -1
- snowflake/cli/api/project/schemas/v1/native_app/__init__.py +0 -0
- snowflake/cli/api/project/schemas/{native_app → v1/native_app}/application.py +8 -9
- snowflake/cli/api/project/schemas/{native_app → v1/native_app}/native_app.py +4 -4
- snowflake/cli/api/project/schemas/{native_app → v1/native_app}/package.py +7 -1
- snowflake/cli/api/project/schemas/v1/snowpark/__init__.py +0 -0
- snowflake/cli/api/project/schemas/{snowpark → v1/snowpark}/callable.py +2 -2
- snowflake/cli/api/project/schemas/{snowpark → v1/snowpark}/snowpark.py +2 -2
- snowflake/cli/api/project/schemas/v1/streamlit/__init__.py +0 -0
- snowflake/cli/api/project/schemas/{streamlit → v1/streamlit}/streamlit.py +2 -1
- snowflake/cli/api/project/util.py +23 -6
- snowflake/cli/api/rendering/jinja.py +14 -8
- snowflake/cli/api/rendering/project_definition_templates.py +5 -1
- snowflake/cli/api/rendering/sql_templates.py +56 -11
- snowflake/cli/api/rest_api.py +11 -5
- snowflake/cli/api/secure_path.py +16 -18
- snowflake/cli/api/secure_utils.py +90 -1
- snowflake/cli/api/sql_execution.py +43 -23
- snowflake/cli/api/utils/definition_rendering.py +45 -13
- {snowflake_cli_labs-2.8.1.dist-info → snowflake_cli_labs-3.0.0.dist-info}/METADATA +20 -18
- snowflake_cli_labs-3.0.0.dist-info/RECORD +242 -0
- snowflake_cli_labs-3.0.0.dist-info/entry_points.txt +2 -0
- snowflake/cli/api/commands/project_initialisation.py +0 -65
- snowflake/cli/api/commands/typer_pre_execute.py +0 -26
- snowflake/cli/api/project/schemas/entities/application_entity.py +0 -44
- snowflake/cli/api/project/schemas/entities/application_package_entity.py +0 -66
- snowflake/cli/app/build_and_push.sh +0 -8
- snowflake/cli/plugins/nativeapp/codegen/setup/native_app_setup_processor.py +0 -172
- snowflake/cli/plugins/nativeapp/init.py +0 -345
- snowflake/cli/plugins/nativeapp/manager.py +0 -823
- snowflake/cli/plugins/nativeapp/run_processor.py +0 -389
- snowflake/cli/plugins/nativeapp/teardown_processor.py +0 -301
- snowflake/cli/plugins/nativeapp/v2_conversions/v2_to_v1_decorator.py +0 -135
- snowflake/cli/plugins/nativeapp/version/version_processor.py +0 -362
- snowflake/cli/plugins/object_stage_deprecated/__init__.py +0 -15
- snowflake/cli/plugins/object_stage_deprecated/commands.py +0 -122
- snowflake/cli/plugins/object_stage_deprecated/plugin_spec.py +0 -32
- snowflake/cli/plugins/snowpark/commands.py +0 -546
- snowflake/cli/plugins/snowpark/common.py +0 -307
- snowflake/cli/plugins/snowpark/manager.py +0 -109
- snowflake/cli/plugins/snowpark/plugin_spec.py +0 -30
- snowflake/cli/plugins/snowpark/snowpark_package_paths.py +0 -65
- snowflake/cli/plugins/spcs/jobs/commands.py +0 -78
- snowflake/cli/plugins/spcs/jobs/manager.py +0 -53
- snowflake/cli/plugins/streamlit/__init__.py +0 -13
- snowflake/cli/plugins/streamlit/plugin_spec.py +0 -30
- snowflake/cli/plugins/workspace/__init__.py +0 -13
- snowflake/cli/plugins/workspace/commands.py +0 -35
- snowflake/cli/plugins/workspace/plugin_spec.py +0 -30
- snowflake/cli/templates/default_snowpark/.gitignore +0 -4
- snowflake/cli/templates/default_snowpark/app/common.py +0 -2
- snowflake/cli/templates/default_snowpark/app/functions.py +0 -15
- snowflake/cli/templates/default_snowpark/app/procedures.py +0 -22
- snowflake/cli/templates/default_snowpark/requirements.txt +0 -1
- snowflake/cli/templates/default_snowpark/snowflake.yml +0 -23
- snowflake/cli/templates/default_streamlit/.gitignore +0 -4
- snowflake/cli/templates/default_streamlit/common/hello.py +0 -2
- snowflake/cli/templates/default_streamlit/environment.yml +0 -6
- snowflake/cli/templates/default_streamlit/pages/my_page.py +0 -3
- snowflake/cli/templates/default_streamlit/snowflake.yml +0 -10
- snowflake/cli/templates/default_streamlit/streamlit_app.py +0 -4
- snowflake_cli_labs-2.8.1.dist-info/RECORD +0 -240
- snowflake_cli_labs-2.8.1.dist-info/entry_points.txt +0 -2
- /snowflake/cli/{app → _app}/__init__.py +0 -0
- /snowflake/cli/{api/project/schemas/native_app → _app/api_impl}/__init__.py +0 -0
- /snowflake/cli/{api/project/schemas/snowpark → _app/api_impl/plugin}/__init__.py +0 -0
- /snowflake/cli/{app → _app}/api_impl/plugin/plugin_config_provider_impl.py +0 -0
- /snowflake/cli/{app → _app}/commands_registration/__init__.py +0 -0
- /snowflake/cli/{app → _app}/commands_registration/threadsafe.py +0 -0
- /snowflake/cli/{app → _app}/constants.py +0 -0
- /snowflake/cli/{api/project/schemas/streamlit → _app/dev}/__init__.py +0 -0
- /snowflake/cli/{app → _app}/dev/commands_structure.py +0 -0
- /snowflake/cli/{app/api_impl → _app/dev/docs}/__init__.py +0 -0
- /snowflake/cli/{app → _app}/dev/docs/project_definition_generate_json_schema.py +0 -0
- /snowflake/cli/{app → _app}/dev/docs/template_utils.py +0 -0
- /snowflake/cli/{app → _app}/dev/docs/templates/definition_description.rst.jinja2 +0 -0
- /snowflake/cli/{app → _app}/dev/docs/templates/overview.rst.jinja2 +0 -0
- /snowflake/cli/{app → _app}/dev/pycharm_remote_debug.py +0 -0
- /snowflake/cli/{app → _app}/loggers.py +0 -0
- /snowflake/cli/{app/api_impl/plugin → _plugins}/__init__.py +0 -0
- /snowflake/cli/{app/dev → _plugins/connection}/__init__.py +0 -0
- /snowflake/cli/{app/dev/docs → _plugins/cortex}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/cortex/types.py +0 -0
- /snowflake/cli/{plugins → _plugins/git}/__init__.py +0 -0
- /snowflake/cli/{plugins/connection → _plugins/helpers}/__init__.py +0 -0
- /snowflake/cli/{plugins/cortex → _plugins/init}/__init__.py +0 -0
- /snowflake/cli/{plugins/git → _plugins/nativeapp}/__init__.py +0 -0
- /snowflake/cli/{plugins/init → _plugins/nativeapp/codegen}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/codegen/sandbox.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/callback_source.py.jinja +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/constants.py +0 -0
- /snowflake/cli/{templates/default_snowpark/app → _plugins/nativeapp/entities}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/feature_flags.py +0 -0
- /snowflake/cli/{plugins → _plugins}/nativeapp/utils.py +0 -0
- /snowflake/cli/{plugins/nativeapp → _plugins/nativeapp/version}/__init__.py +0 -0
- /snowflake/cli/{plugins/nativeapp/codegen → _plugins/notebook}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/notebook/exceptions.py +0 -0
- /snowflake/cli/{plugins → _plugins}/notebook/types.py +0 -0
- /snowflake/cli/{plugins/nativeapp/version → _plugins/object}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/object/common.py +0 -0
- /snowflake/cli/{plugins/notebook → _plugins/snowpark}/__init__.py +0 -0
- /snowflake/cli/{plugins/object → _plugins/snowpark/package}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/snowpark/package/utils.py +0 -0
- /snowflake/cli/{plugins → _plugins}/spcs/common.py +0 -0
- /snowflake/cli/{plugins/snowpark → _plugins/spcs/compute_pool}/__init__.py +0 -0
- /snowflake/cli/{plugins/snowpark/package → _plugins/spcs/image_registry}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/spcs/image_registry/manager.py +0 -0
- /snowflake/cli/{plugins/spcs/compute_pool → _plugins/spcs/image_repository}/__init__.py +0 -0
- /snowflake/cli/{plugins/spcs/image_registry → _plugins/spcs/services}/__init__.py +0 -0
- /snowflake/cli/{plugins/spcs/image_repository → _plugins/sql}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/sql/snowsql_templating.py +0 -0
- /snowflake/cli/{plugins/spcs/jobs → _plugins/stage}/__init__.py +0 -0
- /snowflake/cli/{plugins → _plugins}/stage/md5.py +0 -0
- /snowflake/cli/{plugins/spcs/services → _plugins/streamlit}/__init__.py +0 -0
- /snowflake/cli/{plugins/sql → _plugins/workspace}/__init__.py +0 -0
- /snowflake/cli/{plugins/stage → api/project/schemas/entities}/__init__.py +0 -0
- /snowflake/cli/api/project/schemas/{native_app → v1/native_app}/path_mapping.py +0 -0
- /snowflake/cli/api/project/schemas/{snowpark → v1/snowpark}/argument.py +0 -0
- {snowflake_cli_labs-2.8.1.dist-info → snowflake_cli_labs-3.0.0.dist-info}/WHEEL +0 -0
- {snowflake_cli_labs-2.8.1.dist-info → snowflake_cli_labs-3.0.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -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,23 +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.exceptions import MissingConfiguration
|
|
31
34
|
from snowflake.cli.api.identifiers import FQN
|
|
32
35
|
from snowflake.cli.api.output.formats import OutputFormat
|
|
33
|
-
from snowflake.cli.api.project.definition_manager import DefinitionManager
|
|
34
|
-
from snowflake.cli.api.rendering.jinja import CONTEXT_KEY
|
|
35
36
|
|
|
36
37
|
DEFAULT_CONTEXT_SETTINGS = {"help_option_names": ["--help", "-h"]}
|
|
37
38
|
|
|
@@ -39,115 +40,39 @@ _CONNECTION_SECTION = "Connection configuration"
|
|
|
39
40
|
_CLI_BEHAVIOUR = "Global configuration"
|
|
40
41
|
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"""
|
|
49
|
-
Class that allows you to generate instances of typer.models.OptionInfo with some default properties while allowing
|
|
50
|
-
specific values to be overridden.
|
|
51
|
-
|
|
52
|
-
Custom parameters:
|
|
53
|
-
- mutually_exclusive (Tuple[str]|List[str]): A list of parameter names that this Option is not compatible with. If this Option has
|
|
54
|
-
a truthy value and any of the other parameters in the mutually_exclusive list has a truthy value, a
|
|
55
|
-
ClickException will be thrown. Note that mutually_exclusive can contain an option's own name but does not require
|
|
56
|
-
it.
|
|
57
|
-
"""
|
|
58
|
-
|
|
59
|
-
def __init__(
|
|
60
|
-
self,
|
|
61
|
-
default: Any,
|
|
62
|
-
*param_decls: str,
|
|
63
|
-
mutually_exclusive: Optional[List[str] | Tuple[str]] = None,
|
|
64
|
-
**kwargs,
|
|
65
|
-
):
|
|
66
|
-
self.default = default
|
|
67
|
-
self.param_decls = param_decls
|
|
68
|
-
self.mutually_exclusive = mutually_exclusive
|
|
69
|
-
self.kwargs = kwargs
|
|
70
|
-
|
|
71
|
-
def __call__(self, **kwargs) -> typer.models.OptionInfo:
|
|
72
|
-
"""
|
|
73
|
-
Returns a typer.models.OptionInfo instance initialized with the specified default values along with any overrides
|
|
74
|
-
from kwargs. Note that if you are overriding param_decls, you must pass an iterable of strings, you cannot use
|
|
75
|
-
positional arguments like you can with typer.Option. Does not modify the original instance.
|
|
76
|
-
"""
|
|
77
|
-
default = kwargs.get("default", self.default)
|
|
78
|
-
param_decls = kwargs.get("param_decls", self.param_decls)
|
|
79
|
-
mutually_exclusive = kwargs.get("mutually_exclusive", self.mutually_exclusive)
|
|
80
|
-
if not isinstance(param_decls, list) and not isinstance(param_decls, tuple):
|
|
81
|
-
raise TypeError("param_decls must be a list or tuple")
|
|
82
|
-
passed_kwargs = self.kwargs.copy()
|
|
83
|
-
passed_kwargs.update(kwargs)
|
|
84
|
-
if passed_kwargs.get("callback", None) or mutually_exclusive:
|
|
85
|
-
passed_kwargs["callback"] = self._callback_factory(
|
|
86
|
-
passed_kwargs.get("callback", None), mutually_exclusive
|
|
87
|
-
)
|
|
88
|
-
for non_kwarg in ["default", "param_decls", "mutually_exclusive"]:
|
|
89
|
-
passed_kwargs.pop(non_kwarg, None)
|
|
90
|
-
return typer.Option(default, *param_decls, **passed_kwargs)
|
|
91
|
-
|
|
92
|
-
class InvalidCallbackSignature(ClickException):
|
|
93
|
-
def __init__(self, callback):
|
|
94
|
-
super().__init__(
|
|
95
|
-
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)"
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
def _callback_factory(
|
|
99
|
-
self, callback, mutually_exclusive: Optional[List[str] | Tuple[str]]
|
|
100
|
-
):
|
|
101
|
-
callback = callback if callback else lambda x: x
|
|
102
|
-
|
|
103
|
-
# inspect existing_callback to make sure signature is valid
|
|
104
|
-
existing_params = signature(callback).parameters
|
|
105
|
-
# at most one parameter with each type in [typer.Context, typer.CallbackParam, any other type]
|
|
106
|
-
limits = [
|
|
107
|
-
lambda x: x == typer.Context,
|
|
108
|
-
lambda x: x == typer.CallbackParam,
|
|
109
|
-
lambda x: x != typer.Context and x != typer.CallbackParam,
|
|
110
|
-
]
|
|
111
|
-
for limit in limits:
|
|
112
|
-
if len([v for v in existing_params.values() if limit(v.annotation)]) > 1:
|
|
113
|
-
raise self.InvalidCallbackSignature(callback)
|
|
114
|
-
|
|
115
|
-
def generated_callback(ctx: typer.Context, param: typer.CallbackParam, value):
|
|
116
|
-
if mutually_exclusive:
|
|
117
|
-
for name in mutually_exclusive:
|
|
118
|
-
if value and ctx.params.get(
|
|
119
|
-
name, False
|
|
120
|
-
): # if the current parameter is set to True and a previous parameter is also Truthy
|
|
121
|
-
curr_opt = param.opts[0]
|
|
122
|
-
other_opt = [x for x in ctx.command.params if x.name == name][
|
|
123
|
-
0
|
|
124
|
-
].opts[0]
|
|
125
|
-
raise click.ClickException(
|
|
126
|
-
f"Options '{curr_opt}' and '{other_opt}' are incompatible."
|
|
127
|
-
)
|
|
128
|
-
|
|
129
|
-
# pass args to existing callback based on its signature (this is how Typer infers callback args)
|
|
130
|
-
passed_params = {}
|
|
131
|
-
for existing_param in existing_params:
|
|
132
|
-
annotation = existing_params[existing_param].annotation
|
|
133
|
-
if annotation == typer.Context:
|
|
134
|
-
passed_params[existing_param] = ctx
|
|
135
|
-
elif annotation == typer.CallbackParam:
|
|
136
|
-
passed_params[existing_param] = param
|
|
137
|
-
else:
|
|
138
|
-
passed_params[existing_param] = value
|
|
139
|
-
return callback(**passed_params)
|
|
140
|
-
|
|
141
|
-
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
|
+
)
|
|
142
49
|
|
|
50
|
+
def callback(value):
|
|
51
|
+
try:
|
|
52
|
+
if click.get_current_context().resilient_parsing:
|
|
53
|
+
return
|
|
54
|
+
except RuntimeError:
|
|
55
|
+
pass
|
|
56
|
+
|
|
57
|
+
setattr(get_cli_context_manager().connection_context, prop, value)
|
|
58
|
+
return value
|
|
59
|
+
|
|
60
|
+
return callback
|
|
143
61
|
|
|
144
|
-
from snowflake.cli.api.config import get_all_connections
|
|
145
62
|
|
|
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}")
|
|
146
67
|
|
|
147
|
-
def _callback(provide_setter: Callable[[], Callable[[Any], Any]]):
|
|
148
68
|
def callback(value):
|
|
149
|
-
|
|
150
|
-
|
|
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)
|
|
151
76
|
return value
|
|
152
77
|
|
|
153
78
|
return callback
|
|
@@ -159,12 +84,10 @@ ConnectionOption = typer.Option(
|
|
|
159
84
|
"-c",
|
|
160
85
|
"--environment",
|
|
161
86
|
help=f"Name of the connection, as defined in your `config.toml`. Default: `default`.",
|
|
162
|
-
callback=
|
|
163
|
-
lambda: cli_context_manager.connection_context.set_connection_name
|
|
164
|
-
),
|
|
87
|
+
callback=_connection_callback("connection_name"),
|
|
165
88
|
show_default=False,
|
|
166
89
|
rich_help_panel=_CONNECTION_SECTION,
|
|
167
|
-
|
|
90
|
+
shell_complete=lambda _, __, ___: list(get_all_connections()),
|
|
168
91
|
)
|
|
169
92
|
|
|
170
93
|
TemporaryConnectionOption = typer.Option(
|
|
@@ -172,19 +95,35 @@ TemporaryConnectionOption = typer.Option(
|
|
|
172
95
|
"--temporary-connection",
|
|
173
96
|
"-x",
|
|
174
97
|
help="Uses connection defined with command line parameters, instead of one defined in config",
|
|
175
|
-
callback=
|
|
176
|
-
lambda: cli_context_manager.connection_context.set_temporary_connection
|
|
177
|
-
),
|
|
98
|
+
callback=_connection_callback("temporary_connection"),
|
|
178
99
|
is_flag=True,
|
|
179
100
|
rich_help_panel=_CONNECTION_SECTION,
|
|
180
101
|
)
|
|
181
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
|
+
|
|
182
121
|
AccountOption = typer.Option(
|
|
183
122
|
None,
|
|
184
123
|
"--account",
|
|
185
124
|
"--accountname",
|
|
186
125
|
help="Name assigned to your Snowflake account. Overrides the value specified for the connection.",
|
|
187
|
-
callback=
|
|
126
|
+
callback=_connection_callback("account"),
|
|
188
127
|
show_default=False,
|
|
189
128
|
rich_help_panel=_CONNECTION_SECTION,
|
|
190
129
|
)
|
|
@@ -194,7 +133,7 @@ UserOption = typer.Option(
|
|
|
194
133
|
"--user",
|
|
195
134
|
"--username",
|
|
196
135
|
help="Username to connect to Snowflake. Overrides the value specified for the connection.",
|
|
197
|
-
callback=
|
|
136
|
+
callback=_connection_callback("user"),
|
|
198
137
|
show_default=False,
|
|
199
138
|
rich_help_panel=_CONNECTION_SECTION,
|
|
200
139
|
)
|
|
@@ -207,7 +146,7 @@ def _password_callback(value: str):
|
|
|
207
146
|
if value:
|
|
208
147
|
cli_console.message(PLAIN_PASSWORD_MSG)
|
|
209
148
|
|
|
210
|
-
return
|
|
149
|
+
return _connection_callback("password")(value)
|
|
211
150
|
|
|
212
151
|
|
|
213
152
|
PasswordOption = typer.Option(
|
|
@@ -225,21 +164,18 @@ AuthenticatorOption = typer.Option(
|
|
|
225
164
|
"--authenticator",
|
|
226
165
|
help="Snowflake authenticator. Overrides the value specified for the connection.",
|
|
227
166
|
hide_input=True,
|
|
228
|
-
callback=
|
|
229
|
-
lambda: cli_context_manager.connection_context.set_authenticator
|
|
230
|
-
),
|
|
167
|
+
callback=_connection_callback("authenticator"),
|
|
231
168
|
show_default=False,
|
|
232
169
|
rich_help_panel=_CONNECTION_SECTION,
|
|
233
170
|
)
|
|
234
171
|
|
|
235
172
|
PrivateKeyPathOption = typer.Option(
|
|
236
173
|
None,
|
|
174
|
+
"--private-key-file",
|
|
237
175
|
"--private-key-path",
|
|
238
|
-
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.",
|
|
239
177
|
hide_input=True,
|
|
240
|
-
callback=
|
|
241
|
-
lambda: cli_context_manager.connection_context.set_private_key_path
|
|
242
|
-
),
|
|
178
|
+
callback=_connection_callback("private_key_file"),
|
|
243
179
|
show_default=False,
|
|
244
180
|
rich_help_panel=_CONNECTION_SECTION,
|
|
245
181
|
exists=True,
|
|
@@ -252,9 +188,7 @@ SessionTokenOption = typer.Option(
|
|
|
252
188
|
"--session-token",
|
|
253
189
|
help="Snowflake session token. Can be used only in conjunction with --master-token. Overrides the value specified for the connection.",
|
|
254
190
|
hide_input=True,
|
|
255
|
-
callback=
|
|
256
|
-
lambda: cli_context_manager.connection_context.set_session_token
|
|
257
|
-
),
|
|
191
|
+
callback=_connection_callback("session_token"),
|
|
258
192
|
show_default=False,
|
|
259
193
|
rich_help_panel=_CONNECTION_SECTION,
|
|
260
194
|
exists=True,
|
|
@@ -268,7 +202,7 @@ MasterTokenOption = typer.Option(
|
|
|
268
202
|
"--master-token",
|
|
269
203
|
help="Snowflake master token. Can be used only in conjunction with --session-token. Overrides the value specified for the connection.",
|
|
270
204
|
hide_input=True,
|
|
271
|
-
callback=
|
|
205
|
+
callback=_connection_callback("master_token"),
|
|
272
206
|
show_default=False,
|
|
273
207
|
rich_help_panel=_CONNECTION_SECTION,
|
|
274
208
|
exists=True,
|
|
@@ -281,9 +215,7 @@ TokenFilePathOption = typer.Option(
|
|
|
281
215
|
None,
|
|
282
216
|
"--token-file-path",
|
|
283
217
|
help="Path to file with an OAuth token that should be used when connecting to Snowflake",
|
|
284
|
-
callback=
|
|
285
|
-
lambda: cli_context_manager.connection_context.set_token_file_path
|
|
286
|
-
),
|
|
218
|
+
callback=_connection_callback("token_file_path"),
|
|
287
219
|
show_default=False,
|
|
288
220
|
rich_help_panel=_CONNECTION_SECTION,
|
|
289
221
|
exists=True,
|
|
@@ -296,7 +228,7 @@ DatabaseOption = typer.Option(
|
|
|
296
228
|
"--database",
|
|
297
229
|
"--dbname",
|
|
298
230
|
help="Database to use. Overrides the value specified for the connection.",
|
|
299
|
-
callback=
|
|
231
|
+
callback=_connection_callback("database"),
|
|
300
232
|
show_default=False,
|
|
301
233
|
rich_help_panel=_CONNECTION_SECTION,
|
|
302
234
|
)
|
|
@@ -306,7 +238,7 @@ SchemaOption = typer.Option(
|
|
|
306
238
|
"--schema",
|
|
307
239
|
"--schemaname",
|
|
308
240
|
help="Database schema to use. Overrides the value specified for the connection.",
|
|
309
|
-
callback=
|
|
241
|
+
callback=_connection_callback("schema"),
|
|
310
242
|
show_default=False,
|
|
311
243
|
rich_help_panel=_CONNECTION_SECTION,
|
|
312
244
|
)
|
|
@@ -316,7 +248,7 @@ RoleOption = typer.Option(
|
|
|
316
248
|
"--role",
|
|
317
249
|
"--rolename",
|
|
318
250
|
help="Role to use. Overrides the value specified for the connection.",
|
|
319
|
-
callback=
|
|
251
|
+
callback=_connection_callback("role"),
|
|
320
252
|
show_default=False,
|
|
321
253
|
rich_help_panel=_CONNECTION_SECTION,
|
|
322
254
|
)
|
|
@@ -325,7 +257,7 @@ WarehouseOption = typer.Option(
|
|
|
325
257
|
None,
|
|
326
258
|
"--warehouse",
|
|
327
259
|
help="Warehouse to use. Overrides the value specified for the connection.",
|
|
328
|
-
callback=
|
|
260
|
+
callback=_connection_callback("warehouse"),
|
|
329
261
|
show_default=False,
|
|
330
262
|
rich_help_panel=_CONNECTION_SECTION,
|
|
331
263
|
)
|
|
@@ -334,7 +266,7 @@ MfaPasscodeOption = typer.Option(
|
|
|
334
266
|
None,
|
|
335
267
|
"--mfa-passcode",
|
|
336
268
|
help="Token to use for multi-factor authentication (MFA)",
|
|
337
|
-
callback=
|
|
269
|
+
callback=_connection_callback("mfa_passcode"),
|
|
338
270
|
prompt="MFA passcode",
|
|
339
271
|
prompt_required=False,
|
|
340
272
|
show_default=False,
|
|
@@ -345,7 +277,7 @@ EnableDiagOption = typer.Option(
|
|
|
345
277
|
False,
|
|
346
278
|
"--enable-diag",
|
|
347
279
|
help="Run python connector diagnostic test",
|
|
348
|
-
callback=
|
|
280
|
+
callback=_connection_callback("enable_diag"),
|
|
349
281
|
show_default=False,
|
|
350
282
|
is_flag=True,
|
|
351
283
|
rich_help_panel=_CONNECTION_SECTION,
|
|
@@ -359,12 +291,12 @@ _DIAG_LOG_DEFAULT_VALUE = "<temporary_directory>"
|
|
|
359
291
|
def _diag_log_path_callback(path: str):
|
|
360
292
|
if path == _DIAG_LOG_DEFAULT_VALUE:
|
|
361
293
|
path = tempfile.gettempdir()
|
|
362
|
-
|
|
294
|
+
get_cli_context_manager().connection_context.diag_log_path = Path(path)
|
|
363
295
|
return path
|
|
364
296
|
|
|
365
297
|
|
|
366
298
|
DiagLogPathOption: Path = typer.Option(
|
|
367
|
-
|
|
299
|
+
_DIAG_LOG_DEFAULT_VALUE,
|
|
368
300
|
"--diag-log-path",
|
|
369
301
|
help="Diagnostic report path",
|
|
370
302
|
callback=_diag_log_path_callback,
|
|
@@ -378,9 +310,7 @@ DiagAllowlistPathOption: Path = typer.Option(
|
|
|
378
310
|
None,
|
|
379
311
|
"--diag-allowlist-path",
|
|
380
312
|
help="Diagnostic report path to optional allowlist",
|
|
381
|
-
callback=
|
|
382
|
-
lambda: cli_context_manager.connection_context.set_diag_allowlist_path
|
|
383
|
-
),
|
|
313
|
+
callback=_connection_callback("diag_allowlist_path"),
|
|
384
314
|
show_default=False,
|
|
385
315
|
rich_help_panel=_CONNECTION_SECTION,
|
|
386
316
|
exists=True,
|
|
@@ -392,7 +322,7 @@ OutputFormatOption = typer.Option(
|
|
|
392
322
|
"--format",
|
|
393
323
|
help="Specifies the output format.",
|
|
394
324
|
case_sensitive=False,
|
|
395
|
-
callback=
|
|
325
|
+
callback=_context_callback("output_format"),
|
|
396
326
|
rich_help_panel=_CLI_BEHAVIOUR,
|
|
397
327
|
)
|
|
398
328
|
|
|
@@ -400,7 +330,7 @@ SilentOption = typer.Option(
|
|
|
400
330
|
False,
|
|
401
331
|
"--silent",
|
|
402
332
|
help="Turns off intermediate output to console.",
|
|
403
|
-
callback=
|
|
333
|
+
callback=_context_callback("silent"),
|
|
404
334
|
is_flag=True,
|
|
405
335
|
rich_help_panel=_CLI_BEHAVIOUR,
|
|
406
336
|
is_eager=True,
|
|
@@ -411,7 +341,7 @@ VerboseOption = typer.Option(
|
|
|
411
341
|
"--verbose",
|
|
412
342
|
"-v",
|
|
413
343
|
help="Displays log entries for log levels `info` and higher.",
|
|
414
|
-
callback=
|
|
344
|
+
callback=_context_callback("verbose"),
|
|
415
345
|
is_flag=True,
|
|
416
346
|
rich_help_panel=_CLI_BEHAVIOUR,
|
|
417
347
|
)
|
|
@@ -420,7 +350,7 @@ DebugOption = typer.Option(
|
|
|
420
350
|
False,
|
|
421
351
|
"--debug",
|
|
422
352
|
help="Displays log entries for log levels `debug` and higher; debug logs contains additional information.",
|
|
423
|
-
callback=
|
|
353
|
+
callback=_context_callback("enable_tracebacks"),
|
|
424
354
|
is_flag=True,
|
|
425
355
|
rich_help_panel=_CLI_BEHAVIOUR,
|
|
426
356
|
)
|
|
@@ -461,6 +391,10 @@ OnErrorOption = typer.Option(
|
|
|
461
391
|
NoInteractiveOption = typer.Option(False, "--no-interactive", help="Disable prompting.")
|
|
462
392
|
|
|
463
393
|
|
|
394
|
+
def entity_argument(entity_type: str) -> typer.Argument:
|
|
395
|
+
return typer.Argument(None, help=f"ID of {entity_type} entity.")
|
|
396
|
+
|
|
397
|
+
|
|
464
398
|
def variables_option(description: str):
|
|
465
399
|
return typer.Option(
|
|
466
400
|
None,
|
|
@@ -519,24 +453,49 @@ def experimental_option(
|
|
|
519
453
|
"--experimental",
|
|
520
454
|
help=help_text,
|
|
521
455
|
hidden=True,
|
|
522
|
-
callback=
|
|
456
|
+
callback=_context_callback("experimental"),
|
|
523
457
|
is_flag=True,
|
|
524
458
|
rich_help_panel=_CLI_BEHAVIOUR,
|
|
525
459
|
)
|
|
526
460
|
|
|
527
461
|
|
|
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
|
+
|
|
528
476
|
def identifier_argument(
|
|
529
|
-
sf_object: str,
|
|
477
|
+
sf_object: str,
|
|
478
|
+
example: str,
|
|
479
|
+
click_type: click.ParamType = IdentifierType(),
|
|
480
|
+
callback: Callable | None = None,
|
|
530
481
|
) -> typer.Argument:
|
|
531
482
|
return typer.Argument(
|
|
532
483
|
...,
|
|
533
484
|
help=f"Identifier of the {sf_object}. For example: {example}",
|
|
534
485
|
show_default=False,
|
|
535
|
-
click_type=
|
|
486
|
+
click_type=click_type,
|
|
536
487
|
callback=callback,
|
|
537
488
|
)
|
|
538
489
|
|
|
539
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
|
|
496
|
+
)
|
|
497
|
+
|
|
498
|
+
|
|
540
499
|
def execution_identifier_argument(sf_object: str, example: str) -> typer.Argument:
|
|
541
500
|
return typer.Argument(
|
|
542
501
|
...,
|
|
@@ -545,29 +504,12 @@ def execution_identifier_argument(sf_object: str, example: str) -> typer.Argumen
|
|
|
545
504
|
)
|
|
546
505
|
|
|
547
506
|
|
|
548
|
-
def register_project_definition(is_optional: bool) -> None:
|
|
549
|
-
project_path = cli_context_manager.project_path_arg
|
|
550
|
-
env_overrides_args = cli_context_manager.project_env_overrides_args
|
|
551
|
-
|
|
552
|
-
dm = DefinitionManager(project_path, {CONTEXT_KEY: {"env": env_overrides_args}})
|
|
553
|
-
project_definition = dm.project_definition
|
|
554
|
-
project_root = dm.project_root
|
|
555
|
-
template_context = dm.template_context
|
|
556
|
-
|
|
557
|
-
if not dm.has_definition_file and not is_optional:
|
|
558
|
-
raise MissingConfiguration(
|
|
559
|
-
"Cannot find project definition (snowflake.yml). Please provide a path to the project or run this command in a valid project directory."
|
|
560
|
-
)
|
|
561
|
-
|
|
562
|
-
cli_context_manager.set_project_definition(project_definition)
|
|
563
|
-
cli_context_manager.set_project_root(project_root)
|
|
564
|
-
cli_context_manager.set_template_context(template_context)
|
|
565
|
-
|
|
566
|
-
|
|
567
507
|
def project_definition_option(is_optional: bool):
|
|
568
|
-
def
|
|
569
|
-
|
|
570
|
-
|
|
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
|
|
571
513
|
|
|
572
514
|
return typer.Option(
|
|
573
515
|
None,
|
|
@@ -575,36 +517,26 @@ def project_definition_option(is_optional: bool):
|
|
|
575
517
|
"--project",
|
|
576
518
|
help=f"Path where Snowflake project resides. "
|
|
577
519
|
f"Defaults to current working directory.",
|
|
578
|
-
callback=
|
|
520
|
+
callback=project_path_callback,
|
|
579
521
|
show_default=False,
|
|
580
522
|
)
|
|
581
523
|
|
|
582
524
|
|
|
583
525
|
def project_env_overrides_option():
|
|
584
|
-
def project_env_overrides_callback(
|
|
526
|
+
def project_env_overrides_callback(
|
|
527
|
+
env_overrides_args_list: list[str],
|
|
528
|
+
) -> dict[str, str]:
|
|
585
529
|
env_overrides_args_map = {
|
|
586
530
|
v.key: v.value for v in parse_key_value_variables(env_overrides_args_list)
|
|
587
531
|
}
|
|
588
|
-
|
|
532
|
+
get_cli_context_manager().project_env_overrides_args = env_overrides_args_map
|
|
533
|
+
return env_overrides_args_map
|
|
589
534
|
|
|
590
535
|
return typer.Option(
|
|
591
536
|
[],
|
|
592
537
|
"--env",
|
|
593
|
-
help="String in format of key=value. Overrides variables from env section used for
|
|
594
|
-
callback=
|
|
595
|
-
show_default=False,
|
|
596
|
-
)
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
def readable_file_option(param_name: str, help_str: str) -> typer.Option:
|
|
600
|
-
return typer.Option(
|
|
601
|
-
None,
|
|
602
|
-
param_name,
|
|
603
|
-
exists=True,
|
|
604
|
-
file_okay=True,
|
|
605
|
-
dir_okay=False,
|
|
606
|
-
readable=True,
|
|
607
|
-
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,
|
|
608
540
|
show_default=False,
|
|
609
541
|
)
|
|
610
542
|
|
|
@@ -627,36 +559,3 @@ def deprecated_flag_callback_enum(msg: str):
|
|
|
627
559
|
return value.value
|
|
628
560
|
|
|
629
561
|
return _warning_callback
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
@dataclass
|
|
633
|
-
class Variable:
|
|
634
|
-
key: str
|
|
635
|
-
value: str
|
|
636
|
-
|
|
637
|
-
def __init__(self, key: str, value: str):
|
|
638
|
-
self.key = key
|
|
639
|
-
self.value = value
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
def parse_key_value_variables(variables: Optional[List[str]]) -> List[Variable]:
|
|
643
|
-
"""Util for parsing key=value input. Useful for commands accepting multiple input options."""
|
|
644
|
-
if not variables:
|
|
645
|
-
return []
|
|
646
|
-
result: List[Variable] = []
|
|
647
|
-
if not variables:
|
|
648
|
-
return result
|
|
649
|
-
for p in variables:
|
|
650
|
-
if "=" not in p:
|
|
651
|
-
raise ClickException(f"Invalid variable: '{p}'")
|
|
652
|
-
|
|
653
|
-
key, value = p.split("=", 1)
|
|
654
|
-
result.append(Variable(key.strip(), value.strip()))
|
|
655
|
-
return result
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
class IdentifierType(click.ParamType):
|
|
659
|
-
name = "TEXT"
|
|
660
|
-
|
|
661
|
-
def convert(self, value, param, ctx):
|
|
662
|
-
return FQN.from_string(value)
|