snowflake-cli-labs 3.0.0rc5__py3-none-any.whl → 3.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- README.md +21 -0
- {snowflake_cli_labs-3.0.0rc5.dist-info → snowflake_cli_labs-3.0.2.dist-info}/METADATA +6 -96
- snowflake_cli_labs-3.0.2.dist-info/RECORD +5 -0
- snowflake/cli/__about__.py +0 -17
- snowflake/cli/__init__.py +0 -13
- snowflake/cli/_app/__init__.py +0 -22
- snowflake/cli/_app/__main__.py +0 -31
- snowflake/cli/_app/api_impl/__init__.py +0 -13
- snowflake/cli/_app/api_impl/plugin/__init__.py +0 -13
- snowflake/cli/_app/api_impl/plugin/plugin_config_provider_impl.py +0 -66
- snowflake/cli/_app/cli_app.py +0 -252
- snowflake/cli/_app/commands_registration/__init__.py +0 -33
- snowflake/cli/_app/commands_registration/builtin_plugins.py +0 -50
- snowflake/cli/_app/commands_registration/command_plugins_loader.py +0 -169
- snowflake/cli/_app/commands_registration/commands_registration_with_callbacks.py +0 -105
- snowflake/cli/_app/commands_registration/exception_logging.py +0 -26
- snowflake/cli/_app/commands_registration/threadsafe.py +0 -48
- snowflake/cli/_app/commands_registration/typer_registration.py +0 -153
- snowflake/cli/_app/constants.py +0 -19
- snowflake/cli/_app/dev/__init__.py +0 -13
- snowflake/cli/_app/dev/commands_structure.py +0 -48
- snowflake/cli/_app/dev/docs/__init__.py +0 -13
- snowflake/cli/_app/dev/docs/commands_docs_generator.py +0 -118
- snowflake/cli/_app/dev/docs/generator.py +0 -35
- snowflake/cli/_app/dev/docs/project_definition_docs_generator.py +0 -58
- snowflake/cli/_app/dev/docs/project_definition_generate_json_schema.py +0 -227
- snowflake/cli/_app/dev/docs/template_utils.py +0 -23
- snowflake/cli/_app/dev/docs/templates/definition_description.rst.jinja2 +0 -38
- snowflake/cli/_app/dev/docs/templates/overview.rst.jinja2 +0 -9
- snowflake/cli/_app/dev/docs/templates/usage.rst.jinja2 +0 -67
- snowflake/cli/_app/dev/pycharm_remote_debug.py +0 -46
- snowflake/cli/_app/loggers.py +0 -199
- snowflake/cli/_app/main_typer.py +0 -62
- snowflake/cli/_app/printing.py +0 -181
- snowflake/cli/_app/secret.py +0 -9
- snowflake/cli/_app/snow_connector.py +0 -309
- snowflake/cli/_app/telemetry.py +0 -220
- snowflake/cli/_app/version_check.py +0 -74
- snowflake/cli/_plugins/__init__.py +0 -13
- snowflake/cli/_plugins/connection/__init__.py +0 -13
- snowflake/cli/_plugins/connection/commands.py +0 -353
- snowflake/cli/_plugins/connection/plugin_spec.py +0 -30
- snowflake/cli/_plugins/connection/util.py +0 -195
- snowflake/cli/_plugins/cortex/__init__.py +0 -13
- snowflake/cli/_plugins/cortex/commands.py +0 -332
- snowflake/cli/_plugins/cortex/constants.py +0 -17
- snowflake/cli/_plugins/cortex/manager.py +0 -189
- snowflake/cli/_plugins/cortex/plugin_spec.py +0 -30
- snowflake/cli/_plugins/cortex/types.py +0 -22
- snowflake/cli/_plugins/git/__init__.py +0 -13
- snowflake/cli/_plugins/git/commands.py +0 -358
- snowflake/cli/_plugins/git/manager.py +0 -151
- snowflake/cli/_plugins/git/plugin_spec.py +0 -30
- snowflake/cli/_plugins/helpers/__init__.py +0 -13
- snowflake/cli/_plugins/helpers/commands.py +0 -90
- snowflake/cli/_plugins/helpers/plugin_spec.py +0 -30
- snowflake/cli/_plugins/init/__init__.py +0 -13
- snowflake/cli/_plugins/init/commands.py +0 -248
- snowflake/cli/_plugins/init/plugin_spec.py +0 -30
- snowflake/cli/_plugins/nativeapp/__init__.py +0 -13
- snowflake/cli/_plugins/nativeapp/artifacts.py +0 -757
- snowflake/cli/_plugins/nativeapp/bundle_context.py +0 -31
- snowflake/cli/_plugins/nativeapp/codegen/__init__.py +0 -13
- snowflake/cli/_plugins/nativeapp/codegen/artifact_processor.py +0 -91
- snowflake/cli/_plugins/nativeapp/codegen/compiler.py +0 -149
- snowflake/cli/_plugins/nativeapp/codegen/sandbox.py +0 -306
- snowflake/cli/_plugins/nativeapp/codegen/setup/native_app_setup_processor.py +0 -249
- snowflake/cli/_plugins/nativeapp/codegen/setup/setup_driver.py.source +0 -59
- snowflake/cli/_plugins/nativeapp/codegen/snowpark/callback_source.py.jinja +0 -181
- snowflake/cli/_plugins/nativeapp/codegen/snowpark/extension_function_utils.py +0 -217
- snowflake/cli/_plugins/nativeapp/codegen/snowpark/models.py +0 -61
- snowflake/cli/_plugins/nativeapp/codegen/snowpark/python_processor.py +0 -523
- snowflake/cli/_plugins/nativeapp/codegen/templates/templates_processor.py +0 -114
- snowflake/cli/_plugins/nativeapp/commands.py +0 -559
- snowflake/cli/_plugins/nativeapp/common_flags.py +0 -44
- snowflake/cli/_plugins/nativeapp/constants.py +0 -27
- snowflake/cli/_plugins/nativeapp/entities/__init__.py +0 -0
- snowflake/cli/_plugins/nativeapp/entities/application.py +0 -878
- snowflake/cli/_plugins/nativeapp/entities/application_package.py +0 -1392
- snowflake/cli/_plugins/nativeapp/exceptions.py +0 -113
- snowflake/cli/_plugins/nativeapp/feature_flags.py +0 -24
- snowflake/cli/_plugins/nativeapp/manager.py +0 -415
- snowflake/cli/_plugins/nativeapp/plugin_spec.py +0 -30
- snowflake/cli/_plugins/nativeapp/policy.py +0 -53
- snowflake/cli/_plugins/nativeapp/project_model.py +0 -211
- snowflake/cli/_plugins/nativeapp/run_processor.py +0 -184
- snowflake/cli/_plugins/nativeapp/same_account_install_method.py +0 -70
- snowflake/cli/_plugins/nativeapp/teardown_processor.py +0 -70
- snowflake/cli/_plugins/nativeapp/utils.py +0 -98
- snowflake/cli/_plugins/nativeapp/v2_conversions/v2_to_v1_decorator.py +0 -262
- snowflake/cli/_plugins/nativeapp/version/__init__.py +0 -13
- snowflake/cli/_plugins/nativeapp/version/commands.py +0 -141
- snowflake/cli/_plugins/nativeapp/version/version_processor.py +0 -98
- snowflake/cli/_plugins/notebook/__init__.py +0 -13
- snowflake/cli/_plugins/notebook/commands.py +0 -86
- snowflake/cli/_plugins/notebook/exceptions.py +0 -20
- snowflake/cli/_plugins/notebook/manager.py +0 -71
- snowflake/cli/_plugins/notebook/plugin_spec.py +0 -30
- snowflake/cli/_plugins/notebook/types.py +0 -15
- snowflake/cli/_plugins/object/__init__.py +0 -13
- snowflake/cli/_plugins/object/command_aliases.py +0 -95
- snowflake/cli/_plugins/object/commands.py +0 -180
- snowflake/cli/_plugins/object/common.py +0 -85
- snowflake/cli/_plugins/object/manager.py +0 -118
- snowflake/cli/_plugins/object/plugin_spec.py +0 -30
- snowflake/cli/_plugins/snowpark/__init__.py +0 -13
- snowflake/cli/_plugins/snowpark/commands.py +0 -450
- snowflake/cli/_plugins/snowpark/common.py +0 -268
- snowflake/cli/_plugins/snowpark/models.py +0 -150
- snowflake/cli/_plugins/snowpark/package/__init__.py +0 -13
- snowflake/cli/_plugins/snowpark/package/anaconda_packages.py +0 -199
- snowflake/cli/_plugins/snowpark/package/commands.py +0 -195
- snowflake/cli/_plugins/snowpark/package/manager.py +0 -44
- snowflake/cli/_plugins/snowpark/package/utils.py +0 -26
- snowflake/cli/_plugins/snowpark/package_utils.py +0 -354
- snowflake/cli/_plugins/snowpark/plugin_spec.py +0 -30
- snowflake/cli/_plugins/snowpark/snowpark_entity.py +0 -29
- snowflake/cli/_plugins/snowpark/snowpark_entity_model.py +0 -173
- snowflake/cli/_plugins/snowpark/snowpark_project_paths.py +0 -109
- snowflake/cli/_plugins/snowpark/snowpark_shared.py +0 -59
- snowflake/cli/_plugins/snowpark/zipper.py +0 -89
- snowflake/cli/_plugins/spcs/__init__.py +0 -33
- snowflake/cli/_plugins/spcs/common.py +0 -99
- snowflake/cli/_plugins/spcs/compute_pool/__init__.py +0 -13
- snowflake/cli/_plugins/spcs/compute_pool/commands.py +0 -241
- snowflake/cli/_plugins/spcs/compute_pool/manager.py +0 -121
- snowflake/cli/_plugins/spcs/image_registry/__init__.py +0 -13
- snowflake/cli/_plugins/spcs/image_registry/commands.py +0 -65
- snowflake/cli/_plugins/spcs/image_registry/manager.py +0 -105
- snowflake/cli/_plugins/spcs/image_repository/__init__.py +0 -13
- snowflake/cli/_plugins/spcs/image_repository/commands.py +0 -202
- snowflake/cli/_plugins/spcs/image_repository/manager.py +0 -84
- snowflake/cli/_plugins/spcs/plugin_spec.py +0 -30
- snowflake/cli/_plugins/spcs/services/__init__.py +0 -13
- snowflake/cli/_plugins/spcs/services/commands.py +0 -345
- snowflake/cli/_plugins/spcs/services/manager.py +0 -208
- snowflake/cli/_plugins/sql/__init__.py +0 -13
- snowflake/cli/_plugins/sql/commands.py +0 -86
- snowflake/cli/_plugins/sql/manager.py +0 -92
- snowflake/cli/_plugins/sql/plugin_spec.py +0 -30
- snowflake/cli/_plugins/sql/snowsql_templating.py +0 -28
- snowflake/cli/_plugins/stage/__init__.py +0 -13
- snowflake/cli/_plugins/stage/commands.py +0 -264
- snowflake/cli/_plugins/stage/diff.py +0 -280
- snowflake/cli/_plugins/stage/manager.py +0 -582
- snowflake/cli/_plugins/stage/md5.py +0 -160
- snowflake/cli/_plugins/stage/plugin_spec.py +0 -30
- snowflake/cli/_plugins/stage/utils.py +0 -54
- snowflake/cli/_plugins/streamlit/__init__.py +0 -13
- snowflake/cli/_plugins/streamlit/commands.py +0 -195
- snowflake/cli/_plugins/streamlit/manager.py +0 -220
- snowflake/cli/_plugins/streamlit/plugin_spec.py +0 -30
- snowflake/cli/_plugins/streamlit/streamlit_entity.py +0 -12
- snowflake/cli/_plugins/streamlit/streamlit_entity_model.py +0 -66
- snowflake/cli/_plugins/workspace/__init__.py +0 -13
- snowflake/cli/_plugins/workspace/action_context.py +0 -18
- snowflake/cli/_plugins/workspace/commands.py +0 -306
- snowflake/cli/_plugins/workspace/manager.py +0 -74
- snowflake/cli/_plugins/workspace/plugin_spec.py +0 -30
- snowflake/cli/api/__init__.py +0 -48
- snowflake/cli/api/cli_global_context.py +0 -247
- snowflake/cli/api/commands/__init__.py +0 -13
- snowflake/cli/api/commands/alias.py +0 -23
- snowflake/cli/api/commands/common.py +0 -25
- snowflake/cli/api/commands/decorators.py +0 -369
- snowflake/cli/api/commands/execution_metadata.py +0 -40
- snowflake/cli/api/commands/experimental_behaviour.py +0 -18
- snowflake/cli/api/commands/flags.py +0 -561
- snowflake/cli/api/commands/overrideable_parameter.py +0 -143
- snowflake/cli/api/commands/snow_typer.py +0 -247
- snowflake/cli/api/commands/utils.py +0 -18
- snowflake/cli/api/config.py +0 -380
- snowflake/cli/api/connections.py +0 -216
- snowflake/cli/api/console/__init__.py +0 -17
- snowflake/cli/api/console/abc.py +0 -94
- snowflake/cli/api/console/console.py +0 -134
- snowflake/cli/api/console/enum.py +0 -17
- snowflake/cli/api/constants.py +0 -90
- snowflake/cli/api/entities/common.py +0 -56
- snowflake/cli/api/entities/utils.py +0 -370
- snowflake/cli/api/errno.py +0 -28
- snowflake/cli/api/exceptions.py +0 -190
- snowflake/cli/api/feature_flags.py +0 -54
- snowflake/cli/api/identifiers.py +0 -190
- snowflake/cli/api/metrics.py +0 -92
- snowflake/cli/api/output/__init__.py +0 -13
- snowflake/cli/api/output/formats.py +0 -20
- snowflake/cli/api/output/types.py +0 -118
- snowflake/cli/api/plugins/__init__.py +0 -13
- snowflake/cli/api/plugins/command/__init__.py +0 -72
- snowflake/cli/api/plugins/command/plugin_hook_specs.py +0 -21
- snowflake/cli/api/plugins/plugin_config.py +0 -32
- snowflake/cli/api/project/__init__.py +0 -13
- snowflake/cli/api/project/definition.py +0 -126
- snowflake/cli/api/project/definition_conversion.py +0 -400
- snowflake/cli/api/project/definition_manager.py +0 -145
- snowflake/cli/api/project/errors.py +0 -56
- snowflake/cli/api/project/project_verification.py +0 -23
- snowflake/cli/api/project/schemas/__init__.py +0 -13
- snowflake/cli/api/project/schemas/entities/__init__.py +0 -13
- snowflake/cli/api/project/schemas/entities/common.py +0 -153
- snowflake/cli/api/project/schemas/entities/entities.py +0 -61
- snowflake/cli/api/project/schemas/project_definition.py +0 -330
- snowflake/cli/api/project/schemas/template.py +0 -77
- snowflake/cli/api/project/schemas/updatable_model.py +0 -202
- snowflake/cli/api/project/schemas/v1/__init__.py +0 -0
- snowflake/cli/api/project/schemas/v1/identifier_model.py +0 -51
- snowflake/cli/api/project/schemas/v1/native_app/__init__.py +0 -0
- snowflake/cli/api/project/schemas/v1/native_app/application.py +0 -61
- snowflake/cli/api/project/schemas/v1/native_app/native_app.py +0 -93
- snowflake/cli/api/project/schemas/v1/native_app/package.py +0 -84
- snowflake/cli/api/project/schemas/v1/native_app/path_mapping.py +0 -65
- snowflake/cli/api/project/schemas/v1/snowpark/__init__.py +0 -0
- snowflake/cli/api/project/schemas/v1/snowpark/argument.py +0 -28
- snowflake/cli/api/project/schemas/v1/snowpark/callable.py +0 -69
- snowflake/cli/api/project/schemas/v1/snowpark/snowpark.py +0 -36
- snowflake/cli/api/project/schemas/v1/streamlit/__init__.py +0 -0
- snowflake/cli/api/project/schemas/v1/streamlit/streamlit.py +0 -47
- snowflake/cli/api/project/util.py +0 -278
- snowflake/cli/api/rendering/__init__.py +0 -13
- snowflake/cli/api/rendering/jinja.py +0 -118
- snowflake/cli/api/rendering/project_definition_templates.py +0 -43
- snowflake/cli/api/rendering/project_templates.py +0 -98
- snowflake/cli/api/rendering/sql_templates.py +0 -105
- snowflake/cli/api/rest_api.py +0 -178
- snowflake/cli/api/sanitizers.py +0 -43
- snowflake/cli/api/secure_path.py +0 -360
- snowflake/cli/api/secure_utils.py +0 -118
- snowflake/cli/api/sql_execution.py +0 -280
- snowflake/cli/api/utils/__init__.py +0 -13
- snowflake/cli/api/utils/cursor.py +0 -34
- snowflake/cli/api/utils/definition_rendering.py +0 -415
- snowflake/cli/api/utils/dict_utils.py +0 -73
- snowflake/cli/api/utils/error_handling.py +0 -23
- snowflake/cli/api/utils/graph.py +0 -97
- snowflake/cli/api/utils/models.py +0 -63
- snowflake/cli/api/utils/naming_utils.py +0 -13
- snowflake/cli/api/utils/path_utils.py +0 -36
- snowflake/cli/api/utils/templating_functions.py +0 -144
- snowflake/cli/api/utils/types.py +0 -35
- snowflake_cli_labs-3.0.0rc5.dist-info/RECORD +0 -242
- snowflake_cli_labs-3.0.0rc5.dist-info/entry_points.txt +0 -2
- {snowflake_cli_labs-3.0.0rc5.dist-info → snowflake_cli_labs-3.0.2.dist-info}/WHEEL +0 -0
- {snowflake_cli_labs-3.0.0rc5.dist-info → snowflake_cli_labs-3.0.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2024 Snowflake Inc.
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
from snowflake.cli._plugins.streamlit import commands
|
|
16
|
-
from snowflake.cli.api.plugins.command import (
|
|
17
|
-
SNOWCLI_ROOT_COMMAND_PATH,
|
|
18
|
-
CommandSpec,
|
|
19
|
-
CommandType,
|
|
20
|
-
plugin_hook_impl,
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
@plugin_hook_impl
|
|
25
|
-
def command_spec():
|
|
26
|
-
return CommandSpec(
|
|
27
|
-
parent_command_path=SNOWCLI_ROOT_COMMAND_PATH,
|
|
28
|
-
command_type=CommandType.COMMAND_GROUP,
|
|
29
|
-
typer_instance=commands.app.create_instance(),
|
|
30
|
-
)
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
from snowflake.cli._plugins.streamlit.streamlit_entity_model import (
|
|
2
|
-
StreamlitEntityModel,
|
|
3
|
-
)
|
|
4
|
-
from snowflake.cli.api.entities.common import EntityBase
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class StreamlitEntity(EntityBase[StreamlitEntityModel]):
|
|
8
|
-
"""
|
|
9
|
-
A Streamlit app.
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
pass
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2024 Snowflake Inc.
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
from __future__ import annotations
|
|
15
|
-
|
|
16
|
-
from pathlib import Path
|
|
17
|
-
from typing import List, Literal, Optional
|
|
18
|
-
|
|
19
|
-
from pydantic import Field, model_validator
|
|
20
|
-
from snowflake.cli.api.project.schemas.entities.common import (
|
|
21
|
-
EntityModelBase,
|
|
22
|
-
ExternalAccessBaseModel,
|
|
23
|
-
ImportsBaseModel,
|
|
24
|
-
)
|
|
25
|
-
from snowflake.cli.api.project.schemas.updatable_model import (
|
|
26
|
-
DiscriminatorField,
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
class StreamlitEntityModel(EntityModelBase, ExternalAccessBaseModel, ImportsBaseModel):
|
|
31
|
-
type: Literal["streamlit"] = DiscriminatorField() # noqa: A003
|
|
32
|
-
title: Optional[str] = Field(
|
|
33
|
-
title="Human-readable title for the Streamlit dashboard", default=None
|
|
34
|
-
)
|
|
35
|
-
comment: Optional[str] = Field(title="Comment for the Streamlit app", default=None)
|
|
36
|
-
query_warehouse: str = Field(
|
|
37
|
-
title="Snowflake warehouse to host the app", default=None
|
|
38
|
-
)
|
|
39
|
-
main_file: Optional[str] = Field(
|
|
40
|
-
title="Entrypoint file of the Streamlit app", default="streamlit_app.py"
|
|
41
|
-
)
|
|
42
|
-
pages_dir: Optional[str] = Field(title="Streamlit pages", default=None)
|
|
43
|
-
stage: Optional[str] = Field(
|
|
44
|
-
title="Stage in which the app’s artifacts will be stored", default="streamlit"
|
|
45
|
-
)
|
|
46
|
-
# Possibly can be PathMapping
|
|
47
|
-
artifacts: Optional[List[Path]] = Field(
|
|
48
|
-
title="List of files which should be deployed. Each file needs to exist locally. "
|
|
49
|
-
"Main file needs to be included in the artifacts.",
|
|
50
|
-
default=None,
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
@model_validator(mode="after")
|
|
54
|
-
def artifacts_must_exists(self):
|
|
55
|
-
if not self.artifacts:
|
|
56
|
-
return self
|
|
57
|
-
|
|
58
|
-
for artifact in self.artifacts:
|
|
59
|
-
if "*" in artifact.name:
|
|
60
|
-
continue
|
|
61
|
-
if not artifact.exists():
|
|
62
|
-
raise ValueError(
|
|
63
|
-
f"Specified artifact {artifact} does not exist locally."
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
return self
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2024 Snowflake Inc.
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
from dataclasses import dataclass
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
from typing import Callable, Optional
|
|
4
|
-
|
|
5
|
-
from snowflake.cli.api.console.abc import AbstractConsole
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@dataclass
|
|
9
|
-
class ActionContext:
|
|
10
|
-
"""
|
|
11
|
-
An object that is passed to each action when called by WorkspaceManager
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
console: AbstractConsole
|
|
15
|
-
project_root: Path
|
|
16
|
-
default_role: str
|
|
17
|
-
default_warehouse: Optional[str]
|
|
18
|
-
get_entity: Callable
|
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2024 Snowflake Inc.
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
from __future__ import annotations
|
|
16
|
-
|
|
17
|
-
import logging
|
|
18
|
-
from pathlib import Path
|
|
19
|
-
from textwrap import dedent
|
|
20
|
-
from typing import List, Optional
|
|
21
|
-
|
|
22
|
-
import typer
|
|
23
|
-
from click import MissingParameter
|
|
24
|
-
from snowflake.cli._plugins.nativeapp.artifacts import BundleMap
|
|
25
|
-
from snowflake.cli._plugins.nativeapp.common_flags import (
|
|
26
|
-
ForceOption,
|
|
27
|
-
InteractiveOption,
|
|
28
|
-
ValidateOption,
|
|
29
|
-
)
|
|
30
|
-
from snowflake.cli._plugins.workspace.manager import WorkspaceManager
|
|
31
|
-
from snowflake.cli.api.cli_global_context import get_cli_context
|
|
32
|
-
from snowflake.cli.api.commands.decorators import with_project_definition
|
|
33
|
-
from snowflake.cli.api.commands.snow_typer import SnowTyperFactory
|
|
34
|
-
from snowflake.cli.api.entities.common import EntityActions
|
|
35
|
-
from snowflake.cli.api.exceptions import IncompatibleParametersError
|
|
36
|
-
from snowflake.cli.api.output.types import MessageResult, QueryResult
|
|
37
|
-
|
|
38
|
-
ws = SnowTyperFactory(
|
|
39
|
-
name="ws",
|
|
40
|
-
help="Deploy and interact with snowflake.yml-based entities.",
|
|
41
|
-
is_hidden=lambda: True,
|
|
42
|
-
)
|
|
43
|
-
log = logging.getLogger(__name__)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
@ws.command(requires_connection=True, hidden=True)
|
|
47
|
-
@with_project_definition()
|
|
48
|
-
def bundle(
|
|
49
|
-
entity_id: str = typer.Option(
|
|
50
|
-
help=f"""The ID of the entity you want to bundle.""",
|
|
51
|
-
),
|
|
52
|
-
**options,
|
|
53
|
-
):
|
|
54
|
-
"""
|
|
55
|
-
Prepares a local folder with the configured artifacts of the specified entity.
|
|
56
|
-
"""
|
|
57
|
-
|
|
58
|
-
cli_context = get_cli_context()
|
|
59
|
-
ws = WorkspaceManager(
|
|
60
|
-
project_definition=cli_context.project_definition,
|
|
61
|
-
project_root=cli_context.project_root,
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
bundle_map: BundleMap = ws.perform_action(entity_id, EntityActions.BUNDLE)
|
|
65
|
-
return MessageResult(f"Bundle generated at {bundle_map.deploy_root()}")
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
@ws.command(requires_connection=True, hidden=True)
|
|
69
|
-
@with_project_definition()
|
|
70
|
-
def deploy(
|
|
71
|
-
entity_id: str = typer.Option(
|
|
72
|
-
help=f"""The ID of the entity you want to deploy.""",
|
|
73
|
-
),
|
|
74
|
-
# TODO The following options should be generated automatically, depending on the specified entity type
|
|
75
|
-
prune: Optional[bool] = typer.Option(
|
|
76
|
-
default=None,
|
|
77
|
-
help=f"""Whether to delete specified files from the stage if they don't exist locally. If set, the command deletes files that exist in the stage, but not in the local filesystem. This option cannot be used when paths are specified.""",
|
|
78
|
-
),
|
|
79
|
-
recursive: Optional[bool] = typer.Option(
|
|
80
|
-
None,
|
|
81
|
-
"--recursive/--no-recursive",
|
|
82
|
-
"-r",
|
|
83
|
-
help=f"""Whether to traverse and deploy files from subdirectories. If set, the command deploys all files and subdirectories; otherwise, only files in the current directory are deployed.""",
|
|
84
|
-
),
|
|
85
|
-
paths: Optional[List[Path]] = typer.Argument(
|
|
86
|
-
default=None,
|
|
87
|
-
show_default=False,
|
|
88
|
-
help=dedent(
|
|
89
|
-
f"""
|
|
90
|
-
Paths, relative to the the project root, of files or directories you want to upload to a stage. If a file is
|
|
91
|
-
specified, it must match one of the artifacts src pattern entries in snowflake.yml. If a directory is
|
|
92
|
-
specified, it will be searched for subfolders or files to deploy based on artifacts src pattern entries. If
|
|
93
|
-
unspecified, the command syncs all local changes to the stage."""
|
|
94
|
-
).strip(),
|
|
95
|
-
),
|
|
96
|
-
from_release_directive: Optional[bool] = typer.Option(
|
|
97
|
-
False,
|
|
98
|
-
"--from-release-directive",
|
|
99
|
-
help=f"""Creates or upgrades an application object to the version and patch specified by the release directive applicable to your Snowflake account.
|
|
100
|
-
The command fails if no release directive exists for your Snowflake account for a given application package, which is determined from the project definition file. Default: unset.""",
|
|
101
|
-
is_flag=True,
|
|
102
|
-
),
|
|
103
|
-
interactive: bool = InteractiveOption,
|
|
104
|
-
force: Optional[bool] = ForceOption,
|
|
105
|
-
validate: bool = ValidateOption,
|
|
106
|
-
**options,
|
|
107
|
-
):
|
|
108
|
-
"""
|
|
109
|
-
Deploys the specified entity.
|
|
110
|
-
"""
|
|
111
|
-
if prune is None and recursive is None and not paths:
|
|
112
|
-
prune = True
|
|
113
|
-
recursive = True
|
|
114
|
-
else:
|
|
115
|
-
if prune is None:
|
|
116
|
-
prune = False
|
|
117
|
-
if recursive is None:
|
|
118
|
-
recursive = False
|
|
119
|
-
|
|
120
|
-
if paths and prune:
|
|
121
|
-
raise IncompatibleParametersError(["paths", "--prune"])
|
|
122
|
-
|
|
123
|
-
cli_context = get_cli_context()
|
|
124
|
-
ws = WorkspaceManager(
|
|
125
|
-
project_definition=cli_context.project_definition,
|
|
126
|
-
project_root=cli_context.project_root,
|
|
127
|
-
)
|
|
128
|
-
|
|
129
|
-
ws.perform_action(
|
|
130
|
-
entity_id,
|
|
131
|
-
EntityActions.DEPLOY,
|
|
132
|
-
prune=prune,
|
|
133
|
-
recursive=recursive,
|
|
134
|
-
paths=paths,
|
|
135
|
-
validate=validate,
|
|
136
|
-
from_release_directive=from_release_directive,
|
|
137
|
-
interactive=interactive,
|
|
138
|
-
force=force,
|
|
139
|
-
)
|
|
140
|
-
return MessageResult("Deployed successfully.")
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
@ws.command(requires_connection=True, hidden=True)
|
|
144
|
-
@with_project_definition()
|
|
145
|
-
def drop(
|
|
146
|
-
entity_id: str = typer.Option(
|
|
147
|
-
help=f"""The ID of the entity you want to drop.""",
|
|
148
|
-
),
|
|
149
|
-
# TODO The following options should be generated automatically, depending on the specified entity type
|
|
150
|
-
interactive: bool = InteractiveOption,
|
|
151
|
-
force: Optional[bool] = ForceOption,
|
|
152
|
-
cascade: Optional[bool] = typer.Option(
|
|
153
|
-
None,
|
|
154
|
-
help=f"""Whether to drop all application objects owned by the application within the account. Default: false.""",
|
|
155
|
-
show_default=False,
|
|
156
|
-
),
|
|
157
|
-
**options,
|
|
158
|
-
):
|
|
159
|
-
"""
|
|
160
|
-
Drops the specified entity.
|
|
161
|
-
"""
|
|
162
|
-
cli_context = get_cli_context()
|
|
163
|
-
ws = WorkspaceManager(
|
|
164
|
-
project_definition=cli_context.project_definition,
|
|
165
|
-
project_root=cli_context.project_root,
|
|
166
|
-
)
|
|
167
|
-
|
|
168
|
-
ws.perform_action(
|
|
169
|
-
entity_id,
|
|
170
|
-
EntityActions.DROP,
|
|
171
|
-
force_drop=force,
|
|
172
|
-
interactive=interactive,
|
|
173
|
-
cascade=cascade,
|
|
174
|
-
)
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
@ws.command(requires_connection=True, hidden=True)
|
|
178
|
-
@with_project_definition()
|
|
179
|
-
def validate(
|
|
180
|
-
entity_id: str = typer.Option(
|
|
181
|
-
help=f"""The ID of the entity you want to validate.""",
|
|
182
|
-
),
|
|
183
|
-
interactive: bool = InteractiveOption,
|
|
184
|
-
force: Optional[bool] = ForceOption,
|
|
185
|
-
**options,
|
|
186
|
-
):
|
|
187
|
-
"""Validates the specified entity."""
|
|
188
|
-
cli_context = get_cli_context()
|
|
189
|
-
ws = WorkspaceManager(
|
|
190
|
-
project_definition=cli_context.project_definition,
|
|
191
|
-
project_root=cli_context.project_root,
|
|
192
|
-
)
|
|
193
|
-
|
|
194
|
-
ws.perform_action(
|
|
195
|
-
entity_id,
|
|
196
|
-
EntityActions.VALIDATE,
|
|
197
|
-
interactive=interactive,
|
|
198
|
-
force=force,
|
|
199
|
-
)
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
version = SnowTyperFactory(
|
|
203
|
-
name="version",
|
|
204
|
-
help="Manages versions for project entities.",
|
|
205
|
-
)
|
|
206
|
-
ws.add_typer(version)
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
@version.command(name="list", requires_connection=True, hidden=True)
|
|
210
|
-
@with_project_definition()
|
|
211
|
-
def version_list(
|
|
212
|
-
entity_id: str = typer.Option(
|
|
213
|
-
help="The ID of the entity you want to list versions for.",
|
|
214
|
-
),
|
|
215
|
-
**options,
|
|
216
|
-
):
|
|
217
|
-
"""Lists the versions of the specified entity."""
|
|
218
|
-
cli_context = get_cli_context()
|
|
219
|
-
ws = WorkspaceManager(
|
|
220
|
-
project_definition=cli_context.project_definition,
|
|
221
|
-
project_root=cli_context.project_root,
|
|
222
|
-
)
|
|
223
|
-
cursor = ws.perform_action(
|
|
224
|
-
entity_id,
|
|
225
|
-
EntityActions.VERSION_LIST,
|
|
226
|
-
)
|
|
227
|
-
return QueryResult(cursor)
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
@version.command(name="create", requires_connection=True, hidden=True)
|
|
231
|
-
@with_project_definition()
|
|
232
|
-
def version_create(
|
|
233
|
-
entity_id: str = typer.Option(
|
|
234
|
-
help="The ID of the entity you want to create a version for.",
|
|
235
|
-
),
|
|
236
|
-
version: Optional[str] = typer.Argument(
|
|
237
|
-
None,
|
|
238
|
-
help=f"""Version to define in your application package. If the version already exists, an auto-incremented patch is added to the version instead. Defaults to the version specified in the `manifest.yml` file.""",
|
|
239
|
-
),
|
|
240
|
-
patch: Optional[int] = typer.Option(
|
|
241
|
-
None,
|
|
242
|
-
"--patch",
|
|
243
|
-
help=f"""The patch number you want to create for an existing version.
|
|
244
|
-
Defaults to undefined if it is not set, which means the Snowflake CLI either uses the patch specified in the `manifest.yml` file or automatically generates a new patch number.""",
|
|
245
|
-
),
|
|
246
|
-
skip_git_check: Optional[bool] = typer.Option(
|
|
247
|
-
False,
|
|
248
|
-
"--skip-git-check",
|
|
249
|
-
help="When enabled, the Snowflake CLI skips checking if your project has any untracked or stages files in git. Default: unset.",
|
|
250
|
-
is_flag=True,
|
|
251
|
-
),
|
|
252
|
-
interactive: bool = InteractiveOption,
|
|
253
|
-
force: Optional[bool] = ForceOption,
|
|
254
|
-
**options,
|
|
255
|
-
):
|
|
256
|
-
"""Creates a new version for the specified entity."""
|
|
257
|
-
if version is None and patch is not None:
|
|
258
|
-
raise MissingParameter("Cannot provide a patch without version!")
|
|
259
|
-
|
|
260
|
-
cli_context = get_cli_context()
|
|
261
|
-
ws = WorkspaceManager(
|
|
262
|
-
project_definition=cli_context.project_definition,
|
|
263
|
-
project_root=cli_context.project_root,
|
|
264
|
-
)
|
|
265
|
-
ws.perform_action(
|
|
266
|
-
entity_id,
|
|
267
|
-
EntityActions.VERSION_CREATE,
|
|
268
|
-
version=version,
|
|
269
|
-
patch=patch,
|
|
270
|
-
skip_git_check=skip_git_check,
|
|
271
|
-
interactive=interactive,
|
|
272
|
-
force=force,
|
|
273
|
-
)
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
@version.command(name="drop", requires_connection=True, hidden=True)
|
|
277
|
-
@with_project_definition()
|
|
278
|
-
def version_drop(
|
|
279
|
-
entity_id: str = typer.Option(
|
|
280
|
-
help="The ID of the entity you want to create a version for.",
|
|
281
|
-
),
|
|
282
|
-
version: Optional[str] = typer.Argument(
|
|
283
|
-
None,
|
|
284
|
-
help=f"""Version to define in your application package. If the version already exists, an auto-incremented patch is added to the version instead. Defaults to the version specified in the `manifest.yml` file.""",
|
|
285
|
-
),
|
|
286
|
-
interactive: bool = InteractiveOption,
|
|
287
|
-
force: Optional[bool] = ForceOption,
|
|
288
|
-
**options,
|
|
289
|
-
):
|
|
290
|
-
"""
|
|
291
|
-
Drops a version defined for your entity. Versions can either be passed in as an argument to the command or read from the `manifest.yml` file.
|
|
292
|
-
Dropping patches is not allowed.
|
|
293
|
-
"""
|
|
294
|
-
|
|
295
|
-
cli_context = get_cli_context()
|
|
296
|
-
ws = WorkspaceManager(
|
|
297
|
-
project_definition=cli_context.project_definition,
|
|
298
|
-
project_root=cli_context.project_root,
|
|
299
|
-
)
|
|
300
|
-
ws.perform_action(
|
|
301
|
-
entity_id,
|
|
302
|
-
EntityActions.VERSION_CREATE,
|
|
303
|
-
version=version,
|
|
304
|
-
interactive=interactive,
|
|
305
|
-
force=force,
|
|
306
|
-
)
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
from typing import Dict
|
|
3
|
-
|
|
4
|
-
from snowflake.cli._plugins.workspace.action_context import ActionContext
|
|
5
|
-
from snowflake.cli.api.cli_global_context import get_cli_context
|
|
6
|
-
from snowflake.cli.api.console import cli_console as cc
|
|
7
|
-
from snowflake.cli.api.entities.common import EntityActions, get_sql_executor
|
|
8
|
-
from snowflake.cli.api.exceptions import InvalidProjectDefinitionVersionError
|
|
9
|
-
from snowflake.cli.api.project.definition import default_role
|
|
10
|
-
from snowflake.cli.api.project.schemas.entities.entities import (
|
|
11
|
-
Entity,
|
|
12
|
-
v2_entity_model_to_entity_map,
|
|
13
|
-
)
|
|
14
|
-
from snowflake.cli.api.project.schemas.project_definition import (
|
|
15
|
-
DefinitionV20,
|
|
16
|
-
ProjectDefinition,
|
|
17
|
-
)
|
|
18
|
-
from snowflake.cli.api.project.util import to_identifier
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class WorkspaceManager:
|
|
22
|
-
"""
|
|
23
|
-
Instantiates entity instances from entity models, providing higher-order functionality on entity compositions.
|
|
24
|
-
"""
|
|
25
|
-
|
|
26
|
-
def __init__(self, project_definition: ProjectDefinition, project_root: Path):
|
|
27
|
-
if not project_definition.meets_version_requirement("2"):
|
|
28
|
-
raise InvalidProjectDefinitionVersionError(
|
|
29
|
-
"2.x", project_definition.definition_version
|
|
30
|
-
)
|
|
31
|
-
self._entities_cache: Dict[str, Entity] = {}
|
|
32
|
-
self._project_definition: DefinitionV20 = project_definition
|
|
33
|
-
self._project_root = project_root
|
|
34
|
-
self._default_role = default_role()
|
|
35
|
-
if self._default_role is None:
|
|
36
|
-
self._default_role = get_sql_executor().current_role()
|
|
37
|
-
self.default_warehouse = None
|
|
38
|
-
cli_context = get_cli_context()
|
|
39
|
-
if cli_context.connection.warehouse:
|
|
40
|
-
self.default_warehouse = to_identifier(cli_context.connection.warehouse)
|
|
41
|
-
|
|
42
|
-
def get_entity(self, entity_id: str):
|
|
43
|
-
"""
|
|
44
|
-
Returns an entity instance with the given ID. If exists, reuses the previously returned instance, or instantiates a new one otherwise.
|
|
45
|
-
"""
|
|
46
|
-
if entity_id in self._entities_cache:
|
|
47
|
-
return self._entities_cache[entity_id]
|
|
48
|
-
entity_model = self._project_definition.entities.get(entity_id, None)
|
|
49
|
-
if entity_model is None:
|
|
50
|
-
raise ValueError(f"No such entity ID: {entity_id}")
|
|
51
|
-
entity_model_cls = entity_model.__class__
|
|
52
|
-
entity_cls = v2_entity_model_to_entity_map[entity_model_cls]
|
|
53
|
-
self._entities_cache[entity_id] = entity_cls(entity_model)
|
|
54
|
-
return self._entities_cache[entity_id]
|
|
55
|
-
|
|
56
|
-
def perform_action(self, entity_id: str, action: EntityActions, *args, **kwargs):
|
|
57
|
-
"""
|
|
58
|
-
Instantiates an entity of the given ID and calls the given action on it.
|
|
59
|
-
"""
|
|
60
|
-
entity = self.get_entity(entity_id)
|
|
61
|
-
if entity.supports(action):
|
|
62
|
-
action_ctx = ActionContext(
|
|
63
|
-
console=cc,
|
|
64
|
-
project_root=self.project_root(),
|
|
65
|
-
default_role=self._default_role,
|
|
66
|
-
default_warehouse=self.default_warehouse,
|
|
67
|
-
get_entity=self.get_entity,
|
|
68
|
-
)
|
|
69
|
-
return entity.perform(action, action_ctx, *args, **kwargs)
|
|
70
|
-
else:
|
|
71
|
-
raise ValueError(f'This entity type does not support "{action.value}"')
|
|
72
|
-
|
|
73
|
-
def project_root(self) -> Path:
|
|
74
|
-
return self._project_root
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2024 Snowflake Inc.
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
from snowflake.cli._plugins.workspace import commands
|
|
16
|
-
from snowflake.cli.api.plugins.command import (
|
|
17
|
-
SNOWCLI_ROOT_COMMAND_PATH,
|
|
18
|
-
CommandSpec,
|
|
19
|
-
CommandType,
|
|
20
|
-
plugin_hook_impl,
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
@plugin_hook_impl
|
|
25
|
-
def command_spec():
|
|
26
|
-
return CommandSpec(
|
|
27
|
-
parent_command_path=SNOWCLI_ROOT_COMMAND_PATH,
|
|
28
|
-
command_type=CommandType.COMMAND_GROUP,
|
|
29
|
-
typer_instance=commands.ws.create_instance(),
|
|
30
|
-
)
|
snowflake/cli/api/__init__.py
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2024 Snowflake Inc.
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
from __future__ import annotations
|
|
16
|
-
|
|
17
|
-
from typing import Optional
|
|
18
|
-
|
|
19
|
-
from snowflake.cli.api.plugins.plugin_config import PluginConfigProvider
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class Api:
|
|
23
|
-
def __init__(
|
|
24
|
-
self,
|
|
25
|
-
plugin_config_provider: PluginConfigProvider,
|
|
26
|
-
):
|
|
27
|
-
self.plugin_config_provider = plugin_config_provider
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
class ApiNotInitializedError(RuntimeError):
|
|
31
|
-
"""There was a try to use CLI's API while it is still not initialized."""
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class ApiProvider:
|
|
35
|
-
def __init__(self):
|
|
36
|
-
self._api: Optional[Api] = None
|
|
37
|
-
|
|
38
|
-
def register_api(self, api: Api) -> None:
|
|
39
|
-
self._api = api
|
|
40
|
-
|
|
41
|
-
def api(self) -> Api:
|
|
42
|
-
if self._api:
|
|
43
|
-
return self._api
|
|
44
|
-
else:
|
|
45
|
-
raise ApiNotInitializedError()
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
api_provider = ApiProvider()
|