frogml-cli 0.0.1__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.
- frogml_cli/__init__.py +10 -0
- frogml_cli/cli.py +40 -0
- frogml_cli/commands/__init__.py +0 -0
- frogml_cli/commands/_logic/__init__.py +0 -0
- frogml_cli/commands/_logic/tools.py +6 -0
- frogml_cli/commands/alerts/__init__.py +0 -0
- frogml_cli/commands/alerts/alerts_commnad_group.py +18 -0
- frogml_cli/commands/alerts/delete/__init__.py +0 -0
- frogml_cli/commands/alerts/delete/_logic.py +5 -0
- frogml_cli/commands/alerts/delete/ui.py +10 -0
- frogml_cli/commands/alerts/list/__init__.py +0 -0
- frogml_cli/commands/alerts/list/_logic.py +23 -0
- frogml_cli/commands/alerts/list/ui.py +17 -0
- frogml_cli/commands/alerts/register/__init__.py +0 -0
- frogml_cli/commands/alerts/register/_logic.py +72 -0
- frogml_cli/commands/alerts/register/ui.py +30 -0
- frogml_cli/commands/audience/__init__.py +0 -0
- frogml_cli/commands/audience/_logic/__init__.py +0 -0
- frogml_cli/commands/audience/_logic/config/__init__.py +0 -0
- frogml_cli/commands/audience/_logic/config/config_base.py +15 -0
- frogml_cli/commands/audience/_logic/config/parser.py +30 -0
- frogml_cli/commands/audience/_logic/config/v1/__init__.py +0 -0
- frogml_cli/commands/audience/_logic/config/v1/audience_config.py +25 -0
- frogml_cli/commands/audience/_logic/config/v1/conditions_config.py +59 -0
- frogml_cli/commands/audience/_logic/config/v1/config_v1.py +23 -0
- frogml_cli/commands/audience/_logic/config/v1/route_config.py +15 -0
- frogml_cli/commands/audience/_logic/config/v1/spec.py +9 -0
- frogml_cli/commands/audience/audience_api_dump.py +86 -0
- frogml_cli/commands/audience/audience_commands_group.py +30 -0
- frogml_cli/commands/audience/create/__init__.py +0 -0
- frogml_cli/commands/audience/create/logic.py +41 -0
- frogml_cli/commands/audience/create/ui.py +21 -0
- frogml_cli/commands/audience/delete/__init__.py +0 -0
- frogml_cli/commands/audience/delete/logic.py +13 -0
- frogml_cli/commands/audience/delete/ui.py +17 -0
- frogml_cli/commands/audience/get/__init__.py +0 -0
- frogml_cli/commands/audience/get/logic.py +14 -0
- frogml_cli/commands/audience/get/ui.py +25 -0
- frogml_cli/commands/audience/list/__init__.py +0 -0
- frogml_cli/commands/audience/list/logic.py +16 -0
- frogml_cli/commands/audience/list/ui.py +26 -0
- frogml_cli/commands/audience/update/__init__.py +0 -0
- frogml_cli/commands/audience/update/logic.py +37 -0
- frogml_cli/commands/audience/update/ui.py +26 -0
- frogml_cli/commands/auto_scalling/__init__.py +0 -0
- frogml_cli/commands/auto_scalling/_logic/__init__.py +0 -0
- frogml_cli/commands/auto_scalling/_logic/config/__init__.py +3 -0
- frogml_cli/commands/auto_scalling/_logic/config/config.py +152 -0
- frogml_cli/commands/auto_scalling/_logic/config/parser.py +21 -0
- frogml_cli/commands/auto_scalling/attach/__init__.py +0 -0
- frogml_cli/commands/auto_scalling/attach/_logic.py +43 -0
- frogml_cli/commands/auto_scalling/attach/ui.py +21 -0
- frogml_cli/commands/auto_scalling/autoscaling_commands_group.py +15 -0
- frogml_cli/commands/automations/__init__.py +0 -0
- frogml_cli/commands/automations/automations_commands_group.py +30 -0
- frogml_cli/commands/automations/delete/__init__.py +0 -0
- frogml_cli/commands/automations/delete/_logic.py +6 -0
- frogml_cli/commands/automations/delete/ui.py +23 -0
- frogml_cli/commands/automations/executions/__init__.py +0 -0
- frogml_cli/commands/automations/executions/executions_commands_group.py +14 -0
- frogml_cli/commands/automations/executions/list/__init__.py +0 -0
- frogml_cli/commands/automations/executions/list/_logic.py +8 -0
- frogml_cli/commands/automations/executions/list/ui.py +27 -0
- frogml_cli/commands/automations/list/__init__.py +0 -0
- frogml_cli/commands/automations/list/_logic.py +36 -0
- frogml_cli/commands/automations/list/ui.py +21 -0
- frogml_cli/commands/automations/register/__init__.py +0 -0
- frogml_cli/commands/automations/register/_logic.py +43 -0
- frogml_cli/commands/automations/register/ui.py +44 -0
- frogml_cli/commands/config/__init__.py +0 -0
- frogml_cli/commands/config/add/__init__.py +0 -0
- frogml_cli/commands/config/add/ui.py +62 -0
- frogml_cli/commands/config/config_commands_group.py +11 -0
- frogml_cli/commands/feature_store/__init__.py +0 -0
- frogml_cli/commands/feature_store/backfill/__init__.py +0 -0
- frogml_cli/commands/feature_store/backfill/_logic.py +140 -0
- frogml_cli/commands/feature_store/backfill/ui.py +129 -0
- frogml_cli/commands/feature_store/delete/__init__.py +0 -0
- frogml_cli/commands/feature_store/delete/_logic.py +107 -0
- frogml_cli/commands/feature_store/delete/ui.py +40 -0
- frogml_cli/commands/feature_store/execution/__init__.py +0 -0
- frogml_cli/commands/feature_store/execution/ui.py +19 -0
- frogml_cli/commands/feature_store/feature_store_command_group.py +29 -0
- frogml_cli/commands/feature_store/list/__init__.py +0 -0
- frogml_cli/commands/feature_store/list/ui.py +140 -0
- frogml_cli/commands/feature_store/pause/__init__.py +0 -0
- frogml_cli/commands/feature_store/pause/ui.py +18 -0
- frogml_cli/commands/feature_store/register/__init__.py +0 -0
- frogml_cli/commands/feature_store/register/_logic.py +369 -0
- frogml_cli/commands/feature_store/register/ui.py +111 -0
- frogml_cli/commands/feature_store/resume/__init__.py +0 -0
- frogml_cli/commands/feature_store/resume/ui.py +18 -0
- frogml_cli/commands/feature_store/trigger/__init__.py +0 -0
- frogml_cli/commands/feature_store/trigger/ui.py +39 -0
- frogml_cli/commands/models/__init__.py +0 -0
- frogml_cli/commands/models/build/__init__.py +0 -0
- frogml_cli/commands/models/build/_logic/__init__.py +0 -0
- frogml_cli/commands/models/build/_logic/build_steps.py +42 -0
- frogml_cli/commands/models/build/_logic/client_logs/__init__.py +0 -0
- frogml_cli/commands/models/build/_logic/client_logs/cli_phase_run_handler.py +123 -0
- frogml_cli/commands/models/build/_logic/client_logs/cli_trigger_build_logger.py +19 -0
- frogml_cli/commands/models/build/_logic/client_logs/logger.py +88 -0
- frogml_cli/commands/models/build/_logic/client_logs/messages.py +36 -0
- frogml_cli/commands/models/build/_logic/client_logs/spinner.py +14 -0
- frogml_cli/commands/models/build/_logic/client_logs/trigger_build_logger.py +54 -0
- frogml_cli/commands/models/build/_logic/client_logs/utils.py +12 -0
- frogml_cli/commands/models/build/_logic/phase/__init__.py +0 -0
- frogml_cli/commands/models/build/_logic/phase/a_fetch_model_code/__init__.py +20 -0
- frogml_cli/commands/models/build/_logic/phase/a_fetch_model_code/get_sdk_version_step.py +15 -0
- frogml_cli/commands/models/build/_logic/phase/b_remote_register_frogml_build/__init__.py +16 -0
- frogml_cli/commands/models/build/_logic/phase/c_deploy/__init__.py +6 -0
- frogml_cli/commands/models/build/_logic/phase/c_deploy/build_polling_status.py +55 -0
- frogml_cli/commands/models/build/_logic/phase/c_deploy/deploy_build.py +61 -0
- frogml_cli/commands/models/build/_logic/util/__init__.py +0 -0
- frogml_cli/commands/models/build/_logic/util/protobuf_factory.py +45 -0
- frogml_cli/commands/models/build/_logic/util/step_decorator.py +60 -0
- frogml_cli/commands/models/build/_logic/util/text.py +9 -0
- frogml_cli/commands/models/build/_logic/wait_until_finished.py +27 -0
- frogml_cli/commands/models/build/ui.py +337 -0
- frogml_cli/commands/models/builds/__init__.py +0 -0
- frogml_cli/commands/models/builds/builds_commands_group.py +16 -0
- frogml_cli/commands/models/builds/cancel/__init__.py +0 -0
- frogml_cli/commands/models/builds/cancel/_logic.py +5 -0
- frogml_cli/commands/models/builds/cancel/ui.py +15 -0
- frogml_cli/commands/models/builds/logs/__init__.py +0 -0
- frogml_cli/commands/models/builds/logs/ui.py +35 -0
- frogml_cli/commands/models/builds/status/__init__.py +0 -0
- frogml_cli/commands/models/builds/status/_logic.py +6 -0
- frogml_cli/commands/models/builds/status/ui.py +39 -0
- frogml_cli/commands/models/create/__init__.py +0 -0
- frogml_cli/commands/models/create/_logic.py +40 -0
- frogml_cli/commands/models/create/ui.py +46 -0
- frogml_cli/commands/models/delete/__init__.py +0 -0
- frogml_cli/commands/models/delete/_logic.py +18 -0
- frogml_cli/commands/models/delete/ui.py +25 -0
- frogml_cli/commands/models/deployments/__init__.py +0 -0
- frogml_cli/commands/models/deployments/deploy/__init__.py +0 -0
- frogml_cli/commands/models/deployments/deploy/_logic/__init__.py +0 -0
- frogml_cli/commands/models/deployments/deploy/_logic/advance_deployment_options_handler.py +31 -0
- frogml_cli/commands/models/deployments/deploy/_logic/base_deploy_executor.py +70 -0
- frogml_cli/commands/models/deployments/deploy/_logic/deploy_config.py +261 -0
- frogml_cli/commands/models/deployments/deploy/_logic/deployment.py +407 -0
- frogml_cli/commands/models/deployments/deploy/_logic/deployment_message_helpers.py +116 -0
- frogml_cli/commands/models/deployments/deploy/_logic/deployment_response_handler.py +156 -0
- frogml_cli/commands/models/deployments/deploy/_logic/deployment_size_mapper.py +98 -0
- frogml_cli/commands/models/deployments/deploy/_logic/get_latest_successful_build.py +28 -0
- frogml_cli/commands/models/deployments/deploy/_logic/local_deployment.py +193 -0
- frogml_cli/commands/models/deployments/deploy/batch/__init__.py +0 -0
- frogml_cli/commands/models/deployments/deploy/batch/_logic/__init__.py +0 -0
- frogml_cli/commands/models/deployments/deploy/batch/_logic/advanced_deployment_mapper.py +15 -0
- frogml_cli/commands/models/deployments/deploy/batch/_logic/deploy_executor.py +24 -0
- frogml_cli/commands/models/deployments/deploy/batch/ui.py +119 -0
- frogml_cli/commands/models/deployments/deploy/deploy_commands_group.py +19 -0
- frogml_cli/commands/models/deployments/deploy/realtime/__init__.py +0 -0
- frogml_cli/commands/models/deployments/deploy/realtime/_logic/__init__.py +0 -0
- frogml_cli/commands/models/deployments/deploy/realtime/_logic/advanced_deployment_mapper.py +21 -0
- frogml_cli/commands/models/deployments/deploy/realtime/_logic/deploy_executor.py +24 -0
- frogml_cli/commands/models/deployments/deploy/realtime/_logic/serving_strategy_mapper.py +75 -0
- frogml_cli/commands/models/deployments/deploy/realtime/ui.py +202 -0
- frogml_cli/commands/models/deployments/deploy/streaming/__init__.py +0 -0
- frogml_cli/commands/models/deployments/deploy/streaming/_logic/__init__.py +0 -0
- frogml_cli/commands/models/deployments/deploy/streaming/_logic/deploy_executor.py +24 -0
- frogml_cli/commands/models/deployments/deploy/streaming/_logic/serving_strategy_mapper.py +38 -0
- frogml_cli/commands/models/deployments/deploy/streaming/ui.py +206 -0
- frogml_cli/commands/models/deployments/undeploy/__init__.py +0 -0
- frogml_cli/commands/models/deployments/undeploy/_logic/__init__.py +0 -0
- frogml_cli/commands/models/deployments/undeploy/_logic/request_undeploy.py +249 -0
- frogml_cli/commands/models/deployments/undeploy/ui.py +61 -0
- frogml_cli/commands/models/describe/__init__.py +0 -0
- frogml_cli/commands/models/describe/_logic.py +169 -0
- frogml_cli/commands/models/describe/ui.py +35 -0
- frogml_cli/commands/models/executions/__init__.py +0 -0
- frogml_cli/commands/models/executions/cancel/__init__.py +0 -0
- frogml_cli/commands/models/executions/cancel/_logic.py +9 -0
- frogml_cli/commands/models/executions/cancel/ui.py +27 -0
- frogml_cli/commands/models/executions/execution_commands_group.py +24 -0
- frogml_cli/commands/models/executions/report/__init__.py +0 -0
- frogml_cli/commands/models/executions/report/_logic.py +14 -0
- frogml_cli/commands/models/executions/report/ui.py +43 -0
- frogml_cli/commands/models/executions/start/__init__.py +0 -0
- frogml_cli/commands/models/executions/start/_logic.py +83 -0
- frogml_cli/commands/models/executions/start/ui.py +208 -0
- frogml_cli/commands/models/executions/status/__init__.py +0 -0
- frogml_cli/commands/models/executions/status/_logic.py +13 -0
- frogml_cli/commands/models/executions/status/ui.py +27 -0
- frogml_cli/commands/models/init/__init__.py +0 -0
- frogml_cli/commands/models/init/_logic/__init__.py +0 -0
- frogml_cli/commands/models/init/_logic/initialize_model_structure.py +40 -0
- frogml_cli/commands/models/init/_logic/template/__init__.py +0 -0
- frogml_cli/commands/models/init/_logic/template/churn/__init__.py +0 -0
- frogml_cli/commands/models/init/_logic/template/churn/cookiecutter.json +3 -0
- frogml_cli/commands/models/init/_logic/template/churn/{{cookiecutter.model_directory}}/__init__.py +0 -0
- frogml_cli/commands/models/init/_logic/template/churn/{{cookiecutter.model_directory}}/main/__init__.py +5 -0
- frogml_cli/commands/models/init/_logic/template/churn/{{cookiecutter.model_directory}}/main/conda.yml +10 -0
- frogml_cli/commands/models/init/_logic/template/churn/{{cookiecutter.model_directory}}/main/data.csv +1001 -0
- frogml_cli/commands/models/init/_logic/template/churn/{{cookiecutter.model_directory}}/main/model.py +99 -0
- frogml_cli/commands/models/init/_logic/template/churn/{{cookiecutter.model_directory}}/tests/__init__.py +0 -0
- frogml_cli/commands/models/init/_logic/template/churn/{{cookiecutter.model_directory}}/tests/it/__init__.py +0 -0
- frogml_cli/commands/models/init/_logic/template/churn/{{cookiecutter.model_directory}}/tests/it/test_churn.py +32 -0
- frogml_cli/commands/models/init/_logic/template/credit_risk/__init__.py +0 -0
- frogml_cli/commands/models/init/_logic/template/credit_risk/cookiecutter.json +3 -0
- frogml_cli/commands/models/init/_logic/template/credit_risk/{{cookiecutter.model_directory}}/__init__.py +0 -0
- frogml_cli/commands/models/init/_logic/template/credit_risk/{{cookiecutter.model_directory}}/main/__init__.py +5 -0
- frogml_cli/commands/models/init/_logic/template/credit_risk/{{cookiecutter.model_directory}}/main/conda.yml +11 -0
- frogml_cli/commands/models/init/_logic/template/credit_risk/{{cookiecutter.model_directory}}/main/data.csv +1001 -0
- frogml_cli/commands/models/init/_logic/template/credit_risk/{{cookiecutter.model_directory}}/main/model.py +108 -0
- frogml_cli/commands/models/init/_logic/template/general/__init__.py +0 -0
- frogml_cli/commands/models/init/_logic/template/general/cookiecutter.json +6 -0
- frogml_cli/commands/models/init/_logic/template/general/{{cookiecutter.model_directory}}/__init__.py +0 -0
- frogml_cli/commands/models/init/_logic/template/general/{{cookiecutter.model_directory}}/{{cookiecutter.main_directory}}/__init__.py +5 -0
- frogml_cli/commands/models/init/_logic/template/general/{{cookiecutter.model_directory}}/{{cookiecutter.main_directory}}/conda.yml +8 -0
- frogml_cli/commands/models/init/_logic/template/general/{{cookiecutter.model_directory}}/{{cookiecutter.main_directory}}/model.py +66 -0
- frogml_cli/commands/models/init/_logic/template/general/{{cookiecutter.model_directory}}/{{cookiecutter.test_directory}}/__init__.py +0 -0
- frogml_cli/commands/models/init/_logic/template/general/{{cookiecutter.model_directory}}/{{cookiecutter.test_directory}}/test_qwak_model.py +5 -0
- frogml_cli/commands/models/init/_logic/template/titanic/__init__.py +0 -0
- frogml_cli/commands/models/init/_logic/template/titanic/cookiecutter.json +3 -0
- frogml_cli/commands/models/init/_logic/template/titanic/{{cookiecutter.model_directory}}/__init__.py +0 -0
- frogml_cli/commands/models/init/_logic/template/titanic/{{cookiecutter.model_directory}}/main/__init__.py +5 -0
- frogml_cli/commands/models/init/_logic/template/titanic/{{cookiecutter.model_directory}}/main/conda.yml +11 -0
- frogml_cli/commands/models/init/_logic/template/titanic/{{cookiecutter.model_directory}}/main/model.py +98 -0
- frogml_cli/commands/models/init/_logic/template/titanic/{{cookiecutter.model_directory}}/tests/__init__.py +0 -0
- frogml_cli/commands/models/init/_logic/template/titanic/{{cookiecutter.model_directory}}/tests/it/__init__.py +0 -0
- frogml_cli/commands/models/init/_logic/template/titanic/{{cookiecutter.model_directory}}/tests/it/test_titanic.py +24 -0
- frogml_cli/commands/models/init/_logic/template/titanic_poetry/__init__.py +0 -0
- frogml_cli/commands/models/init/_logic/template/titanic_poetry/cookiecutter.json +3 -0
- frogml_cli/commands/models/init/_logic/template/titanic_poetry/{{cookiecutter.model_directory}}/__init__.py +0 -0
- frogml_cli/commands/models/init/_logic/template/titanic_poetry/{{cookiecutter.model_directory}}/main/__init__.py +5 -0
- frogml_cli/commands/models/init/_logic/template/titanic_poetry/{{cookiecutter.model_directory}}/main/model.py +98 -0
- frogml_cli/commands/models/init/_logic/template/titanic_poetry/{{cookiecutter.model_directory}}/main/pyproject.toml +20 -0
- frogml_cli/commands/models/init/_logic/template/titanic_poetry/{{cookiecutter.model_directory}}/tests/__init__.py +0 -0
- frogml_cli/commands/models/init/_logic/template/titanic_poetry/{{cookiecutter.model_directory}}/tests/it/__init__.py +0 -0
- frogml_cli/commands/models/init/_logic/template/titanic_poetry/{{cookiecutter.model_directory}}/tests/it/test_titanic.py +25 -0
- frogml_cli/commands/models/init/ui.py +61 -0
- frogml_cli/commands/models/list/__init__.py +0 -0
- frogml_cli/commands/models/list/_logic.py +5 -0
- frogml_cli/commands/models/list/ui.py +41 -0
- frogml_cli/commands/models/list_models/__init__.py +0 -0
- frogml_cli/commands/models/list_models/_logic.py +11 -0
- frogml_cli/commands/models/list_models/ui.py +60 -0
- frogml_cli/commands/models/metadata/__init__.py +0 -0
- frogml_cli/commands/models/metadata/_logic.py +12 -0
- frogml_cli/commands/models/metadata/ui.py +60 -0
- frogml_cli/commands/models/models_command_group.py +44 -0
- frogml_cli/commands/models/runtime/__init__.py +0 -0
- frogml_cli/commands/models/runtime/logs/__init__.py +0 -0
- frogml_cli/commands/models/runtime/logs/ui.py +63 -0
- frogml_cli/commands/models/runtime/runtime_commands_group.py +17 -0
- frogml_cli/commands/models/runtime/update/__init__.py +0 -0
- frogml_cli/commands/models/runtime/update/_logic.py +9 -0
- frogml_cli/commands/models/runtime/update/ui.py +17 -0
- frogml_cli/commands/secrets/__init__.py +0 -0
- frogml_cli/commands/secrets/delete/__init__.py +0 -0
- frogml_cli/commands/secrets/delete/_logic.py +5 -0
- frogml_cli/commands/secrets/delete/ui.py +21 -0
- frogml_cli/commands/secrets/get/__init__.py +0 -0
- frogml_cli/commands/secrets/get/_logic.py +5 -0
- frogml_cli/commands/secrets/get/ui.py +17 -0
- frogml_cli/commands/secrets/secrets_commands_group.py +19 -0
- frogml_cli/commands/secrets/set/__init__.py +0 -0
- frogml_cli/commands/secrets/set/_logic.py +5 -0
- frogml_cli/commands/secrets/set/ui.py +16 -0
- frogml_cli/commands/ui_tools.py +18 -0
- frogml_cli/exceptions/__init__.py +14 -0
- frogml_cli/exceptions/frogml_command_exception.py +2 -0
- frogml_cli/exceptions/frogml_deploy_new_build_failed.py +5 -0
- frogml_cli/exceptions/frogml_resource_not_found.py +2 -0
- frogml_cli/inner/__init__.py +0 -0
- frogml_cli/inner/file_registry.py +98 -0
- frogml_cli/inner/tools/__init__.py +0 -0
- frogml_cli/inner/tools/cli_tools.py +179 -0
- frogml_cli/inner/tools/config_handler.py +29 -0
- frogml_cli/inner/tools/dataclasses_utils.py +21 -0
- frogml_cli/inner/tools/logger/__init__.py +3 -0
- frogml_cli/inner/tools/logger/logger.py +278 -0
- frogml_cli/inner/tools/logger/logging.yml +79 -0
- frogml_cli/inner/tools/tracking.py +47 -0
- frogml_cli/main.py +9 -0
- frogml_cli/tools/__init__.py +0 -0
- frogml_cli/tools/colors.py +13 -0
- frogml_cli/tools/const.py +3 -0
- frogml_cli/tools/files.py +63 -0
- frogml_cli/tools/log_handling.py +159 -0
- frogml_cli/tools/utils.py +45 -0
- frogml_cli-0.0.1.dist-info/METADATA +51 -0
- frogml_cli-0.0.1.dist-info/RECORD +287 -0
- frogml_cli-0.0.1.dist-info/WHEEL +4 -0
- frogml_cli-0.0.1.dist-info/entry_points.txt +3 -0
@@ -0,0 +1,407 @@
|
|
1
|
+
from abc import ABC
|
2
|
+
from dataclasses import dataclass, field
|
3
|
+
from datetime import datetime
|
4
|
+
from enum import Enum
|
5
|
+
from typing import Dict, List
|
6
|
+
|
7
|
+
from frogml._proto.qwak.audience.v1.audience_pb2 import (
|
8
|
+
AudienceRoutesEntry as AudienceProto,
|
9
|
+
)
|
10
|
+
from frogml._proto.qwak.audience.v1.audience_pb2 import Route as RouteProto
|
11
|
+
from frogml._proto.qwak.auto_scaling.v1.auto_scaling_pb2 import (
|
12
|
+
AutoScalingConfig as AutoScalingProto,
|
13
|
+
)
|
14
|
+
from frogml._proto.qwak.deployment.deployment_pb2 import (
|
15
|
+
DeploymentDetails as DeploymentProto,
|
16
|
+
)
|
17
|
+
from frogml._proto.qwak.deployment.deployment_pb2 import (
|
18
|
+
RealTimeConfig as RealTimeConfigProto,
|
19
|
+
)
|
20
|
+
from frogml._proto.qwak.deployment.deployment_pb2 import (
|
21
|
+
ServingStrategy as ServingStrategyProto,
|
22
|
+
)
|
23
|
+
from frogml._proto.qwak.deployment.deployment_pb2 import (
|
24
|
+
StreamConfig as StreamConfigProto,
|
25
|
+
)
|
26
|
+
|
27
|
+
|
28
|
+
@dataclass
|
29
|
+
class TrafficSpec:
|
30
|
+
percentage: int = field(default=None)
|
31
|
+
is_shadow: bool = field(default=None)
|
32
|
+
|
33
|
+
|
34
|
+
@dataclass
|
35
|
+
class Variation:
|
36
|
+
name: str = field(default=None)
|
37
|
+
environment_id: str = field(default=None)
|
38
|
+
traffic_spec: TrafficSpec = field(default=None)
|
39
|
+
|
40
|
+
|
41
|
+
@dataclass
|
42
|
+
class Route:
|
43
|
+
variation_name: str = field(default=None)
|
44
|
+
weight: int = field(default=None)
|
45
|
+
shadow: bool = field(default=None)
|
46
|
+
model_id: str = field(default=None)
|
47
|
+
environment_id: str = field(default=None)
|
48
|
+
audience_id: str = field(default=None)
|
49
|
+
|
50
|
+
|
51
|
+
@dataclass
|
52
|
+
class AudienceRoute:
|
53
|
+
audience_id: str = field(default=None)
|
54
|
+
audience_name: str = field(default=None)
|
55
|
+
routes: List[Route] = field(default_factory=list)
|
56
|
+
order: int = field(default=None)
|
57
|
+
|
58
|
+
|
59
|
+
@dataclass
|
60
|
+
class EnvironmentAudienceRoute(AudienceRoute):
|
61
|
+
environment_id: str = field(default=None)
|
62
|
+
|
63
|
+
@staticmethod
|
64
|
+
def from_proto(environment_id: str, proto: AudienceProto):
|
65
|
+
return EnvironmentAudienceRoute(
|
66
|
+
audience_id=proto.audience_id,
|
67
|
+
audience_name=proto.audience_name,
|
68
|
+
routes=Deployment.parse_routes(proto.routes),
|
69
|
+
order=proto.order,
|
70
|
+
environment_id=environment_id,
|
71
|
+
)
|
72
|
+
|
73
|
+
|
74
|
+
class Metric(Enum):
|
75
|
+
NOT_VALID = 0
|
76
|
+
CPU = 1
|
77
|
+
MEMORY = 2
|
78
|
+
LATENCY = 3
|
79
|
+
GPU = 4
|
80
|
+
ERROR_RATE = 5
|
81
|
+
THROUGHPUT = 6
|
82
|
+
|
83
|
+
|
84
|
+
class Aggregation(Enum):
|
85
|
+
NOT_VALID = 0
|
86
|
+
MIN = 1
|
87
|
+
MAX = 2
|
88
|
+
AVERAGE = 3
|
89
|
+
SUM = 4
|
90
|
+
|
91
|
+
|
92
|
+
@dataclass
|
93
|
+
class QuerySpec:
|
94
|
+
metric: Metric = field(default=None)
|
95
|
+
aggregation: Aggregation = field(default=None)
|
96
|
+
time_period: int = field(default=None)
|
97
|
+
error_code: str = field(default=None)
|
98
|
+
|
99
|
+
|
100
|
+
class Triggers(ABC):
|
101
|
+
pass
|
102
|
+
|
103
|
+
|
104
|
+
@dataclass
|
105
|
+
class PrometheusTrigger(Triggers):
|
106
|
+
query_spec: QuerySpec = field(default=None)
|
107
|
+
threshold: int = field(default=None)
|
108
|
+
|
109
|
+
|
110
|
+
@dataclass
|
111
|
+
class AutoScalingConfig:
|
112
|
+
min_replica_count: int = field(default=None)
|
113
|
+
max_replica_count: int = field(default=None)
|
114
|
+
pooling_interval: int = field(default=None)
|
115
|
+
cool_down_period: int = field(default=None)
|
116
|
+
triggers: List[Triggers] = field(default_factory=list)
|
117
|
+
|
118
|
+
|
119
|
+
@dataclass
|
120
|
+
class TrafficConfig:
|
121
|
+
selected_variation_name: str = field(default=None)
|
122
|
+
variations: List[Variation] = field(default_factory=list)
|
123
|
+
audiences: List[AudienceRoute] = field(default_factory=list)
|
124
|
+
fallback_variation: str = field(default=None)
|
125
|
+
|
126
|
+
|
127
|
+
class ServingConfig(ABC):
|
128
|
+
pass
|
129
|
+
|
130
|
+
|
131
|
+
@dataclass
|
132
|
+
class RealTimeConfig(ServingConfig):
|
133
|
+
traffic_config: TrafficConfig = field(default=None)
|
134
|
+
autoscaling_config: AutoScalingConfig = field(default=None)
|
135
|
+
|
136
|
+
|
137
|
+
@dataclass
|
138
|
+
class BatchConfig(ServingConfig):
|
139
|
+
pass
|
140
|
+
|
141
|
+
|
142
|
+
class AutoOffSet(Enum):
|
143
|
+
UNKNOWN = 0
|
144
|
+
EARLIEST = 1
|
145
|
+
LATEST = 2
|
146
|
+
|
147
|
+
|
148
|
+
@dataclass
|
149
|
+
class Consumer:
|
150
|
+
bootstrap_server: List[str] = field(default_factory=list)
|
151
|
+
topic: str = field(default=None)
|
152
|
+
group: str = field(default=None)
|
153
|
+
timeout: int = field(default=None)
|
154
|
+
auto_offset: AutoOffSet = field(default=None)
|
155
|
+
max_batch_size: int = field(default=None)
|
156
|
+
max_poll_latency: float = field(default=None)
|
157
|
+
|
158
|
+
|
159
|
+
class Compression(Enum):
|
160
|
+
UNKNOWN = 0
|
161
|
+
UNCOMPRESSED = 1
|
162
|
+
GZIP = 2
|
163
|
+
SNAPPY = 3
|
164
|
+
LZ4 = 4
|
165
|
+
ZSTD = 5
|
166
|
+
|
167
|
+
|
168
|
+
@dataclass
|
169
|
+
class Producer:
|
170
|
+
bootstrap_server: List[str] = field(default_factory=list)
|
171
|
+
topic: str = field(default=None)
|
172
|
+
compression: Compression = field(default=None)
|
173
|
+
|
174
|
+
|
175
|
+
@dataclass
|
176
|
+
class KafkaConfig:
|
177
|
+
consumer: Consumer = field(default=None)
|
178
|
+
producer: Producer = field(default=None)
|
179
|
+
workers: int = field(default=None)
|
180
|
+
|
181
|
+
|
182
|
+
@dataclass
|
183
|
+
class StreamConfig(ServingConfig):
|
184
|
+
kafka: KafkaConfig = field(default=None)
|
185
|
+
|
186
|
+
|
187
|
+
class BuildStatus(Enum):
|
188
|
+
INVALID = 0
|
189
|
+
IN_PROGRESS = 1
|
190
|
+
SUCCESSFUL = 2
|
191
|
+
FAILED = 3
|
192
|
+
REMOTE_BUILD_INITIALIZING = 4
|
193
|
+
REMOTE_BUILD_CANCELLED = 5
|
194
|
+
REMOTE_BUILD_TIMED_OUT = 6
|
195
|
+
REMOTE_BUILD_UNKNOWN = 7
|
196
|
+
SYNCING_ENVIRONMENTS = 8
|
197
|
+
FINISHED_SYNCING = 9
|
198
|
+
|
199
|
+
|
200
|
+
class MemoryUnit(Enum):
|
201
|
+
UNKNOWN = 0
|
202
|
+
MIB = 1
|
203
|
+
GIB = 2
|
204
|
+
|
205
|
+
|
206
|
+
class KubeDeploymentType(Enum):
|
207
|
+
UNDEFINED = 0
|
208
|
+
ONLINE = 1
|
209
|
+
STREAM = 2
|
210
|
+
BATCH = 3
|
211
|
+
|
212
|
+
|
213
|
+
class GpuType(Enum):
|
214
|
+
INVALID_GPU = 0
|
215
|
+
ONLINE = 1
|
216
|
+
STREAM = 2
|
217
|
+
BATCH = 3
|
218
|
+
|
219
|
+
|
220
|
+
@dataclass
|
221
|
+
class Deployment:
|
222
|
+
build_id: str = field(default=None)
|
223
|
+
number_of_pods: int = field(default=None)
|
224
|
+
cpu_fraction: float = field(default=None)
|
225
|
+
memory_amount: int = field(default=None)
|
226
|
+
memory_units: MemoryUnit = field(default=MemoryUnit.UNKNOWN)
|
227
|
+
number_of_workers: int = field(default=None)
|
228
|
+
http_request_timeout_ms: int = field(default=None)
|
229
|
+
kube_deployment_type: KubeDeploymentType = field(
|
230
|
+
default=KubeDeploymentType.UNDEFINED
|
231
|
+
)
|
232
|
+
serving_config: ServingConfig = field(default=None)
|
233
|
+
variation: Variation = field(default=None)
|
234
|
+
custom_iam_role_arn: str = field(default=None)
|
235
|
+
max_batch_size: int = field(default=None)
|
236
|
+
gpu_type: GpuType = field(default=GpuType.INVALID_GPU)
|
237
|
+
gpu_amount: int = field(default=None)
|
238
|
+
environment_id: str = field(default=None)
|
239
|
+
available_replicas: int = field(default=None)
|
240
|
+
deployment_process_timeout_limit: int = field(default=None)
|
241
|
+
daemon_mode: bool = field(default=None)
|
242
|
+
purchase_option: str = field(default=None)
|
243
|
+
environment_variables: Dict[str, str] = field(default_factory=dict)
|
244
|
+
last_deployed: datetime = field(default=datetime.now())
|
245
|
+
|
246
|
+
@staticmethod
|
247
|
+
def parse_routes(proto: List[RouteProto]) -> List[Route]:
|
248
|
+
routes = []
|
249
|
+
for proto_route in proto:
|
250
|
+
route = Route(
|
251
|
+
variation_name=proto_route.variation_name,
|
252
|
+
weight=proto_route.weight,
|
253
|
+
shadow=proto_route.shadow,
|
254
|
+
model_id=proto_route.model_id,
|
255
|
+
environment_id=proto_route.environment_id,
|
256
|
+
audience_id=proto_route.audience_id,
|
257
|
+
)
|
258
|
+
routes.append(route)
|
259
|
+
return routes
|
260
|
+
|
261
|
+
@staticmethod
|
262
|
+
def parse_audience_routes(proto: List[RouteProto]) -> List[AudienceRoute]:
|
263
|
+
routes = []
|
264
|
+
for proto_route in proto:
|
265
|
+
route = AudienceRoute(
|
266
|
+
audience_id=proto_route.audience_id,
|
267
|
+
audience_name=proto_route.audience_name,
|
268
|
+
routes=Deployment.parse_routes(proto_route.routes),
|
269
|
+
order=proto_route.order,
|
270
|
+
)
|
271
|
+
routes.append(route)
|
272
|
+
return routes
|
273
|
+
|
274
|
+
@staticmethod
|
275
|
+
def parse_autoscaling(proto: AutoScalingProto) -> AutoScalingConfig:
|
276
|
+
triggers = []
|
277
|
+
for proto_trigger in proto.triggers.triggers:
|
278
|
+
trigger = PrometheusTrigger(
|
279
|
+
query_spec=QuerySpec(
|
280
|
+
metric=Metric(
|
281
|
+
proto_trigger.prometheus_trigger.query_spec.metric_type
|
282
|
+
),
|
283
|
+
aggregation=Aggregation(
|
284
|
+
proto_trigger.prometheus_trigger.query_spec.aggregation_type
|
285
|
+
),
|
286
|
+
time_period=proto_trigger.prometheus_trigger.query_spec.time_period,
|
287
|
+
error_code=proto_trigger.prometheus_trigger.query_spec.error_code,
|
288
|
+
),
|
289
|
+
threshold=proto_trigger.prometheus_trigger.threshold,
|
290
|
+
)
|
291
|
+
triggers.append(trigger)
|
292
|
+
return AutoScalingConfig(
|
293
|
+
min_replica_count=proto.min_replica_count,
|
294
|
+
max_replica_count=proto.max_replica_count,
|
295
|
+
pooling_interval=proto.polling_interval,
|
296
|
+
cool_down_period=proto.cool_down_period,
|
297
|
+
triggers=triggers,
|
298
|
+
)
|
299
|
+
|
300
|
+
@staticmethod
|
301
|
+
def parse_realtime_config(proto: RealTimeConfigProto) -> RealTimeConfig:
|
302
|
+
variations = []
|
303
|
+
for proto_variation in proto.traffic_config.variations:
|
304
|
+
variation = Variation(
|
305
|
+
name=proto_variation.name,
|
306
|
+
environment_id=proto_variation.environment_id,
|
307
|
+
traffic_spec=TrafficSpec(
|
308
|
+
percentage=proto_variation.traffic.percentage,
|
309
|
+
is_shadow=proto_variation.traffic.is_shadow,
|
310
|
+
),
|
311
|
+
)
|
312
|
+
variations.append(variation)
|
313
|
+
audiences = []
|
314
|
+
for proto_audience in proto.traffic_config.audience_routes_entries:
|
315
|
+
audience = AudienceRoute(
|
316
|
+
audience_id=proto_audience.audience_id,
|
317
|
+
audience_name=proto_audience.audience_name,
|
318
|
+
routes=Deployment.parse_routes(proto_audience.routes),
|
319
|
+
order=proto_audience.order,
|
320
|
+
)
|
321
|
+
audiences.append(audience)
|
322
|
+
|
323
|
+
autoscaling = Deployment.parse_autoscaling(proto.auto_scaling_config)
|
324
|
+
return RealTimeConfig(
|
325
|
+
traffic_config=TrafficConfig(
|
326
|
+
variations=variations,
|
327
|
+
audiences=audiences,
|
328
|
+
fallback_variation=proto.traffic_config.fallback_variation,
|
329
|
+
),
|
330
|
+
autoscaling_config=autoscaling,
|
331
|
+
)
|
332
|
+
|
333
|
+
@staticmethod
|
334
|
+
def parse_streaming_config(proto_config: StreamConfigProto) -> StreamConfig:
|
335
|
+
return StreamConfig(
|
336
|
+
kafka=KafkaConfig(
|
337
|
+
consumer=Consumer(
|
338
|
+
bootstrap_server=list(proto_config.kafka.consumer.bootstrap_server),
|
339
|
+
topic=proto_config.kafka.consumer.topic,
|
340
|
+
group=proto_config.kafka.consumer.group,
|
341
|
+
timeout=proto_config.kafka.consumer.timeout,
|
342
|
+
auto_offset=AutoOffSet(proto_config.kafka.consumer.auto_offset_type)
|
343
|
+
if proto_config.kafka.consumer.auto_offset_type
|
344
|
+
else None,
|
345
|
+
max_batch_size=proto_config.kafka.consumer.max_batch_size,
|
346
|
+
max_poll_latency=proto_config.kafka.consumer.max_poll_latency,
|
347
|
+
),
|
348
|
+
producer=Producer(
|
349
|
+
bootstrap_server=list(proto_config.kafka.producer.bootstrap_server),
|
350
|
+
topic=proto_config.kafka.producer.topic,
|
351
|
+
compression=Compression(
|
352
|
+
proto_config.kafka.producer.compression_type
|
353
|
+
)
|
354
|
+
if proto_config.kafka.producer.compression_type
|
355
|
+
else None,
|
356
|
+
),
|
357
|
+
workers=proto_config.kafka.workers,
|
358
|
+
)
|
359
|
+
)
|
360
|
+
|
361
|
+
@staticmethod
|
362
|
+
def parse_serving_strategy(proto: ServingStrategyProto) -> ServingConfig:
|
363
|
+
which = proto.WhichOneof("Strategy")
|
364
|
+
if which == "realtime_config":
|
365
|
+
return Deployment.parse_realtime_config(proto.realtime_config)
|
366
|
+
elif which == "batch_config":
|
367
|
+
return BatchConfig()
|
368
|
+
elif which == "stream_config":
|
369
|
+
return Deployment.parse_streaming_config(proto.stream_config)
|
370
|
+
else:
|
371
|
+
raise ValueError(f"Unknown serving strategy: {which}")
|
372
|
+
|
373
|
+
@staticmethod
|
374
|
+
def from_proto(proto: DeploymentProto):
|
375
|
+
variation = Variation(
|
376
|
+
name=proto.variation.name,
|
377
|
+
environment_id=proto.variation.environment_id,
|
378
|
+
traffic_spec=TrafficSpec(
|
379
|
+
percentage=proto.variation.traffic.percentage,
|
380
|
+
is_shadow=proto.variation.traffic.is_shadow,
|
381
|
+
),
|
382
|
+
)
|
383
|
+
return Deployment(
|
384
|
+
build_id=proto.build_id,
|
385
|
+
number_of_pods=proto.number_of_pods,
|
386
|
+
cpu_fraction=proto.cpu_fraction,
|
387
|
+
memory_amount=proto.memory_amount,
|
388
|
+
memory_units=MemoryUnit(proto.memory_units),
|
389
|
+
number_of_workers=proto.number_of_workers,
|
390
|
+
http_request_timeout_ms=proto.http_request_timeout_ms,
|
391
|
+
kube_deployment_type=KubeDeploymentType(proto.kube_deployment_type),
|
392
|
+
serving_config=Deployment.parse_serving_strategy(proto.serving_strategy),
|
393
|
+
variation=variation,
|
394
|
+
custom_iam_role_arn=proto.custom_iam_role_arn,
|
395
|
+
max_batch_size=proto.max_batch_size,
|
396
|
+
gpu_type=GpuType(proto.gpu_type),
|
397
|
+
gpu_amount=proto.gpu_amount,
|
398
|
+
environment_id=proto.environment_id,
|
399
|
+
available_replicas=proto.available_replicas,
|
400
|
+
daemon_mode=bool(proto.daemon_mode.value),
|
401
|
+
deployment_process_timeout_limit=proto.deployment_process_timeout_limit,
|
402
|
+
purchase_option=proto.purchase_option,
|
403
|
+
environment_variables=dict(proto.environment_variables),
|
404
|
+
last_deployed=datetime.fromtimestamp(
|
405
|
+
proto.last_deployed.seconds + proto.last_deployed.nanos / 1e9
|
406
|
+
),
|
407
|
+
)
|
@@ -0,0 +1,116 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from typing import Dict
|
4
|
+
|
5
|
+
from frogml._proto.qwak.deployment.deployment_pb2 import (
|
6
|
+
BatchConfig,
|
7
|
+
EnvironmentDeploymentMessage,
|
8
|
+
HostingService,
|
9
|
+
KubeDeployment,
|
10
|
+
KubeDeploymentType,
|
11
|
+
ServingStrategy,
|
12
|
+
)
|
13
|
+
from frogml.core.clients.administration.eco_system.client import EcosystemClient
|
14
|
+
from frogml.core.clients.instance_template.client import (
|
15
|
+
InstanceTemplateManagementClient,
|
16
|
+
)
|
17
|
+
from frogml.core.exceptions import FrogmlException
|
18
|
+
|
19
|
+
from frogml_cli.commands.models.deployments.deploy._logic.advance_deployment_options_handler import (
|
20
|
+
get_advanced_deployment_options_from_deploy_config,
|
21
|
+
)
|
22
|
+
from frogml_cli.commands.models.deployments.deploy._logic.deploy_config import (
|
23
|
+
DeployConfig,
|
24
|
+
)
|
25
|
+
from frogml_cli.commands.models.deployments.deploy._logic.deployment_size_mapper import (
|
26
|
+
deployment_size_from_deploy_config,
|
27
|
+
)
|
28
|
+
from frogml_cli.commands.models.deployments.deploy.realtime._logic.serving_strategy_mapper import (
|
29
|
+
create_realtime_serving_strategy_from_deploy_config,
|
30
|
+
)
|
31
|
+
from frogml_cli.commands.models.deployments.deploy.streaming._logic.serving_strategy_mapper import (
|
32
|
+
create_streaming_serving_strategy_from_deploy_config,
|
33
|
+
)
|
34
|
+
from frogml_cli.inner.tools.cli_tools import dictify_params
|
35
|
+
|
36
|
+
UNKNOWN_SERVING_STRATEGY = (
|
37
|
+
"The deployments type doesn't have a serving strategy configured"
|
38
|
+
)
|
39
|
+
|
40
|
+
|
41
|
+
def get_env_to_deployment_message(
|
42
|
+
deploy_config: DeployConfig,
|
43
|
+
kube_deployment_type: KubeDeploymentType,
|
44
|
+
ecosystem_client: EcosystemClient,
|
45
|
+
instance_template_client: InstanceTemplateManagementClient,
|
46
|
+
) -> Dict[str, EnvironmentDeploymentMessage]:
|
47
|
+
deployment_size = deployment_size_from_deploy_config(
|
48
|
+
deploy_config, instance_template_client, ecosystem_client
|
49
|
+
)
|
50
|
+
advanced_deployment_options = get_advanced_deployment_options_from_deploy_config(
|
51
|
+
deploy_config, kube_deployment_type
|
52
|
+
)
|
53
|
+
environment_variables = {}
|
54
|
+
|
55
|
+
if len(deploy_config.realtime.environments) != 0:
|
56
|
+
deploy_config.environments = deploy_config.realtime.environments
|
57
|
+
|
58
|
+
environment_name_to_config = ecosystem_client.get_environments_names_to_details(
|
59
|
+
deploy_config.environments
|
60
|
+
)
|
61
|
+
|
62
|
+
if kube_deployment_type == KubeDeploymentType.ONLINE:
|
63
|
+
env_to_serving_strategy = create_realtime_serving_strategy_from_deploy_config(
|
64
|
+
deploy_config,
|
65
|
+
environment_name_to_config,
|
66
|
+
)
|
67
|
+
environment_variables = dictify_params(deploy_config.realtime.env_vars)
|
68
|
+
elif kube_deployment_type == KubeDeploymentType.BATCH:
|
69
|
+
env_to_serving_strategy = {}
|
70
|
+
if len(environment_name_to_config) == 0:
|
71
|
+
env_to_serving_strategy = {
|
72
|
+
ecosystem_client.get_account_details().default_environment_id: ServingStrategy(
|
73
|
+
batch_config=BatchConfig()
|
74
|
+
)
|
75
|
+
}
|
76
|
+
else:
|
77
|
+
for env_name, env_config in environment_name_to_config.items():
|
78
|
+
env_to_serving_strategy[env_config.id] = ServingStrategy(
|
79
|
+
batch_config=BatchConfig()
|
80
|
+
)
|
81
|
+
|
82
|
+
elif kube_deployment_type == KubeDeploymentType.STREAM:
|
83
|
+
env_to_serving_strategy = {}
|
84
|
+
if len(environment_name_to_config) == 0:
|
85
|
+
env_to_serving_strategy[
|
86
|
+
ecosystem_client.get_account_details().default_environment_id
|
87
|
+
] = create_streaming_serving_strategy_from_deploy_config(deploy_config)
|
88
|
+
else:
|
89
|
+
for env_name, env_config in environment_name_to_config.items():
|
90
|
+
env_to_serving_strategy[
|
91
|
+
env_config.id
|
92
|
+
] = create_streaming_serving_strategy_from_deploy_config(deploy_config)
|
93
|
+
environment_variables = dictify_params(deploy_config.stream.env_vars)
|
94
|
+
else:
|
95
|
+
raise FrogmlException(UNKNOWN_SERVING_STRATEGY)
|
96
|
+
env_to_hosting_services = {
|
97
|
+
env_id: HostingService(
|
98
|
+
kube_deployment=KubeDeployment(
|
99
|
+
deployment_size=deployment_size,
|
100
|
+
advanced_deployment_options=advanced_deployment_options,
|
101
|
+
serving_strategy=serving_strategy,
|
102
|
+
kube_deployment_type=kube_deployment_type,
|
103
|
+
environment_variables=environment_variables,
|
104
|
+
),
|
105
|
+
)
|
106
|
+
for env_id, serving_strategy in env_to_serving_strategy.items()
|
107
|
+
}
|
108
|
+
env_deployment_messages = {
|
109
|
+
env_id: EnvironmentDeploymentMessage(
|
110
|
+
model_id=deploy_config.model_id,
|
111
|
+
build_id=deploy_config.build_id,
|
112
|
+
hosting_service=hosting_service,
|
113
|
+
)
|
114
|
+
for env_id, hosting_service in env_to_hosting_services.items()
|
115
|
+
}
|
116
|
+
return env_deployment_messages
|
@@ -0,0 +1,156 @@
|
|
1
|
+
from typing import Dict
|
2
|
+
|
3
|
+
from frogml._proto.qwak.deployment.deployment_pb2 import ModelDeploymentStatus
|
4
|
+
from frogml._proto.qwak.deployment.deployment_service_pb2 import DeployModelResponse
|
5
|
+
from frogml._proto.qwak.ecosystem.v0.ecosystem_pb2 import UserContextEnvironmentDetails
|
6
|
+
from frogml.core.clients.administration.eco_system.client import EcosystemClient
|
7
|
+
from frogml.core.exceptions import FrogmlException
|
8
|
+
from frogml.core.tools.logger.logger import get_frogml_logger
|
9
|
+
from tabulate import tabulate
|
10
|
+
|
11
|
+
from frogml_cli.commands.models.deployments.deploy._logic.base_deploy_executor import (
|
12
|
+
FAILED_STATUS,
|
13
|
+
BaseDeployExecutor,
|
14
|
+
)
|
15
|
+
from frogml_cli.tools.utils import frogml_spinner
|
16
|
+
|
17
|
+
logger = get_frogml_logger()
|
18
|
+
|
19
|
+
|
20
|
+
def __client_deployment_remote(
|
21
|
+
deploy: BaseDeployExecutor, sync: bool, output_multiple: bool = False
|
22
|
+
):
|
23
|
+
try:
|
24
|
+
deploy_response: DeployModelResponse = deploy.deploy()
|
25
|
+
deploy_status, deploy_id = (
|
26
|
+
ModelDeploymentStatus.Name(deploy_response.status),
|
27
|
+
deploy_response.deployment_named_id,
|
28
|
+
)
|
29
|
+
|
30
|
+
if deploy_response.environment_to_deployment_result:
|
31
|
+
account_environments = EcosystemClient().get_environments()
|
32
|
+
output_deployments_response(account_environments, deploy, deploy_response)
|
33
|
+
__check_failed_deployments(account_environments, deploy_response)
|
34
|
+
|
35
|
+
if sync:
|
36
|
+
deployment_id_to_env = {}
|
37
|
+
for (
|
38
|
+
env_id,
|
39
|
+
env_deploy_response,
|
40
|
+
) in deploy_response.environment_to_deployment_result.items():
|
41
|
+
deployment_id_to_env[
|
42
|
+
env_deploy_response.deployment_named_id
|
43
|
+
] = account_environments.get(env_id).name
|
44
|
+
|
45
|
+
__sync_deployments(deploy, deployment_id_to_env)
|
46
|
+
|
47
|
+
if output_multiple:
|
48
|
+
return deploy_response.environment_to_deployment_result
|
49
|
+
else:
|
50
|
+
if "FAILED" in deploy_status:
|
51
|
+
raise FrogmlException(deploy_response.info)
|
52
|
+
|
53
|
+
if sync:
|
54
|
+
__sync_deployment(deploy, deploy_id)
|
55
|
+
|
56
|
+
if not sync:
|
57
|
+
logger.info(
|
58
|
+
"Deployment initiated successfully, Use --sync to wait for deployments to be ready."
|
59
|
+
)
|
60
|
+
return deploy_id, deploy_status
|
61
|
+
except Exception as e:
|
62
|
+
logger.error(f"Deployment failed, Error: {e}")
|
63
|
+
raise e
|
64
|
+
|
65
|
+
|
66
|
+
def __check_failed_deployments(
|
67
|
+
account_environments: Dict[str, UserContextEnvironmentDetails],
|
68
|
+
deploy_response: DeployModelResponse,
|
69
|
+
):
|
70
|
+
failed_deployments = {}
|
71
|
+
for (
|
72
|
+
env_id,
|
73
|
+
env_deploy_response,
|
74
|
+
) in deploy_response.environment_to_deployment_result.items():
|
75
|
+
deploy_status = ModelDeploymentStatus.Name(env_deploy_response.status)
|
76
|
+
if "FAILED" in deploy_status:
|
77
|
+
env_config = account_environments.get(env_id)
|
78
|
+
failed_deployments[
|
79
|
+
env_config.name if env_config else env_id
|
80
|
+
] = env_deploy_response.info
|
81
|
+
if failed_deployments:
|
82
|
+
failed_deployments_message = "\n".join(
|
83
|
+
[
|
84
|
+
f"Environment {env_name}: {reason}"
|
85
|
+
for env_name, reason in failed_deployments.items()
|
86
|
+
]
|
87
|
+
)
|
88
|
+
raise FrogmlException(
|
89
|
+
f"The following deployments failed:\n {failed_deployments_message}"
|
90
|
+
)
|
91
|
+
|
92
|
+
|
93
|
+
def output_deployments_response(
|
94
|
+
account_environments: Dict[str, UserContextEnvironmentDetails],
|
95
|
+
deploy: BaseDeployExecutor,
|
96
|
+
deploy_response: DeployModelResponse,
|
97
|
+
):
|
98
|
+
for (
|
99
|
+
env_id,
|
100
|
+
env_deploy_response,
|
101
|
+
) in deploy_response.environment_to_deployment_result.items():
|
102
|
+
env_config = account_environments.get(env_id)
|
103
|
+
if env_deploy_response.status == ModelDeploymentStatus.INITIATING_DEPLOYMENT:
|
104
|
+
logger.info(
|
105
|
+
tabulate(
|
106
|
+
tabular_data=[
|
107
|
+
["Environment", env_config.name],
|
108
|
+
["Model ID", deploy.config.model_id],
|
109
|
+
["Build ID", deploy.config.build_id],
|
110
|
+
["Deployment ID", env_deploy_response.deployment_named_id],
|
111
|
+
],
|
112
|
+
tablefmt="fancy_grid",
|
113
|
+
)
|
114
|
+
)
|
115
|
+
|
116
|
+
|
117
|
+
def __sync_deployments(
|
118
|
+
deploy: BaseDeployExecutor, deployment_id_to_env: Dict[str, str]
|
119
|
+
):
|
120
|
+
with frogml_spinner(
|
121
|
+
begin_text=f"Deploy - model: {deploy.config.model_id}, build: {deploy.config.build_id} "
|
122
|
+
f"Environments: {', '.join(deploy.config.realtime.environments)}",
|
123
|
+
end_text="Successful deployments",
|
124
|
+
print_callback=print,
|
125
|
+
):
|
126
|
+
deployment_id_to_status = deploy.poll_until_complete_multiple(
|
127
|
+
list(deployment_id_to_env.keys()), check_every_n_seconds=5
|
128
|
+
)
|
129
|
+
failed_deployments = []
|
130
|
+
for deployment_id, status in deployment_id_to_status.items():
|
131
|
+
if status in FAILED_STATUS:
|
132
|
+
failed_deployments.append(
|
133
|
+
f"Environment {deployment_id_to_env.get(deployment_id)} "
|
134
|
+
f"failed with status: {status}"
|
135
|
+
)
|
136
|
+
if failed_deployments:
|
137
|
+
raise FrogmlException("\n".join(failed_deployments))
|
138
|
+
|
139
|
+
|
140
|
+
def __sync_deployment(deploy: BaseDeployExecutor, deploy_name: str):
|
141
|
+
with frogml_spinner(
|
142
|
+
begin_text=f"Deploy - model: {deploy.config.model_id}, build: {deploy.config.build_id}",
|
143
|
+
end_text="Successful deployments",
|
144
|
+
print_callback=print,
|
145
|
+
):
|
146
|
+
deployment_status = deploy.poll_until_complete(
|
147
|
+
deploy_name, check_every_n_seconds=5
|
148
|
+
)
|
149
|
+
if deployment_status in FAILED_STATUS:
|
150
|
+
raise FrogmlException(deployment_status)
|
151
|
+
|
152
|
+
|
153
|
+
def client_deployment(
|
154
|
+
deploy: BaseDeployExecutor, sync: bool, output_multiple: bool = False
|
155
|
+
):
|
156
|
+
return __client_deployment_remote(deploy, sync, output_multiple)
|