snowflake-cli-labs 2.8.0rc1__py3-none-any.whl → 3.0.0rc1__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 +24 -17
- snowflake/cli/{app → _app}/telemetry.py +4 -5
- snowflake/cli/{plugins → _plugins}/connection/commands.py +25 -7
- 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 +20 -11
- 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 +32 -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 +4 -4
- snowflake/cli/{plugins → _plugins}/nativeapp/codegen/snowpark/python_processor.py +23 -29
- snowflake/cli/_plugins/nativeapp/codegen/templates/templates_processor.py +93 -0
- snowflake/cli/{plugins → _plugins}/nativeapp/commands.py +171 -42
- snowflake/cli/{plugins → _plugins}/nativeapp/common_flags.py +1 -1
- snowflake/cli/{plugins → _plugins}/nativeapp/exceptions.py +3 -3
- snowflake/cli/{plugins → _plugins}/nativeapp/init.py +1 -1
- snowflake/cli/_plugins/nativeapp/manager.py +572 -0
- snowflake/cli/{plugins/connection → _plugins/nativeapp}/plugin_spec.py +1 -1
- snowflake/cli/{plugins → _plugins}/nativeapp/project_model.py +35 -19
- snowflake/cli/{plugins → _plugins}/nativeapp/run_processor.py +25 -23
- snowflake/cli/{plugins → _plugins}/nativeapp/teardown_processor.py +24 -110
- 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 +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 +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 +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 +54 -21
- 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 +59 -62
- snowflake/cli/{plugins → _plugins}/streamlit/manager.py +51 -70
- snowflake/cli/_plugins/streamlit/plugin_spec.py +30 -0
- snowflake/cli/_plugins/workspace/action_context.py +17 -0
- snowflake/cli/_plugins/workspace/commands.py +194 -0
- snowflake/cli/_plugins/workspace/manager.py +73 -0
- snowflake/cli/{plugins → _plugins}/workspace/plugin_spec.py +1 -1
- snowflake/cli/api/cli_global_context.py +40 -13
- snowflake/cli/api/commands/common.py +25 -0
- snowflake/cli/api/commands/decorators.py +5 -4
- snowflake/cli/api/commands/experimental_behaviour.py +2 -3
- snowflake/cli/api/commands/flags.py +97 -179
- snowflake/cli/api/commands/overrideable_parameter.py +143 -0
- snowflake/cli/api/commands/snow_typer.py +14 -6
- snowflake/cli/api/commands/typer_pre_execute.py +3 -3
- snowflake/cli/api/commands/utils.py +18 -0
- snowflake/cli/api/config.py +18 -5
- snowflake/cli/api/console/abc.py +5 -2
- snowflake/cli/api/constants.py +11 -0
- snowflake/cli/api/entities/application_entity.py +12 -0
- snowflake/cli/api/entities/application_package_entity.py +553 -0
- snowflake/cli/api/entities/common.py +51 -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 +357 -0
- snowflake/cli/api/exceptions.py +31 -5
- snowflake/cli/api/feature_flags.py +0 -1
- snowflake/cli/api/identifiers.py +41 -9
- snowflake/cli/api/project/definition.py +37 -6
- snowflake/cli/api/project/definition_conversion.py +194 -0
- 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} +43 -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 +98 -27
- snowflake/cli/api/project/schemas/updatable_model.py +11 -3
- snowflake/cli/api/project/util.py +23 -6
- snowflake/cli/api/rendering/jinja.py +14 -8
- snowflake/cli/api/rendering/project_definition_templates.py +1 -1
- snowflake/cli/api/rendering/sql_templates.py +43 -11
- snowflake/cli/api/secure_path.py +16 -18
- snowflake/cli/api/secure_utils.py +90 -1
- snowflake/cli/api/sql_execution.py +48 -19
- snowflake/cli/api/utils/definition_rendering.py +18 -8
- {snowflake_cli_labs-2.8.0rc1.dist-info → snowflake_cli_labs-3.0.0rc1.dist-info}/METADATA +13 -13
- snowflake_cli_labs-3.0.0rc1.dist-info/RECORD +236 -0
- snowflake_cli_labs-3.0.0rc1.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/codegen/setup/native_app_setup_processor.py +0 -172
- 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/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/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/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.0rc1.dist-info}/WHEEL +0 -0
- {snowflake_cli_labs-2.8.0rc1.dist-info → snowflake_cli_labs-3.0.0rc1.dist-info}/licenses/LICENSE +0 -0
|
@@ -14,33 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
import click
|
|
18
17
|
import typer
|
|
19
|
-
from snowflake.cli.api.commands.flags import (
|
|
20
|
-
deprecated_flag_callback,
|
|
21
|
-
deprecated_flag_callback_enum,
|
|
22
|
-
)
|
|
23
|
-
from snowflake.cli.plugins.snowpark.models import YesNoAsk
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def deprecated_allow_native_libraries_option(old_flag_name: str):
|
|
27
|
-
return typer.Option(
|
|
28
|
-
YesNoAsk.NO.value,
|
|
29
|
-
old_flag_name,
|
|
30
|
-
help="Allows native libraries, when using packages installed through PIP",
|
|
31
|
-
hidden=True,
|
|
32
|
-
callback=deprecated_flag_callback_enum(
|
|
33
|
-
f"{old_flag_name} flag is deprecated. Use --allow-shared-libraries flag instead."
|
|
34
|
-
),
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def resolve_allow_shared_libraries_yes_no_ask(allow_shared_libraries: YesNoAsk) -> bool:
|
|
39
|
-
if allow_shared_libraries == YesNoAsk.ASK:
|
|
40
|
-
return click.confirm("Continue with package installation?", default=False)
|
|
41
|
-
else:
|
|
42
|
-
return allow_shared_libraries == YesNoAsk.YES
|
|
43
|
-
|
|
44
18
|
|
|
45
19
|
AllowSharedLibrariesOption: bool = typer.Option(
|
|
46
20
|
False,
|
|
@@ -48,16 +22,6 @@ AllowSharedLibrariesOption: bool = typer.Option(
|
|
|
48
22
|
help="Allows shared (.so) libraries, when using packages installed through PIP.",
|
|
49
23
|
)
|
|
50
24
|
|
|
51
|
-
DeprecatedCheckAnacondaForPyPiDependencies: bool = typer.Option(
|
|
52
|
-
True,
|
|
53
|
-
"--check-anaconda-for-pypi-deps/--no-check-anaconda-for-pypi-deps",
|
|
54
|
-
"-a",
|
|
55
|
-
help="""Checks if any of missing Anaconda packages dependencies can be imported directly from Anaconda. Valid values include: `true`, `false`, Default: `true`.""",
|
|
56
|
-
hidden=True,
|
|
57
|
-
callback=deprecated_flag_callback(
|
|
58
|
-
"--check-anaconda-for-pypi-deps flag is deprecated. Use --ignore-anaconda flag instead."
|
|
59
|
-
),
|
|
60
|
-
)
|
|
61
25
|
|
|
62
26
|
IgnoreAnacondaOption: bool = typer.Option(
|
|
63
27
|
False,
|
|
@@ -17,7 +17,7 @@ from __future__ import annotations
|
|
|
17
17
|
import fnmatch
|
|
18
18
|
import logging
|
|
19
19
|
from pathlib import Path
|
|
20
|
-
from typing import
|
|
20
|
+
from typing import Dict, List, Literal
|
|
21
21
|
from zipfile import ZIP_DEFLATED, ZipFile
|
|
22
22
|
|
|
23
23
|
log = logging.getLogger(__name__)
|
|
@@ -59,16 +59,24 @@ def add_file_to_existing_zip(zip_file: str, file: str):
|
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
def zip_dir(
|
|
62
|
-
source: Path
|
|
62
|
+
source: Path | List[Path],
|
|
63
|
+
dest_zip: Path,
|
|
64
|
+
mode: Literal["r", "w", "x", "a"] = "w",
|
|
63
65
|
) -> None:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
|
|
67
|
+
if isinstance(source, Path):
|
|
68
|
+
source = [source]
|
|
69
|
+
|
|
70
|
+
files_to_pack: Dict[Path, List[Path]] = {
|
|
71
|
+
src: list(filter(_to_be_zipped, (f.absolute() for f in src.glob("**/*"))))
|
|
72
|
+
for src in source
|
|
73
|
+
}
|
|
67
74
|
|
|
68
75
|
with ZipFile(dest_zip, mode, ZIP_DEFLATED, allowZip64=True) as package_zip:
|
|
69
|
-
for
|
|
70
|
-
|
|
71
|
-
|
|
76
|
+
for src, files in files_to_pack.items():
|
|
77
|
+
for file in files:
|
|
78
|
+
log.debug("Adding %s to %s", file, dest_zip)
|
|
79
|
+
package_zip.write(file, arcname=file.relative_to(src))
|
|
72
80
|
|
|
73
81
|
|
|
74
82
|
def _to_be_zipped(file: Path) -> bool:
|
|
@@ -12,16 +12,15 @@
|
|
|
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.plugins.spcs.compute_pool.commands import (
|
|
15
|
+
from snowflake.cli._plugins.spcs.compute_pool.commands import (
|
|
17
16
|
app as compute_pools_app,
|
|
18
17
|
)
|
|
19
|
-
from snowflake.cli.
|
|
20
|
-
from snowflake.cli.
|
|
18
|
+
from snowflake.cli._plugins.spcs.image_registry.commands import app as registry_app
|
|
19
|
+
from snowflake.cli._plugins.spcs.image_repository.commands import (
|
|
21
20
|
app as image_repository_app,
|
|
22
21
|
)
|
|
23
|
-
from snowflake.cli.
|
|
24
|
-
from snowflake.cli.
|
|
22
|
+
from snowflake.cli._plugins.spcs.services.commands import app as services_app
|
|
23
|
+
from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
|
|
25
24
|
|
|
26
25
|
app = SnowTyperFactory(
|
|
27
26
|
name="spcs",
|
|
@@ -30,6 +29,5 @@ app = SnowTyperFactory(
|
|
|
30
29
|
|
|
31
30
|
app.add_typer(compute_pools_app)
|
|
32
31
|
app.add_typer(services_app)
|
|
33
|
-
app.add_typer(jobs_app)
|
|
34
32
|
app.add_typer(registry_app)
|
|
35
33
|
app.add_typer(image_repository_app)
|
|
@@ -18,23 +18,25 @@ from typing import Optional
|
|
|
18
18
|
|
|
19
19
|
import typer
|
|
20
20
|
from click import ClickException
|
|
21
|
+
from snowflake.cli._plugins.object.command_aliases import (
|
|
22
|
+
add_object_command_aliases,
|
|
23
|
+
)
|
|
24
|
+
from snowflake.cli._plugins.object.common import CommentOption
|
|
25
|
+
from snowflake.cli._plugins.spcs.common import (
|
|
26
|
+
validate_and_set_instances,
|
|
27
|
+
)
|
|
28
|
+
from snowflake.cli._plugins.spcs.compute_pool.manager import ComputePoolManager
|
|
21
29
|
from snowflake.cli.api.commands.flags import (
|
|
22
30
|
IfNotExistsOption,
|
|
23
31
|
OverrideableOption,
|
|
32
|
+
identifier_argument,
|
|
24
33
|
like_option,
|
|
25
34
|
)
|
|
26
35
|
from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
|
|
27
36
|
from snowflake.cli.api.constants import ObjectType
|
|
37
|
+
from snowflake.cli.api.identifiers import FQN
|
|
28
38
|
from snowflake.cli.api.output.types import CommandResult, SingleQueryResult
|
|
29
39
|
from snowflake.cli.api.project.util import is_valid_object_name
|
|
30
|
-
from snowflake.cli.plugins.object.command_aliases import (
|
|
31
|
-
add_object_command_aliases,
|
|
32
|
-
)
|
|
33
|
-
from snowflake.cli.plugins.object.common import CommentOption
|
|
34
|
-
from snowflake.cli.plugins.spcs.common import (
|
|
35
|
-
validate_and_set_instances,
|
|
36
|
-
)
|
|
37
|
-
from snowflake.cli.plugins.spcs.compute_pool.manager import ComputePoolManager
|
|
38
40
|
|
|
39
41
|
app = SnowTyperFactory(
|
|
40
42
|
name="compute-pool",
|
|
@@ -43,22 +45,21 @@ app = SnowTyperFactory(
|
|
|
43
45
|
)
|
|
44
46
|
|
|
45
47
|
|
|
46
|
-
def _compute_pool_name_callback(name:
|
|
48
|
+
def _compute_pool_name_callback(name: FQN) -> FQN:
|
|
47
49
|
"""
|
|
48
50
|
Verifies that compute pool name is a single valid identifier.
|
|
49
51
|
"""
|
|
50
|
-
if not is_valid_object_name(name, max_depth=0, allow_quoted=False):
|
|
52
|
+
if not is_valid_object_name(name.identifier, max_depth=0, allow_quoted=False):
|
|
51
53
|
raise ClickException(
|
|
52
54
|
f"'{name}' is not a valid compute pool name. Note that compute pool names must be unquoted identifiers."
|
|
53
55
|
)
|
|
54
56
|
return name
|
|
55
57
|
|
|
56
58
|
|
|
57
|
-
ComputePoolNameArgument =
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
ComputePoolNameArgument = identifier_argument(
|
|
60
|
+
sf_object="compute pool",
|
|
61
|
+
example="my_compute_pool",
|
|
60
62
|
callback=_compute_pool_name_callback,
|
|
61
|
-
show_default=False,
|
|
62
63
|
)
|
|
63
64
|
|
|
64
65
|
|
|
@@ -106,7 +107,7 @@ add_object_command_aliases(
|
|
|
106
107
|
|
|
107
108
|
@app.command(requires_connection=True)
|
|
108
109
|
def create(
|
|
109
|
-
name:
|
|
110
|
+
name: FQN = ComputePoolNameArgument,
|
|
110
111
|
instance_family: str = typer.Option(
|
|
111
112
|
...,
|
|
112
113
|
"--family",
|
|
@@ -131,7 +132,7 @@ def create(
|
|
|
131
132
|
"""
|
|
132
133
|
max_nodes = validate_and_set_instances(min_nodes, max_nodes, "nodes")
|
|
133
134
|
cursor = ComputePoolManager().create(
|
|
134
|
-
pool_name=name,
|
|
135
|
+
pool_name=name.identifier,
|
|
135
136
|
min_nodes=min_nodes,
|
|
136
137
|
max_nodes=max_nodes,
|
|
137
138
|
instance_family=instance_family,
|
|
@@ -145,33 +146,33 @@ def create(
|
|
|
145
146
|
|
|
146
147
|
|
|
147
148
|
@app.command("stop-all", requires_connection=True)
|
|
148
|
-
def stop_all(name:
|
|
149
|
+
def stop_all(name: FQN = ComputePoolNameArgument, **options) -> CommandResult:
|
|
149
150
|
"""
|
|
150
151
|
Deletes all services running on the compute pool.
|
|
151
152
|
"""
|
|
152
|
-
cursor = ComputePoolManager().stop(pool_name=name)
|
|
153
|
+
cursor = ComputePoolManager().stop(pool_name=name.identifier)
|
|
153
154
|
return SingleQueryResult(cursor)
|
|
154
155
|
|
|
155
156
|
|
|
156
157
|
@app.command(requires_connection=True)
|
|
157
|
-
def suspend(name:
|
|
158
|
+
def suspend(name: FQN = ComputePoolNameArgument, **options) -> CommandResult:
|
|
158
159
|
"""
|
|
159
160
|
Suspends the compute pool by suspending all currently running services and then releasing compute pool nodes.
|
|
160
161
|
"""
|
|
161
|
-
return SingleQueryResult(ComputePoolManager().suspend(name))
|
|
162
|
+
return SingleQueryResult(ComputePoolManager().suspend(name.identifier))
|
|
162
163
|
|
|
163
164
|
|
|
164
165
|
@app.command(requires_connection=True)
|
|
165
|
-
def resume(name:
|
|
166
|
+
def resume(name: FQN = ComputePoolNameArgument, **options) -> CommandResult:
|
|
166
167
|
"""
|
|
167
168
|
Resumes the compute pool from a SUSPENDED state.
|
|
168
169
|
"""
|
|
169
|
-
return SingleQueryResult(ComputePoolManager().resume(name))
|
|
170
|
+
return SingleQueryResult(ComputePoolManager().resume(name.identifier))
|
|
170
171
|
|
|
171
172
|
|
|
172
173
|
@app.command("set", requires_connection=True)
|
|
173
174
|
def set_property(
|
|
174
|
-
name:
|
|
175
|
+
name: FQN = ComputePoolNameArgument,
|
|
175
176
|
min_nodes: Optional[int] = MinNodesOption(default=None, show_default=False),
|
|
176
177
|
max_nodes: Optional[int] = MaxNodesOption(show_default=False),
|
|
177
178
|
auto_resume: Optional[bool] = AutoResumeOption(default=None, show_default=False),
|
|
@@ -187,7 +188,7 @@ def set_property(
|
|
|
187
188
|
Sets one or more properties for the compute pool.
|
|
188
189
|
"""
|
|
189
190
|
cursor = ComputePoolManager().set_property(
|
|
190
|
-
pool_name=name,
|
|
191
|
+
pool_name=name.identifier,
|
|
191
192
|
min_nodes=min_nodes,
|
|
192
193
|
max_nodes=max_nodes,
|
|
193
194
|
auto_resume=auto_resume,
|
|
@@ -199,7 +200,7 @@ def set_property(
|
|
|
199
200
|
|
|
200
201
|
@app.command("unset", requires_connection=True)
|
|
201
202
|
def unset_property(
|
|
202
|
-
name:
|
|
203
|
+
name: FQN = ComputePoolNameArgument,
|
|
203
204
|
auto_resume: bool = AutoResumeOption(
|
|
204
205
|
default=False,
|
|
205
206
|
param_decls=["--auto-resume"],
|
|
@@ -223,7 +224,7 @@ def unset_property(
|
|
|
223
224
|
Resets one or more properties for the compute pool to their default value(s).
|
|
224
225
|
"""
|
|
225
226
|
cursor = ComputePoolManager().unset_property(
|
|
226
|
-
pool_name=name,
|
|
227
|
+
pool_name=name.identifier,
|
|
227
228
|
auto_resume=auto_resume,
|
|
228
229
|
auto_suspend_secs=auto_suspend_secs,
|
|
229
230
|
comment=comment,
|
|
@@ -232,9 +233,9 @@ def unset_property(
|
|
|
232
233
|
|
|
233
234
|
|
|
234
235
|
@app.command(requires_connection=True)
|
|
235
|
-
def status(pool_name:
|
|
236
|
+
def status(pool_name: FQN = ComputePoolNameArgument, **options) -> CommandResult:
|
|
236
237
|
"""
|
|
237
238
|
Retrieves the status of a compute pool along with a relevant message, if one exists.
|
|
238
239
|
"""
|
|
239
|
-
cursor = ComputePoolManager().status(pool_name=pool_name)
|
|
240
|
+
cursor = ComputePoolManager().status(pool_name=pool_name.identifier)
|
|
240
241
|
return SingleQueryResult(cursor)
|
|
@@ -16,13 +16,13 @@ from __future__ import annotations
|
|
|
16
16
|
|
|
17
17
|
from typing import List, Optional
|
|
18
18
|
|
|
19
|
-
from snowflake.cli.
|
|
20
|
-
from snowflake.cli.api.sql_execution import SqlExecutionMixin
|
|
21
|
-
from snowflake.cli.plugins.spcs.common import (
|
|
19
|
+
from snowflake.cli._plugins.spcs.common import (
|
|
22
20
|
NoPropertiesProvidedError,
|
|
23
21
|
handle_object_already_exists,
|
|
24
22
|
strip_empty_lines,
|
|
25
23
|
)
|
|
24
|
+
from snowflake.cli.api.constants import ObjectType
|
|
25
|
+
from snowflake.cli.api.sql_execution import SqlExecutionMixin
|
|
26
26
|
from snowflake.connector.cursor import SnowflakeCursor
|
|
27
27
|
from snowflake.connector.errors import ProgrammingError
|
|
28
28
|
|
|
@@ -12,11 +12,11 @@
|
|
|
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.api.output.types import MessageResult, ObjectResult
|
|
17
|
-
from snowflake.cli.plugins.spcs.image_registry.manager import (
|
|
15
|
+
from snowflake.cli._plugins.spcs.image_registry.manager import (
|
|
18
16
|
RegistryManager,
|
|
19
17
|
)
|
|
18
|
+
from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
|
|
19
|
+
from snowflake.cli.api.output.types import MessageResult, ObjectResult
|
|
20
20
|
|
|
21
21
|
app = SnowTyperFactory(
|
|
22
22
|
name="image-registry",
|
|
@@ -20,26 +20,28 @@ from typing import Optional
|
|
|
20
20
|
import requests
|
|
21
21
|
import typer
|
|
22
22
|
from click import ClickException
|
|
23
|
+
from snowflake.cli._plugins.object.command_aliases import (
|
|
24
|
+
add_object_command_aliases,
|
|
25
|
+
scope_option,
|
|
26
|
+
)
|
|
27
|
+
from snowflake.cli._plugins.spcs.image_registry.manager import RegistryManager
|
|
28
|
+
from snowflake.cli._plugins.spcs.image_repository.manager import ImageRepositoryManager
|
|
23
29
|
from snowflake.cli.api.commands.flags import (
|
|
24
30
|
IfNotExistsOption,
|
|
25
31
|
ReplaceOption,
|
|
32
|
+
identifier_argument,
|
|
26
33
|
like_option,
|
|
27
34
|
)
|
|
28
35
|
from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
|
|
29
36
|
from snowflake.cli.api.console import cli_console
|
|
30
37
|
from snowflake.cli.api.constants import ObjectType
|
|
38
|
+
from snowflake.cli.api.identifiers import FQN
|
|
31
39
|
from snowflake.cli.api.output.types import (
|
|
32
40
|
CollectionResult,
|
|
33
41
|
MessageResult,
|
|
34
42
|
SingleQueryResult,
|
|
35
43
|
)
|
|
36
44
|
from snowflake.cli.api.project.util import is_valid_object_name
|
|
37
|
-
from snowflake.cli.plugins.object.command_aliases import (
|
|
38
|
-
add_object_command_aliases,
|
|
39
|
-
scope_option,
|
|
40
|
-
)
|
|
41
|
-
from snowflake.cli.plugins.spcs.image_registry.manager import RegistryManager
|
|
42
|
-
from snowflake.cli.plugins.spcs.image_repository.manager import ImageRepositoryManager
|
|
43
45
|
|
|
44
46
|
app = SnowTyperFactory(
|
|
45
47
|
name="image-repository",
|
|
@@ -48,18 +50,18 @@ app = SnowTyperFactory(
|
|
|
48
50
|
)
|
|
49
51
|
|
|
50
52
|
|
|
51
|
-
def _repo_name_callback(name:
|
|
52
|
-
if not is_valid_object_name(name, max_depth=2, allow_quoted=False):
|
|
53
|
+
def _repo_name_callback(name: FQN):
|
|
54
|
+
if not is_valid_object_name(name.identifier, max_depth=2, allow_quoted=False):
|
|
53
55
|
raise ClickException(
|
|
54
56
|
f"'{name}' is not a valid image repository name. Note that image repository names must be unquoted identifiers. The same constraint also applies to database and schema names where you create an image repository."
|
|
55
57
|
)
|
|
56
58
|
return name
|
|
57
59
|
|
|
58
60
|
|
|
59
|
-
REPO_NAME_ARGUMENT =
|
|
60
|
-
|
|
61
|
+
REPO_NAME_ARGUMENT = identifier_argument(
|
|
62
|
+
sf_object="image repository",
|
|
63
|
+
example="my_repository",
|
|
61
64
|
callback=_repo_name_callback,
|
|
62
|
-
show_default=False,
|
|
63
65
|
)
|
|
64
66
|
|
|
65
67
|
add_object_command_aliases(
|
|
@@ -76,7 +78,7 @@ add_object_command_aliases(
|
|
|
76
78
|
|
|
77
79
|
@app.command(requires_connection=True)
|
|
78
80
|
def create(
|
|
79
|
-
name:
|
|
81
|
+
name: FQN = REPO_NAME_ARGUMENT,
|
|
80
82
|
replace: bool = ReplaceOption(),
|
|
81
83
|
if_not_exists: bool = IfNotExistsOption(),
|
|
82
84
|
**options,
|
|
@@ -86,21 +88,21 @@ def create(
|
|
|
86
88
|
"""
|
|
87
89
|
return SingleQueryResult(
|
|
88
90
|
ImageRepositoryManager().create(
|
|
89
|
-
name=name, replace=replace, if_not_exists=if_not_exists
|
|
91
|
+
name=name.identifier, replace=replace, if_not_exists=if_not_exists
|
|
90
92
|
)
|
|
91
93
|
)
|
|
92
94
|
|
|
93
95
|
|
|
94
96
|
@app.command("list-images", requires_connection=True)
|
|
95
97
|
def list_images(
|
|
96
|
-
name:
|
|
98
|
+
name: FQN = REPO_NAME_ARGUMENT,
|
|
97
99
|
**options,
|
|
98
100
|
) -> CollectionResult:
|
|
99
101
|
"""Lists images in the given repository."""
|
|
100
102
|
repository_manager = ImageRepositoryManager()
|
|
101
103
|
database = repository_manager.get_database()
|
|
102
104
|
schema = repository_manager.get_schema()
|
|
103
|
-
url = repository_manager.get_repository_url(name)
|
|
105
|
+
url = repository_manager.get_repository_url(name.identifier)
|
|
104
106
|
api_url = repository_manager.get_repository_api_url(url)
|
|
105
107
|
bearer_login = RegistryManager().login_to_registry(api_url)
|
|
106
108
|
repos = []
|
|
@@ -136,7 +138,7 @@ def list_images(
|
|
|
136
138
|
|
|
137
139
|
@app.command("list-tags", requires_connection=True)
|
|
138
140
|
def list_tags(
|
|
139
|
-
name:
|
|
141
|
+
name: FQN = REPO_NAME_ARGUMENT,
|
|
140
142
|
image_name: str = typer.Option(
|
|
141
143
|
...,
|
|
142
144
|
"--image-name",
|
|
@@ -150,7 +152,7 @@ def list_tags(
|
|
|
150
152
|
"""Lists tags for the given image in a repository."""
|
|
151
153
|
|
|
152
154
|
repository_manager = ImageRepositoryManager()
|
|
153
|
-
url = repository_manager.get_repository_url(name)
|
|
155
|
+
url = repository_manager.get_repository_url(name.identifier)
|
|
154
156
|
api_url = repository_manager.get_repository_api_url(url)
|
|
155
157
|
bearer_login = RegistryManager().login_to_registry(api_url)
|
|
156
158
|
|
|
@@ -187,10 +189,14 @@ def list_tags(
|
|
|
187
189
|
|
|
188
190
|
@app.command("url", requires_connection=True)
|
|
189
191
|
def repo_url(
|
|
190
|
-
name:
|
|
192
|
+
name: FQN = REPO_NAME_ARGUMENT,
|
|
191
193
|
**options,
|
|
192
194
|
):
|
|
193
195
|
"""Returns the URL for the given repository."""
|
|
194
196
|
return MessageResult(
|
|
195
|
-
(
|
|
197
|
+
(
|
|
198
|
+
ImageRepositoryManager().get_repository_url(
|
|
199
|
+
repo_name=name.identifier, with_scheme=False
|
|
200
|
+
)
|
|
201
|
+
)
|
|
196
202
|
)
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
|
|
15
15
|
from urllib.parse import urlparse
|
|
16
16
|
|
|
17
|
+
from snowflake.cli._plugins.spcs.common import handle_object_already_exists
|
|
17
18
|
from snowflake.cli.api.constants import ObjectType
|
|
18
19
|
from snowflake.cli.api.identifiers import FQN
|
|
19
20
|
from snowflake.cli.api.sql_execution import SqlExecutionMixin
|
|
20
|
-
from snowflake.cli.plugins.spcs.common import handle_object_already_exists
|
|
21
21
|
from snowflake.connector.errors import ProgrammingError
|
|
22
22
|
|
|
23
23
|
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
from snowflake.cli._plugins.spcs import app
|
|
15
16
|
from snowflake.cli.api.plugins.command import (
|
|
16
17
|
SNOWCLI_ROOT_COMMAND_PATH,
|
|
17
18
|
CommandSpec,
|
|
18
19
|
CommandType,
|
|
19
20
|
plugin_hook_impl,
|
|
20
21
|
)
|
|
21
|
-
from snowflake.cli.plugins.spcs import app
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
@plugin_hook_impl
|